Skip to content

Commit 34cb202

Browse files
wardpeetLekoArtsgatsbybot
authored
chore: upgrade jest (#33277)
Co-authored-by: LekoArts <[email protected]> Co-authored-by: gatsbybot <[email protected]>
1 parent ae2ffe8 commit 34cb202

File tree

79 files changed

+2144
-2983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2144
-2983
lines changed

.github/actions/high-priority-prs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"lodash": "^4.17.15"
1515
},
1616
"devDependencies": {
17-
"jest": "^25.1.0"
17+
"jest": "^27.2.1"
1818
}
1919
}

.jestSetup.js

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
process.env.GATSBY_RECIPES_NO_COLOR = "true"
2+
3+
// Potrace has a dependency on giwrap which has a process.nextTick as a sideEffect which messes up with jest.
4+
jest.mock(`gifwrap`, () => jest.fn())

deprecated-packages/gatsby-recipes/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"hicat": "^0.8.0",
4242
"is-binary-path": "^2.1.0",
4343
"is-url": "^1.2.4",
44-
"jest-diff": "^25.5.0",
44+
"jest-diff": "^27.2.0",
4545
"lock": "^1.0.0",
4646
"lodash": "^4.17.21",
4747
"mitt": "^1.2.0",

deprecated-packages/gatsby-recipes/src/providers/utils/get-diff.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import diff from "jest-diff"
1+
import { diff } from "jest-diff"
22
import chalk from "chalk"
33
import stripAnsi from "strip-ansi"
44

examples/using-jest/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
"babel-jest": "^24.9.0",
3636
"babel-preset-gatsby": "^0.5.10",
3737
"identity-obj-proxy": "^3.0.0",
38-
"jest": "^24.9.0"
38+
"jest": "^27.2.1"
3939
},
4040
"repository": {
4141
"type": "git",
4242
"url": "https://github.com/gatsbyjs/gatsby"
4343
}
44-
}
44+
}

integration-tests/artifacts/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"devDependencies": {
2121
"fs-extra": "^9.0.0",
22-
"jest": "^24.0.0"
22+
"jest": "^27.2.1"
2323
},
2424
"repository": {
2525
"type": "git",

integration-tests/cache-resilience/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"fs-extra": "^9.0.1",
2222
"gatsby-core-utils": "^3.0.0-next.0",
2323
"glob": "^7.1.6",
24-
"jest": "^24.0.0",
24+
"jest": "^27.2.1",
2525
"jest-serializer-path": "^0.1.15",
2626
"lodash": "^4.17.20",
2727
"slash": "^3.0.0",
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const babelPreset = require(`babel-preset-gatsby-package`)()
2-
module.exports = require(`babel-jest`).createTransformer({
3-
...babelPreset,
1+
const babelJest = require(`babel-jest`)
2+
3+
module.exports = babelJest.default.createTransformer({
4+
presets: [`babel-preset-gatsby-package`],
45
})

integration-tests/functions/package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"private": true,
55
"description": "functions",
66
"author": "Kyle Mathews",
7-
"keywords": ["gatsby"],
7+
"keywords": [
8+
"gatsby"
9+
],
810
"scripts": {
911
"build": "gatsby build",
1012
"develop": "gatsby develop",
@@ -17,16 +19,16 @@
1719
"test": "npm-run-all -s build test-prod test-dev"
1820
},
1921
"devDependencies": {
20-
"babel-jest": "^24.0.0",
21-
"babel-preset-gatsby-package": "^1.3.0",
22-
"fs-extra": "^9.0.0",
23-
"jest": "^24.0.0",
22+
"babel-jest": "^27.4.5",
23+
"babel-preset-gatsby-package": "^2.4.0",
24+
"fs-extra": "^10.0.0",
25+
"jest": "^27.2.1",
2426
"npm-run-all": "4.1.5",
2527
"start-server-and-test": "^1.11.3"
2628
},
2729
"dependencies": {
2830
"gatsby": "next",
29-
"gatsby-plugin-gatsby-cloud": "^2.5.0-next.0",
31+
"gatsby-plugin-gatsby-cloud": "next",
3032
"react": "^17.0.1",
3133
"react-dom": "^17.0.1"
3234
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const babelPreset = require(`babel-preset-gatsby-package`)()
2-
module.exports = require(`babel-jest`).createTransformer({
3-
...babelPreset,
1+
const babelJest = require(`babel-jest`)
2+
3+
module.exports = babelJest.default.createTransformer({
4+
presets: [`babel-preset-gatsby-package`],
45
})

integration-tests/gatsby-cli/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
},
77
"license": "MIT",
88
"scripts": {
9-
"test": "jest -w 1"
9+
"test": "jest --runInBand"
1010
},
1111
"devDependencies": {
12-
"babel-jest": "^24.0.0",
13-
"babel-preset-gatsby-package": "^1.3.0",
12+
"babel-jest": "^27.2.1",
13+
"babel-preset-gatsby-package": "next",
1414
"del-cli": "^3.0.1",
1515
"execa": "^4.0.1",
1616
"fs-extra": "^9.0.0",
17-
"gatsby": "^3.3.0",
18-
"gatsby-cli": "^3.3.0",
19-
"gatsby-core-utils": "^2.3.0",
20-
"jest": "^24.0.0",
17+
"gatsby": "next",
18+
"gatsby-cli": "next",
19+
"gatsby-core-utils": "next",
20+
"jest": "^27.2.1",
2121
"react": "^17.0.2",
2222
"react-dom": "^17.0.2"
2323
},
2424
"repository": {
2525
"type": "git",
2626
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
2727
}
28-
}
28+
}

integration-tests/gatsby-pipeline/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"fs-extra": "^9.0.1",
3131
"md5-file": "^5.0.0",
3232
"node-fetch": "^2.6.0",
33-
"jest": "^25.5.4",
33+
"jest": "^27.2.1",
3434
"tree-kill": "^1.2.2"
3535
},
3636
"repository": {

integration-tests/gatsby-source-wordpress/__tests__/index.js

+18-10
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ const isWarmCache = process.env.WARM_CACHE
2929
const testOnColdCacheOnly = isWarmCache ? test.skip : test
3030

3131
describe(`[gatsby-source-wordpress] Build default options`, () => {
32-
beforeAll(async done => {
33-
await urling({ url: `http://localhost:8001/graphql`, retry: 100 })
32+
beforeAll(done => {
33+
;(async () => {
34+
await urling({ url: `http://localhost:8001/graphql`, retry: 100 })
3435

35-
if (isWarmCache) {
36-
done()
37-
} else {
38-
gatsbyCleanBeforeAll(done)
39-
}
36+
if (isWarmCache) {
37+
done()
38+
} else {
39+
gatsbyCleanBeforeAll(done)
40+
}
41+
})()
4042
})
4143

4244
testOnColdCacheOnly(`Default options build succeeded`, async () => {
@@ -89,9 +91,15 @@ describe(`[gatsby-source-wordpress] Run tests on develop build`, () => {
8991
process.exit(1)
9092
}
9193

92-
gatsbyDevelopProcess = spawnGatsbyProcess(`develop`)
93-
94-
await urling(`http://localhost:8000`, { retry: 100 })
94+
return new Promise(resolve => {
95+
gatsbyDevelopProcess = spawnGatsbyProcess(`develop`)
96+
gatsbyDevelopProcess.stdout.on("data", data => {
97+
process.stdout.write(data)
98+
if (data.toString().includes("http://localhost:8000")) {
99+
resolve()
100+
}
101+
})
102+
})
95103
})
96104

97105
require(`../test-fns/index`)

integration-tests/gatsby-source-wordpress/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"devDependencies": {
2525
"cross-env": "^7.0.3",
2626
"dotenv": "^8.2.0",
27-
"jest": "^26.6.3",
27+
"jest": "^27.2.1",
2828
"node-fetch": "^2.6.1",
2929
"rimraf": "^3.0.2",
3030
"urling": "^1.0.7"

integration-tests/gatsby-source-wordpress/test-fns/test-utils/get-gatsby-process.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ exports.gatsbyCleanBeforeAll = async done => {
2424
exports.spawnGatsbyProcess = (command = `develop`, env = {}) => {
2525
const proc = spawn(
2626
process.execPath,
27-
[gatsbyBin, command, ...(command === `develop` ? ["-H", "localhost", "--port", "8000"] : [])],
27+
[
28+
gatsbyBin,
29+
command,
30+
...(command === `develop` ? ["-H", "localhost", "--port", "8000"] : []),
31+
],
2832
{
29-
stdio: [`inherit`, `inherit`, `inherit`],
33+
stdio: [`pipe`, `pipe`, `pipe`],
3034
env: {
3135
...process.env,
3236
NODE_ENV: command === `develop` ? `development` : `production`,
@@ -35,7 +39,7 @@ exports.spawnGatsbyProcess = (command = `develop`, env = {}) => {
3539
}
3640
)
3741

38-
process.on('SIGINT', proc.kill)
42+
process.on("SIGINT", proc.kill)
3943

4044
return proc
4145
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const babelPreset = require(`babel-preset-gatsby-package`)()
2-
module.exports = require(`babel-jest`).createTransformer({
3-
...babelPreset,
1+
const babelJest = require(`babel-jest`)
2+
3+
module.exports = babelJest.default.createTransformer({
4+
presets: [`babel-preset-gatsby-package`],
45
})

integration-tests/images/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"react-dom": "^16.9.0"
2020
},
2121
"devDependencies": {
22-
"babel-preset-gatsby-package": "^1.3.0",
23-
"babel-jest": "^24.0.0",
24-
"jest": "^24.0.0",
22+
"babel-preset-gatsby-package": "next",
23+
"babel-jest": "^27.2.1",
24+
"jest": "^27.2.1",
2525
"pixelmatch": "^5.2.1"
2626
}
27-
}
27+
}

integration-tests/long-term-caching/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"serve": "gatsby serve"
1010
},
1111
"dependencies": {
12-
"gatsby": "^3.0.0-next.0",
12+
"gatsby": "next",
1313
"gray-percentage": "^2.0.0",
1414
"react": "^16.9.0",
1515
"react-dom": "^16.9.0"
1616
},
1717
"devDependencies": {
1818
"babel-plugin-dynamic-import-node-sync": "^2.0.1",
19-
"jest": "^24.0.0"
19+
"jest": "^27.2.1"
2020
}
21-
}
21+
}

integration-tests/node-manifest/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"author": "Tyler Barnes <[email protected]>",
1010
"license": "ISC",
1111
"dependencies": {
12-
"gatsby": "3.6.0-next.1",
12+
"gatsby": "next",
1313
"react": "^17.0.2",
1414
"react-dom": "^17.0.2"
1515
},
1616
"devDependencies": {
1717
"fs-extra": "^10.0.0",
18-
"jest": "^26.6.3",
18+
"jest": "^27.2.1",
1919
"rimraf": "^3.0.2",
2020
"urling": "^1.0.7"
2121
}
22-
}
22+
}

integration-tests/ssr/package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
"url": "https://github.com/gatsbyjs/gatsby/issues"
88
},
99
"dependencies": {
10-
"gatsby": "^3.0.0-next.0",
11-
"gatsby-plugin-postcss": "^3.3.0",
10+
"gatsby": "next",
11+
"gatsby-plugin-postcss": "next",
1212
"react": "^16.12.0",
1313
"react-dom": "^16.12.0",
14-
"tailwindcss": "1"
14+
"tailwindcss": "^1.0.0"
1515
},
1616
"devDependencies": {
1717
"cheerio": "^1.0.0-rc.9",
18-
"cross-env": "^5.0.2",
18+
"cross-env": "^7.0.3",
1919
"execa": "^5.1.1",
20-
"fs-extra": "^9.0.0",
21-
"gatsby-core-utils": "^2.12.0",
22-
"jest": "^24.0.0",
23-
"jest-diff": "^24.0.0",
20+
"fs-extra": "^10.0.0",
21+
"gatsby-core-utils": "next",
22+
"jest": "^27.2.1",
23+
"jest-diff": "^27.2.0",
2424
"jest-serializer-path": "^0.1.15",
2525
"node-fetch": "^2.6.1",
2626
"npm-run-all": "4.1.5",
@@ -44,4 +44,4 @@
4444
"test-output": "node test-output.js",
4545
"test:jest": "jest --runInBand"
4646
}
47-
}
47+
}

integration-tests/ssr/test-output.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async function run() {
77
const { join } = require(`path`)
88
const fs = require(`fs-extra`)
99
const fetch = require(`node-fetch`)
10-
const diff = require(`jest-diff`)
10+
const { diff } = require(`jest-diff`)
1111
const prettier = require(`prettier`)
1212
const cheerio = require(`cheerio`)
1313
const stripAnsi = require(`strip-ansi`)

integration-tests/structured-logging/__tests__/ipc-send.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe(`IPC Send`, () => {
1818
})
1919
})
2020

21-
afterAll(async () => {
21+
afterAll(() => {
2222
gatsbyProcess.kill()
2323
})
2424

integration-tests/structured-logging/__tests__/logs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe(`Activities`, () => {
99
let gatsbyProcess
1010
let events = []
1111

12-
beforeAll(async done => {
12+
beforeAll(done => {
1313
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `develop`], {
1414
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
1515
env: {
@@ -34,7 +34,7 @@ describe(`Activities`, () => {
3434
})
3535
})
3636

37-
afterAll(async () => {
37+
afterAll(() => {
3838
gatsbyProcess.kill()
3939
})
4040

integration-tests/structured-logging/__tests__/status.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe(`Successful Build`, () => {
1010
let gatsbyProcess
1111
let events = []
1212

13-
beforeAll(async done => {
13+
beforeAll(done => {
1414
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `build`], {
1515
// inherit lets us see logs in console
1616
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
@@ -77,7 +77,7 @@ describe(`Failing Build`, () => {
7777
let gatsbyProcess
7878
let events = []
7979

80-
beforeAll(async done => {
80+
beforeAll(done => {
8181
fs.writeFileSync(
8282
path.join(`src`, `pages`, `index.js`),
8383
`import React from "react"

0 commit comments

Comments
 (0)