Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
259 changes: 197 additions & 62 deletions .circleci/config.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,17 @@ Object {

exports[`develop response formats returns json correctly 2`] = `
Object {
"access-control-allow-origin": "*",
"connection": "close",
"content-length": "16",
"content-type": "application/json; charset=utf-8",
"etag": "W/\\"10-R6td1pV+B+Xz9CJkNeaEI2kP+QY\\"",
"vary": "Accept-Encoding",
"x-powered-by": "Express",
}
`;

exports[`develop response formats returns text correctly 1`] = `"I am typescript"`;

exports[`develop response formats returns text correctly 2`] = `
Object {
"access-control-allow-origin": "*",
"connection": "close",
"content-length": "15",
"content-type": "text/html; charset=utf-8",
"etag": "W/\\"f-zwggT56l/fnWBm4dI0PkA4E3i4E\\"",
"vary": "Accept-Encoding",
"x-powered-by": "Express",
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,17 @@ Object {

exports[`production response formats returns json correctly 2`] = `
Object {
"connection": "close",
"content-length": "16",
"content-type": "application/json; charset=utf-8",
"etag": "W/\\"10-R6td1pV+B+Xz9CJkNeaEI2kP+QY\\"",
"x-powered-by": "Express",
}
`;

exports[`production response formats returns text correctly 1`] = `"I am typescript"`;

exports[`production response formats returns text correctly 2`] = `
Object {
"connection": "close",
"content-length": "15",
"content-type": "text/html; charset=utf-8",
"etag": "W/\\"f-zwggT56l/fnWBm4dI0PkA4E3i4E\\"",
"x-powered-by": "Express",
}
`;

Expand Down
14 changes: 10 additions & 4 deletions integration-tests/functions/test-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,23 @@ export function runTests(env, host) {
const res = await fetchWithRetry(`${host}/api/i-am-json`)
const result = await res.json()

const { date, ...headers } = Object.fromEntries(res.headers)
const relevantHeaders = {
'content-type': res.headers.get('content-type'),
'content-length': res.headers.get('content-length')
}
expect(result).toMatchSnapshot()
expect(headers).toMatchSnapshot()
expect(relevantHeaders).toMatchSnapshot()
})
test(`returns text correctly`, async () => {
const res = await fetchWithRetry(`${host}/api/i-am-typescript`)
const result = await res.text()

const { date, ...headers } = Object.fromEntries(res.headers)
const relevantHeaders = {
'content-type': res.headers.get('content-type'),
'content-length': res.headers.get('content-length')
}
expect(result).toMatchSnapshot()
expect(headers).toMatchSnapshot()
expect(relevantHeaders).toMatchSnapshot()
})
})

Expand Down
1 change: 0 additions & 1 deletion integration-tests/lmdb-regeneration/.npmrc

This file was deleted.

1 change: 1 addition & 0 deletions integration-tests/lmdb-regeneration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"build": "gatsby build",
"clean": "gatsby clean",
"postinstall": "npm rebuild --build-from-source lmdb",
"test": "jest --runInBand"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/ssr/__tests__/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe(`SSR`, () => {
it(
title,
async () => {
const src = path.join(__dirname, `/fixtures/`, fixture)
const src = path.join(__dirname, `fixtures`, fixture)
const dest = getSrcLoc(fixture)
fs.copySync(src, dest)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Object {
},
"docsUrl": "https://gatsby.dev/issue-how-to",
"level": "ERROR",
"stack": Array [],
"stack": Any<Array>,
"text": "Error created in Jest",
"type": "UNKNOWN",
}
Expand Down Expand Up @@ -69,80 +69,7 @@ Object {
"error": [Error: Message from new Error],
"level": "ERROR",
"pluginName": "gatsby-plugin-foo-bar",
"stack": Array [
Object {
"columnNumber": 7,
"fileName": "<PROJECT_ROOT>/packages/gatsby-cli/src/reporter/__tests__/index.ts",
"functionName": null,
"lineNumber": 100,
},
Object {
"columnNumber": 28,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/utils.js",
"functionName": "Promise.then.completed",
"lineNumber": 293,
},
Object {
"columnNumber": 10,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/utils.js",
"functionName": "callAsyncCircusFn",
"lineNumber": 226,
},
Object {
"columnNumber": 40,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/run.js",
"functionName": "_callCircusTest",
"lineNumber": 297,
},
Object {
"columnNumber": 3,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/run.js",
"functionName": "_runTest",
"lineNumber": 233,
},
Object {
"columnNumber": 9,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/run.js",
"functionName": "_runTestsForDescribeBlock",
"lineNumber": 135,
},
Object {
"columnNumber": 9,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/run.js",
"functionName": "_runTestsForDescribeBlock",
"lineNumber": 130,
},
Object {
"columnNumber": 3,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/run.js",
"functionName": "run",
"lineNumber": 68,
},
Object {
"columnNumber": 21,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js",
"functionName": "runAndTransformResultsToJestFormat",
"lineNumber": 122,
},
Object {
"columnNumber": 19,
"fileName": "<PROJECT_ROOT>/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js",
"functionName": "jestAdapter",
"lineNumber": 79,
},
Object {
"columnNumber": 16,
"fileName": "<PROJECT_ROOT>/node_modules/jest-runner/build/runTest.js",
"functionName": "runTestInternal",
"lineNumber": 367,
},
Object {
"columnNumber": 34,
"fileName": "<PROJECT_ROOT>/node_modules/jest-runner/build/runTest.js",
"functionName": "runTest",
"lineNumber": 444,
},
],
"stack": Any<Array>,
"text": "Error string passed to reporter Message from new Error",
"type": "UNKNOWN",
}
Expand All @@ -157,7 +84,7 @@ Object {
},
"docsUrl": "https://gatsby.dev/debug-html",
"level": "ERROR",
"stack": Array [],
"stack": Any<Array>,
"text": "\\"navigator\\" is not available during server-side rendering. Enable \\"DEV_SSR\\" to debug this during \\"gatsby develop\\".",
"type": "HTML.COMPILATION",
}
Expand All @@ -171,7 +98,7 @@ Object {
},
"docsUrl": "https://www.gatsbyjs.com/docs/gatsby-cli/#new",
"level": "ERROR",
"stack": Array [],
"stack": Any<Array>,
"text": "Error text is test123",
"type": "PLUGIN",
}
Expand All @@ -186,7 +113,7 @@ Object {
"docsUrl": "https://www.gatsbyjs.com/docs/gatsby-cli/#new",
"level": "ERROR",
"pluginName": "gatsby-plugin-foo-bar",
"stack": Array [],
"stack": Any<Array>,
"text": "Error text is test123",
"type": "PLUGIN",
}
Expand Down
20 changes: 15 additions & 5 deletions packages/gatsby-cli/src/reporter/__tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ describe(`report.error`, () => {
const generatedError = getErrorMessages(
reporterActions.createLog as jest.Mock
)[0]
expect(generatedError).toMatchSnapshot()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these snapshots contained full stack traces down to the node.js level which weren't stable across node.js versions. it didn't seem like that was material to the tests, so we just simplified this.

expect(generatedError).toMatchSnapshot({
stack: expect.any(Array),
})
})

it(`handles "String" signature correctly`, () => {
reporter.error(`Error created in Jest`)
const generatedError = getErrorMessages(
reporterActions.createLog as jest.Mock
)[0]
expect(generatedError).toMatchSnapshot()
expect(generatedError).toMatchSnapshot({
stack: expect.any(Array),
})
})

it(`handles "String, Error, pluginName" signature correctly`, () => {
Expand All @@ -103,7 +107,9 @@ describe(`report.error`, () => {
const generatedError = getErrorMessages(
reporterActions.createLog as jest.Mock
)[0]
expect(generatedError).toMatchSnapshot()
expect(generatedError).toMatchSnapshot({
stack: expect.any(Array),
})
})

it(`sets an error map if setErrorMap is called`, () => {
Expand Down Expand Up @@ -136,7 +142,9 @@ describe(`report.error`, () => {
const generatedError = getErrorMessages(
reporterActions.createLog as jest.Mock
)[0]
expect(generatedError).toMatchSnapshot()
expect(generatedError).toMatchSnapshot({
stack: expect.any(Array),
})
})

// This is how it's potentially called from api-runner-node.js
Expand All @@ -163,6 +171,8 @@ describe(`report.error`, () => {
const generatedError = getErrorMessages(
reporterActions.createLog as jest.Mock
)[0]
expect(generatedError).toMatchSnapshot()
expect(generatedError).toMatchSnapshot({
stack: expect.any(Array),
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import _ from "lodash"
import { resolve } from "path"
import { setFieldsOnGraphQLNodeType } from "../extend-node-type"
import { generateImageSource } from "../gatsby-plugin-image"
import * as gatsbyCoreUtils from "gatsby-core-utils"
import * as fetchRemoteFileModule from "gatsby-core-utils/fetch-remote-file"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matching how it's imported in the source module we're testing. this mismatch stopped working in node 20.

import * as pluginSharp from "gatsby-plugin-sharp"

const FIXTURES = resolve(__dirname, `..`, `__fixtures__`)
Expand All @@ -20,7 +20,7 @@ jest
.spyOn(pluginSharp, `getDominantColor`)
.mockImplementation(() => Promise.resolve(`#mocked`))
jest
.spyOn(gatsbyCoreUtils, `fetchRemoteFile`)
.spyOn(fetchRemoteFileModule, `fetchRemoteFile`)
.mockImplementation(() =>
Promise.resolve(`${FIXTURES}/contentful-logo-256.png`)
)
Expand Down
14 changes: 12 additions & 2 deletions packages/gatsby/cache-dir/__tests__/minimal-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ it(`Builds cache-dir with minimal config`, done => {
})

spawn.on(`close`, function () {
expect(stderr).toEqual(``)
expect(stdout).not.toEqual(``)
try {
// This is a little weird but this node.js deprecation warning is printed on node 22+ BUT we
// fully suppress all node.js warnings in CI for some reason. This pattern allows either
// nothing or just this warning to be printed to stderr, allowing it to pass locally and in CI.
expect(stderr).toMatch(
/^(|\(node:\d+\) \[DEP0180\] DeprecationWarning: fs\.Stats constructor is deprecated\.\s+\(Use `node --trace-deprecation \.\.\.` to show where the warning was created\)[\s\n]*)$/s
)
expect(stdout).not.toEqual(``)
} catch (err) {
done(err)
return
}
done()
})
}, 30000)
3 changes: 1 addition & 2 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"webpack-dev-middleware": "^5.3.4",
"webpack-merge": "^5.9.0",
"webpack-stats-plugin": "^1.1.3",
"webpack-virtual-modules": "^0.5.0",
"webpack-virtual-modules": "^0.6.2",
"xstate": "^4.38.0",
"yaml-loader": "^0.8.0"
},
Expand All @@ -196,7 +196,6 @@
"@types/signal-exit": "^3.0.1",
"@types/string-similarity": "^4.0.0",
"@types/tmp": "^0.2.3",
"@types/webpack-virtual-modules": "^0.1.1",
"babel-preset-gatsby-package": "^3.15.0-next.0",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
Expand Down
Loading
Loading