Skip to content

Commit

Permalink
tests: fix integration test (#26971)
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Sep 21, 2020
1 parent 866abdf commit ece4a6e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
6 changes: 3 additions & 3 deletions integration-tests/cache-resilience/__tests__/cache.js
Expand Up @@ -43,13 +43,13 @@ const { compareState } = require(`../utils/nodes-diff`)
const stdio = `inherit`

const build = ({ updatePlugins } = {}) => {
spawnSync(gatsbyBin, [`clean`], { stdio })
spawnSync(process.execPath, [gatsbyBin, `clean`], { stdio })
selectConfiguration(1)

let processOutput

// First run, get state
processOutput = spawnSync(gatsbyBin, [`build`], {
processOutput = spawnSync(process.execPath, [gatsbyBin, `build`], {
stdio,
env: {
...process.env,
Expand All @@ -71,7 +71,7 @@ const build = ({ updatePlugins } = {}) => {
}

// Second run, get state and compare with state from previous run
processOutput = spawnSync(gatsbyBin, [`build`], {
processOutput = spawnSync(process.execPath, [gatsbyBin, `build`], {
stdio,
env: {
...process.env,
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/cache-resilience/package.json
Expand Up @@ -19,8 +19,11 @@
},
"devDependencies": {
"gatsby-core-utils": "^1.0.21",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"jest": "^24.0.0",
"jest-cli": "^24.0.0",
"lodash": "^4.17.20",
"slash": "^3.0.0",
"snapshot-diff": "^0.6.1"
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/structured-logging/__tests__/ipc-send.js
Expand Up @@ -15,7 +15,7 @@ describe(`IPC Send`, () => {
let gatsbyProcess

beforeAll(() => {
gatsbyProcess = spawn("node", [gatsbyBin, `develop`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `develop`], {
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
env: {
...process.env,
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/structured-logging/__tests__/logs.js
Expand Up @@ -16,7 +16,7 @@ describe(`Activities`, () => {
let events = []

beforeAll(async done => {
gatsbyProcess = spawn(gatsbyBin, [`develop`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `develop`], {
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
env: {
...process.env,
Expand Down Expand Up @@ -50,8 +50,8 @@ describe(`Activities`, () => {
- Start
- Update (Optional)
- End
These tests assert whether events are correctly emitted for the complete lifecycle.
These tests assert whether events are correctly emitted for the complete lifecycle.
*/
it(`emit start, update and end events for a successful activity`, async () => {
const activityEvents = events.filter(
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/structured-logging/__tests__/panic.js
Expand Up @@ -16,7 +16,7 @@ describe(`Panic`, () => {
let events = []

beforeEach(async () => {
gatsbyProcess = spawn(gatsbyBin, [`build`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
// inherit lets us see logs in console
// stdio: [`inherit`, `inherit`, `inherit`, `ipc`],
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/structured-logging/__tests__/status.js
Expand Up @@ -17,7 +17,7 @@ describe(`Successful Build`, () => {
let events = []

beforeAll(async done => {
gatsbyProcess = spawn(gatsbyBin, [`build`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
// inherit lets us see logs in console
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
// stdio: [`inherit`, `inherit`, `inherit`, `ipc`],
Expand Down Expand Up @@ -94,7 +94,7 @@ const IndexPage = () => <div>Hello world!</div>
`
)
gatsbyProcess = spawn(gatsbyBin, [`build`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
// inherit lets us see logs in console
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
// stdio: [`inherit`, `inherit`, `inherit`, `ipc`],
Expand Down
23 changes: 13 additions & 10 deletions integration-tests/structured-logging/__tests__/to-do.js
Expand Up @@ -28,7 +28,7 @@ const gatsbyBin = path.join(
const defaultStdio = `ignore`

const collectEventsForDevelop = (events, env = {}) => {
const gatsbyProcess = spawn(gatsbyBin, [`develop`], {
const gatsbyProcess = spawn(process.execPath, [gatsbyBin, `develop`], {
stdio: [defaultStdio, defaultStdio, defaultStdio, `ipc`],
env: {
...process.env,
Expand All @@ -38,8 +38,9 @@ const collectEventsForDevelop = (events, env = {}) => {
},
})

const finishedPromise = new Promise(resolve => {
const finishedPromise = new Promise((resolve, reject) => {
let listening = true

gatsbyProcess.on(`message`, msg => {
if (!listening) {
return
Expand All @@ -55,7 +56,8 @@ const collectEventsForDevelop = (events, env = {}) => {
setTimeout(() => {
listening = false
gatsbyProcess.kill()
resolve()

setTimeout(resolve, 1000)
}, 5000)
}
})
Expand Down Expand Up @@ -332,7 +334,7 @@ describe(`develop`, () => {
events.splice(0, events.length)
}
beforeAll(async done => {
gatsbyProcess = spawn(gatsbyBin, [`develop`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `develop`], {
stdio: [defaultStdio, defaultStdio, defaultStdio, `ipc`],
env: {
...process.env,
Expand All @@ -359,8 +361,9 @@ describe(`develop`, () => {
})
})

afterAll(() => {
afterAll(done => {
gatsbyProcess.kill()
setTimeout(done, 1000)
})

describe(`code change`, () => {
Expand Down Expand Up @@ -477,7 +480,7 @@ describe(`build`, () => {
let events = []

beforeAll(async () => {
gatsbyProcess = spawn(gatsbyBin, [`build`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
stdio: [defaultStdio, defaultStdio, defaultStdio, `ipc`],
env: {
...process.env,
Expand Down Expand Up @@ -512,7 +515,7 @@ describe(`build`, () => {
let events = []

beforeAll(async () => {
gatsbyProcess = spawn(gatsbyBin, [`build`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
stdio: [defaultStdio, defaultStdio, defaultStdio, `ipc`],
env: {
...process.env,
Expand Down Expand Up @@ -544,7 +547,7 @@ describe(`build`, () => {
let events = []

beforeAll(async () => {
gatsbyProcess = spawn(gatsbyBin, [`build`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
stdio: [defaultStdio, defaultStdio, defaultStdio, `ipc`],
env: {
...process.env,
Expand Down Expand Up @@ -576,7 +579,7 @@ describe(`build`, () => {
let events = []

beforeAll(async () => {
gatsbyProcess = spawn(gatsbyBin, [`build`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
stdio: [defaultStdio, defaultStdio, defaultStdio, `ipc`],
env: {
...process.env,
Expand Down Expand Up @@ -610,7 +613,7 @@ describe(`build`, () => {
let events = []

beforeAll(async () => {
gatsbyProcess = spawn(gatsbyBin, [`build`], {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
stdio: [defaultStdio, defaultStdio, defaultStdio, `ipc`],
env: {
...process.env,
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/structured-logging/package.json
Expand Up @@ -17,9 +17,11 @@
},
"devDependencies": {
"babel-plugin-dynamic-import-node-sync": "^2.0.1",
"fs-extra": "^9.0.1",
"jest": "^24.0.0",
"jest-cli": "^24.0.0",
"joi": "^14.3.1",
"node-fetch": "^2.6.0"
"lodash": "^4.17.20",
"node-fetch": "^2.6.1"
}
}

0 comments on commit ece4a6e

Please sign in to comment.