Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: adjust tests after the bump #33171

Merged
merged 21 commits into from
Sep 14, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ aliases:
yarn why lmdb-store
- run:
name: Run tests
command: yarn jest --ci --runInBand $(yarn jest --listTests | sed 's/\/root\/project//g' | circleci tests split --split-by=timings)
command: yarn jest --ci --runInBand $(yarn -s jest --listTests | sed 's/\/home\/circleci\/project\///g' | circleci tests split)
environment:
NODE_OPTIONS: --max-old-space-size=2048
GENERATE_JEST_REPORT: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ Array [
"availableFlags": Array [
"GATSBY_MAJOR",
],
"flags": Object {},
"flags": Object {
"GATSBY_MAJOR": "4",
},
},
],
]
Expand All @@ -109,7 +111,9 @@ Array [
"availableFlags": Array [
"MAJOR",
],
"flags": Object {},
"flags": Object {
"GATSBY_MAJOR": "4",
},
},
],
]
Expand Down Expand Up @@ -176,7 +180,9 @@ Array [
"availableFlags": Array [
"GATSBY_MAJOR",
],
"flags": Object {},
"flags": Object {
"GATSBY_MAJOR": "4",
},
},
],
]
Expand Down
3 changes: 2 additions & 1 deletion packages/babel-preset-gatsby-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"@babel/core": "^7.15.5",
"@babel/helper-plugin-test-runner": "7.14.5",
"@babel/plugin-transform-modules-commonjs": "^7.15.4",
"@types/babel__core": "^7.1.15"
"@types/babel__core": "^7.1.15",
"cross-env": "^7.0.3"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cross-env used in prepare script, but not declared in devDeps

},
"peerDependencies": {
"@babel/core": "^7.11.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (os.platform() === `win32`) {
// Check if update is available
updateNotifier({ pkg }).notify({ isGlobal: true })

const MIN_NODE_VERSION = `12.13.0`
const MIN_NODE_VERSION = `14.15.0`
// const NEXT_MIN_NODE_VERSION = `10.13.0`

const { version } = process
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-mdx/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ describe(`pluginOptionsSchema`, () => {
`"extensions[1]" must be a string`,
`"extensions[2]" must be a string`,
`"defaultLayouts" must be of type object`,
`"gatsbyRemarkPlugins[0]" does not match any of the allowed types`,
`"gatsbyRemarkPlugins[1]" does not match any of the allowed types`,
`"gatsbyRemarkPlugins[0]" must be one of [string, object]`,
`"gatsbyRemarkPlugins[1].not" is not allowed`,
`"remarkPlugins" must be an array`,
`"rehypePlugins" must be an array`,
`"plugins[0]" does not match any of the allowed types`,
Expand Down
6 changes: 5 additions & 1 deletion packages/gatsby-plugin-mdx/utils/__tests__/gen-mdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ console.log('hello world')

describe(`find imports`, () => {
it(`allows injecting imports via plugins`, async () => {
const testPluginModulePath = path.join(__dirname, `fixtures`, `test-plugin`)
const results = await findImports({
node: {
id: `bbffffbb-bfff-bfff-bfff-dededededede`,
Expand All @@ -37,7 +38,10 @@ describe(`find imports`, () => {
options: {
remarkPlugins: [],
gatsbyRemarkPlugins: [
{ resolve: path.join(__dirname, `fixtures`, `test-plugin`) },
{
resolve: testPluginModulePath,
module: require(testPluginModulePath),
},
],
},
getNode: () => null,
Expand Down
30 changes: 29 additions & 1 deletion packages/gatsby-plugin-utils/src/test-plugin-options-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,35 @@ export async function testPluginOptionsSchema(
pluginSchemaFunction: Exclude<GatsbyNode["pluginOptionsSchema"], undefined>,
pluginOptions: IPluginInfoOptions
): Promise<ITestPluginOptionsSchemaReturnType> {
const pluginSchema = pluginSchemaFunction({ Joi })
const pluginSchema = pluginSchemaFunction({
Joi: Joi.extend(joi => {
return {
base: joi.any(),
type: `subPlugins`,
args: (): any =>
joi
.array()
.items(
joi
.alternatives(
joi.string(),
joi.object({
resolve: Joi.string(),
options: Joi.object({}).unknown(true),
})
)
.custom(value => {
if (typeof value === `string`) {
value = { resolve: value }
}

return value
}, `Gatsby specific subplugin validation`)
)
.default([]),
}
}),
})
Comment on lines -15 to +43
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test helper wasn't aware of .subPlugins so this adds smaller stub that pretty much just checks for valid structure


try {
await validateOptionsSchema(pluginSchema, pluginOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ It's easier than you may imagine`,
showLineNumbers: false,
noInlineHighlight: false,
},
module: require(`gatsby-remark-prismjs`),
},
],
},
Expand Down Expand Up @@ -1335,6 +1336,7 @@ describe(`Headings are generated correctly from schema`, () => {
{
resolve: require.resolve(`gatsby-remark-autolink-headers/src`),
pluginOptions: {},
module: require(`gatsby-remark-autolink-headers/src`),
},
],
},
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby/scripts/__tests__/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ it("generates the expected api output", done => {
"onCreateNode": Object {},
"onCreatePage": Object {},
"onCreateWebpackConfig": Object {},
"onPluginInit": Object {
"version": "3.9.0",
},
"onPostBootstrap": Object {},
"onPostBuild": Object {},
"onPreBootstrap": Object {},
Expand All @@ -57,9 +60,6 @@ it("generates the expected api output", done => {
"resolvableExtensions": Object {},
"setFieldsOnGraphQLNodeType": Object {},
"sourceNodes": Object {},
"onPluginInit": Object {
"version": "3.9.0",
},
"unstable_shouldOnCreateNode": Object {
"version": "2.24.80",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { store } from "../../redux"
import { actions } from "../../redux/actions"

jest.mock(`fs-extra`, () => {
return { writeFile: jest.fn() }
return { writeFile: jest.fn(), readFileSync: jest.fn(() => `foo`) }
})

jest.mock(`gatsby-cli/lib/reporter`, () => {
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/bootstrap/__tests__/requires-writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const generatePagesState = pages => {
state.set(page.path, {
component: ``,
componentChunkName: ``,
mode: `SSG`,
...page,
})
})
Expand Down