Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
[REMOVE ME] Add a bunch of console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
thangngoc89 committed Sep 16, 2016
1 parent f4b13e4 commit e8e0f0f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 62 deletions.
127 changes: 72 additions & 55 deletions __tests__/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,82 @@ const execOpts = { cwd: target }
const phenomic = "node ./node_modules/.bin/phenomic"
const timing = process.env.CI ? 10000 : 5000

describe("Integration: CLI", () => {
beforeEach(() => {
process.env.BABEL_ENV = "development"
let child
let server

beforeEach(() => {
process.env.BABEL_ENV = "development"
})

afterEach(() => {
try {
child.kill()
}
// eslint-disable-next-line
catch (err) {}
try {
server.close()
}
// eslint-disable-next-line
catch (err) {}
})

it("should throw if a CLI flag is NOT recognized", () => {
return new Promise((resolve, reject) => {
child = exec(
`${ phenomic } start --open=false --lol`, execOpts,
(err) => {
if (err && !err.killed) {
clearTimeout(timeout)
expect(err.message.indexOf("Unknown argument") > -1).toBeTruthy()
resolve()
}
}
)

const timeout = setTimeout(() => {
child.kill()
reject("Test didn't finish before timeout")
}, timing)
})
})

it("should throw if a CLI flag is NOT recognized", () => {
return new Promise((resolve, reject) => {
const child = exec(
`${ phenomic } start --open=false --lol`, execOpts,
(err) => {
if (err && !err.killed) {
clearTimeout(timeout)
expect(err.message.indexOf("Unknown argument") > -1).toBeTruthy()
resolve()
}
it("should NOT throw if a CLI flag is recognized", () => {
return new Promise((resolve, reject) => {
child = exec(
`${ phenomic } start --open=false --devPort=4000`, execOpts,

// should die quickly...
(err) => {
if (err && !err.killed) {
clearTimeout(timeout)
reject(err)
}
)
}
)

const timeout = setTimeout(() => {
child.kill()
reject("Test didn't finish before timeout")
}, timing)
})
// ...or be ok quickly
// we assume it's ok and kill the process
// we don't need the actual build
const timeout = setTimeout(() => {
child.kill()
console.log("2 killed child")
resolve()
}, timing)
})
})

it("should NOT throw if port is used", () => {
return new Promise((resolve, reject) => {
const app = require("express")()
server = app.listen(3333, (err) => {
if (err) {
reject(err)
}

it("should NOT throw if a CLI flag is recognized", () => {
return new Promise((resolve, reject) => {
const child = exec(
`${ phenomic } start --open=false --devPort=4000`, execOpts,
`${ phenomic } start --open=false --devPort=3333`, execOpts,

// should die quickly...
(err) => {
if (err && !err.killed) {
clearTimeout(timeout)
Expand All @@ -47,41 +92,13 @@ describe("Integration: CLI", () => {
}
)

// ...or be ok quickly
// we assume it's ok and kill the process
// we don't need the actual build
const timeout = setTimeout(() => {
child.kill()
console.log("3 killed child")
server.close()
console.log("3 killed server")
resolve()
}, timing)
})
})

it("should NOT throw if port is used", () => {
return new Promise((resolve, reject) => {
const app = require("express")()
const server = app.listen(3333, (err) => {
if (err) {
reject(err)
}

const child = exec(
`${ phenomic } start --open=false --devPort=3333`, execOpts,

(err) => {
if (err && !err.killed) {
clearTimeout(timeout)
reject(err)
}
}
)

const timeout = setTimeout(() => {
child.kill()
server.close()
resolve()
}, timing * 2)
})
}, timing * 2)
})
})
})
7 changes: 0 additions & 7 deletions integration-tests/jest-config.json

This file was deleted.

0 comments on commit e8e0f0f

Please sign in to comment.