Skip to content

Commit

Permalink
chore: upgrade jest (#33277)
Browse files Browse the repository at this point in the history
Co-authored-by: LekoArts <lekoarts@gmail.com>
Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>
  • Loading branch information
3 people committed Dec 19, 2021
1 parent ae2ffe8 commit 34cb202
Show file tree
Hide file tree
Showing 79 changed files with 2,144 additions and 2,983 deletions.
2 changes: 1 addition & 1 deletion .github/actions/high-priority-prs/package.json
Expand Up @@ -14,6 +14,6 @@
"lodash": "^4.17.15"
},
"devDependencies": {
"jest": "^25.1.0"
"jest": "^27.2.1"
}
}
3 changes: 3 additions & 0 deletions .jestSetup.js
@@ -1 +1,4 @@
process.env.GATSBY_RECIPES_NO_COLOR = "true"

// Potrace has a dependency on giwrap which has a process.nextTick as a sideEffect which messes up with jest.
jest.mock(`gifwrap`, () => jest.fn())
2 changes: 1 addition & 1 deletion deprecated-packages/gatsby-recipes/package.json
Expand Up @@ -41,7 +41,7 @@
"hicat": "^0.8.0",
"is-binary-path": "^2.1.0",
"is-url": "^1.2.4",
"jest-diff": "^25.5.0",
"jest-diff": "^27.2.0",
"lock": "^1.0.0",
"lodash": "^4.17.21",
"mitt": "^1.2.0",
Expand Down
@@ -1,4 +1,4 @@
import diff from "jest-diff"
import { diff } from "jest-diff"
import chalk from "chalk"
import stripAnsi from "strip-ansi"

Expand Down
4 changes: 2 additions & 2 deletions examples/using-jest/package.json
Expand Up @@ -35,10 +35,10 @@
"babel-jest": "^24.9.0",
"babel-preset-gatsby": "^0.5.10",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.9.0"
"jest": "^27.2.1"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby"
}
}
}
2 changes: 1 addition & 1 deletion integration-tests/artifacts/package.json
Expand Up @@ -19,7 +19,7 @@
},
"devDependencies": {
"fs-extra": "^9.0.0",
"jest": "^24.0.0"
"jest": "^27.2.1"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/cache-resilience/package.json
Expand Up @@ -21,7 +21,7 @@
"fs-extra": "^9.0.1",
"gatsby-core-utils": "^3.0.0-next.0",
"glob": "^7.1.6",
"jest": "^24.0.0",
"jest": "^27.2.1",
"jest-serializer-path": "^0.1.15",
"lodash": "^4.17.20",
"slash": "^3.0.0",
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/functions/jest-transformer.js
@@ -1,4 +1,5 @@
const babelPreset = require(`babel-preset-gatsby-package`)()
module.exports = require(`babel-jest`).createTransformer({
...babelPreset,
const babelJest = require(`babel-jest`)

module.exports = babelJest.default.createTransformer({
presets: [`babel-preset-gatsby-package`],
})
14 changes: 8 additions & 6 deletions integration-tests/functions/package.json
Expand Up @@ -4,7 +4,9 @@
"private": true,
"description": "functions",
"author": "Kyle Mathews",
"keywords": ["gatsby"],
"keywords": [
"gatsby"
],
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
Expand All @@ -17,16 +19,16 @@
"test": "npm-run-all -s build test-prod test-dev"
},
"devDependencies": {
"babel-jest": "^24.0.0",
"babel-preset-gatsby-package": "^1.3.0",
"fs-extra": "^9.0.0",
"jest": "^24.0.0",
"babel-jest": "^27.4.5",
"babel-preset-gatsby-package": "^2.4.0",
"fs-extra": "^10.0.0",
"jest": "^27.2.1",
"npm-run-all": "4.1.5",
"start-server-and-test": "^1.11.3"
},
"dependencies": {
"gatsby": "next",
"gatsby-plugin-gatsby-cloud": "^2.5.0-next.0",
"gatsby-plugin-gatsby-cloud": "next",
"react": "^17.0.1",
"react-dom": "^17.0.1"
}
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/gatsby-cli/jest-transformer.js
@@ -1,4 +1,5 @@
const babelPreset = require(`babel-preset-gatsby-package`)()
module.exports = require(`babel-jest`).createTransformer({
...babelPreset,
const babelJest = require(`babel-jest`)

module.exports = babelJest.default.createTransformer({
presets: [`babel-preset-gatsby-package`],
})
16 changes: 8 additions & 8 deletions integration-tests/gatsby-cli/package.json
Expand Up @@ -6,23 +6,23 @@
},
"license": "MIT",
"scripts": {
"test": "jest -w 1"
"test": "jest --runInBand"
},
"devDependencies": {
"babel-jest": "^24.0.0",
"babel-preset-gatsby-package": "^1.3.0",
"babel-jest": "^27.2.1",
"babel-preset-gatsby-package": "next",
"del-cli": "^3.0.1",
"execa": "^4.0.1",
"fs-extra": "^9.0.0",
"gatsby": "^3.3.0",
"gatsby-cli": "^3.3.0",
"gatsby-core-utils": "^2.3.0",
"jest": "^24.0.0",
"gatsby": "next",
"gatsby-cli": "next",
"gatsby-core-utils": "next",
"jest": "^27.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
}
}
}
2 changes: 1 addition & 1 deletion integration-tests/gatsby-pipeline/package.json
Expand Up @@ -30,7 +30,7 @@
"fs-extra": "^9.0.1",
"md5-file": "^5.0.0",
"node-fetch": "^2.6.0",
"jest": "^25.5.4",
"jest": "^27.2.1",
"tree-kill": "^1.2.2"
},
"repository": {
Expand Down
28 changes: 18 additions & 10 deletions integration-tests/gatsby-source-wordpress/__tests__/index.js
Expand Up @@ -29,14 +29,16 @@ const isWarmCache = process.env.WARM_CACHE
const testOnColdCacheOnly = isWarmCache ? test.skip : test

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

if (isWarmCache) {
done()
} else {
gatsbyCleanBeforeAll(done)
}
if (isWarmCache) {
done()
} else {
gatsbyCleanBeforeAll(done)
}
})()
})

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

gatsbyDevelopProcess = spawnGatsbyProcess(`develop`)

await urling(`http://localhost:8000`, { retry: 100 })
return new Promise(resolve => {
gatsbyDevelopProcess = spawnGatsbyProcess(`develop`)
gatsbyDevelopProcess.stdout.on("data", data => {
process.stdout.write(data)
if (data.toString().includes("http://localhost:8000")) {
resolve()
}
})
})
})

require(`../test-fns/index`)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/gatsby-source-wordpress/package.json
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"jest": "^26.6.3",
"jest": "^27.2.1",
"node-fetch": "^2.6.1",
"rimraf": "^3.0.2",
"urling": "^1.0.7"
Expand Down
Expand Up @@ -24,9 +24,13 @@ exports.gatsbyCleanBeforeAll = async done => {
exports.spawnGatsbyProcess = (command = `develop`, env = {}) => {
const proc = spawn(
process.execPath,
[gatsbyBin, command, ...(command === `develop` ? ["-H", "localhost", "--port", "8000"] : [])],
[
gatsbyBin,
command,
...(command === `develop` ? ["-H", "localhost", "--port", "8000"] : []),
],
{
stdio: [`inherit`, `inherit`, `inherit`],
stdio: [`pipe`, `pipe`, `pipe`],
env: {
...process.env,
NODE_ENV: command === `develop` ? `development` : `production`,
Expand All @@ -35,7 +39,7 @@ exports.spawnGatsbyProcess = (command = `develop`, env = {}) => {
}
)

process.on('SIGINT', proc.kill)
process.on("SIGINT", proc.kill)

return proc
}
7 changes: 4 additions & 3 deletions integration-tests/images/jest-transformer.js
@@ -1,4 +1,5 @@
const babelPreset = require(`babel-preset-gatsby-package`)()
module.exports = require(`babel-jest`).createTransformer({
...babelPreset,
const babelJest = require(`babel-jest`)

module.exports = babelJest.default.createTransformer({
presets: [`babel-preset-gatsby-package`],
})
8 changes: 4 additions & 4 deletions integration-tests/images/package.json
Expand Up @@ -19,9 +19,9 @@
"react-dom": "^16.9.0"
},
"devDependencies": {
"babel-preset-gatsby-package": "^1.3.0",
"babel-jest": "^24.0.0",
"jest": "^24.0.0",
"babel-preset-gatsby-package": "next",
"babel-jest": "^27.2.1",
"jest": "^27.2.1",
"pixelmatch": "^5.2.1"
}
}
}
6 changes: 3 additions & 3 deletions integration-tests/long-term-caching/package.json
Expand Up @@ -9,13 +9,13 @@
"serve": "gatsby serve"
},
"dependencies": {
"gatsby": "^3.0.0-next.0",
"gatsby": "next",
"gray-percentage": "^2.0.0",
"react": "^16.9.0",
"react-dom": "^16.9.0"
},
"devDependencies": {
"babel-plugin-dynamic-import-node-sync": "^2.0.1",
"jest": "^24.0.0"
"jest": "^27.2.1"
}
}
}
6 changes: 3 additions & 3 deletions integration-tests/node-manifest/package.json
Expand Up @@ -9,14 +9,14 @@
"author": "Tyler Barnes <tyler@gatsbyjs.com>",
"license": "ISC",
"dependencies": {
"gatsby": "3.6.0-next.1",
"gatsby": "next",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"fs-extra": "^10.0.0",
"jest": "^26.6.3",
"jest": "^27.2.1",
"rimraf": "^3.0.2",
"urling": "^1.0.7"
}
}
}
18 changes: 9 additions & 9 deletions integration-tests/ssr/package.json
Expand Up @@ -7,20 +7,20 @@
"url": "https://github.com/gatsbyjs/gatsby/issues"
},
"dependencies": {
"gatsby": "^3.0.0-next.0",
"gatsby-plugin-postcss": "^3.3.0",
"gatsby": "next",
"gatsby-plugin-postcss": "next",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"tailwindcss": "1"
"tailwindcss": "^1.0.0"
},
"devDependencies": {
"cheerio": "^1.0.0-rc.9",
"cross-env": "^5.0.2",
"cross-env": "^7.0.3",
"execa": "^5.1.1",
"fs-extra": "^9.0.0",
"gatsby-core-utils": "^2.12.0",
"jest": "^24.0.0",
"jest-diff": "^24.0.0",
"fs-extra": "^10.0.0",
"gatsby-core-utils": "next",
"jest": "^27.2.1",
"jest-diff": "^27.2.0",
"jest-serializer-path": "^0.1.15",
"node-fetch": "^2.6.1",
"npm-run-all": "4.1.5",
Expand All @@ -44,4 +44,4 @@
"test-output": "node test-output.js",
"test:jest": "jest --runInBand"
}
}
}
2 changes: 1 addition & 1 deletion integration-tests/ssr/test-output.js
Expand Up @@ -7,7 +7,7 @@ async function run() {
const { join } = require(`path`)
const fs = require(`fs-extra`)
const fetch = require(`node-fetch`)
const diff = require(`jest-diff`)
const { diff } = require(`jest-diff`)
const prettier = require(`prettier`)
const cheerio = require(`cheerio`)
const stripAnsi = require(`strip-ansi`)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/structured-logging/__tests__/ipc-send.js
Expand Up @@ -18,7 +18,7 @@ describe(`IPC Send`, () => {
})
})

afterAll(async () => {
afterAll(() => {
gatsbyProcess.kill()
})

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/structured-logging/__tests__/logs.js
Expand Up @@ -9,7 +9,7 @@ describe(`Activities`, () => {
let gatsbyProcess
let events = []

beforeAll(async done => {
beforeAll(done => {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `develop`], {
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
env: {
Expand All @@ -34,7 +34,7 @@ describe(`Activities`, () => {
})
})

afterAll(async () => {
afterAll(() => {
gatsbyProcess.kill()
})

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/structured-logging/__tests__/status.js
Expand Up @@ -10,7 +10,7 @@ describe(`Successful Build`, () => {
let gatsbyProcess
let events = []

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

beforeAll(async done => {
beforeAll(done => {
fs.writeFileSync(
path.join(`src`, `pages`, `index.js`),
`import React from "react"
Expand Down

0 comments on commit 34cb202

Please sign in to comment.