Skip to content

Commit ffabe75

Browse files
authored
fix: Enable CLI integration tests (#25997)
1 parent e3203c6 commit ffabe75

File tree

18 files changed

+27
-12
lines changed

18 files changed

+27
-12
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ jobs:
267267
executor: node
268268
steps:
269269
- e2e-test:
270-
test_path: integration-tests/gatsby-pipeline
270+
test_path: integration-tests/gatsby-cli
271271
trigger_pattern: packages/gatsby-cli/*|packages/gatsby/*|integration-tests/gatsby-cli/*
272272

273273
integration_tests_structured_logging:

integration-tests/gatsby-cli/__tests__/build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe(`gatsby build`, () => {
3636
logs.should.contain(
3737
`success Building production JavaScript and CSS bundles`
3838
)
39-
logs.should.contain(`success run queries`)
39+
logs.should.contain(`success run page queries`)
4040
logs.should.contain(`success Building static HTML for pages`)
4141
logs.should.contain(`success onPostBuild`)
4242
logs.should.contain(`info Done building`)

integration-tests/gatsby-cli/__tests__/develop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe(`gatsby develop`, () => {
1818
// 1. Start the `gatsby develop` command
1919
const [childProcess, getLogs] = GatsbyCLI.from(cwd).invokeAsync(
2020
`develop`,
21-
log => log.includes("To create a production build, use gatsby build")
21+
log => log.includes(`Building development bundle`)
2222
)
2323

2424
// 2. kill the `gatsby develop` command so we can get logs

integration-tests/gatsby-cli/__tests__/recipes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe(`gatsby recipes`, () => {
99
beforeAll(() => GatsbyCLI.from(cwd).invoke(`clean`))
1010
afterAll(() => GatsbyCLI.from(cwd).invoke(`clean`))
1111

12-
it(`begins running the jest recipe`, async () => {
12+
xit(`begins running the jest recipe`, async () => {
1313
// 1. Start the `gatsby recipes` command
1414
const [childProcess, getLogs] = GatsbyCLI.from(cwd).invokeAsync(
1515
[`recipes`, `jest`],

integration-tests/gatsby-cli/__tests__/repl.js

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ describe(`gatsby repl`, () => {
3535
logs.should.contain(`success onPreExtractQueries`)
3636
logs.should.contain(`success update schema`)
3737
logs.should.contain(`success extract queries from components`)
38-
logs.should.contain(`success write out requires`)
3938
logs.should.contain(`success write out redirect data`)
4039
logs.should.contain(`success onPostBootstrap`)
4140
logs.should.contain(`info bootstrap finished`)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Disable eslint-loader

integration-tests/gatsby-cli/gatsby-sites/gatsby-build-errors/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "gatsby-starter-default",
2+
"name": "gatsby-starter-default-build-errors",
33
"private": true,
44
"description": "A simple starter to get up and developing quickly with Gatsby",
55
"version": "0.1.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Disable eslint-loader

integration-tests/gatsby-cli/gatsby-sites/gatsby-build-ssr-errors/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "gatsby-starter-default",
2+
"name": "gatsby-starter-default-build-ssr-errors",
33
"private": true,
44
"description": "A simple starter to get up and developing quickly with Gatsby",
55
"version": "0.1.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Disable eslint-loader

integration-tests/gatsby-cli/gatsby-sites/gatsby-build/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "gatsby-starter-default",
2+
"name": "gatsby-starter-default-build",
33
"private": true,
44
"description": "A simple starter to get up and developing quickly with Gatsby",
55
"version": "0.1.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Disable eslint-loader

integration-tests/gatsby-cli/gatsby-sites/gatsby-develop/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "gatsby-starter-default",
2+
"name": "gatsby-starter-default-develop",
33
"private": true,
44
"description": "A simple starter to get up and developing quickly with Gatsby",
55
"version": "0.1.0",

integration-tests/gatsby-cli/gatsby-sites/gatsby-repl/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "gatsby-starter-default",
2+
"name": "gatsby-starter-default-repl",
33
"private": true,
44
"description": "A simple starter to get up and developing quickly with Gatsby",
55
"version": "0.1.0",

integration-tests/gatsby-cli/test-helpers/invoke-cli.js

+4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export const GatsbyCLI = {
77
from(relativeCwd) {
88
return {
99
invoke(args) {
10+
const NODE_ENV = args[0] === `develop` ? `development` : `production`
1011
try {
1112
const results = sync(
1213
resolve(`./node_modules/.bin/gatsby`),
1314
[].concat(args),
1415
{
1516
cwd: join(__dirname, `../`, `./${relativeCwd}`),
17+
env: { NODE_ENV, CI: 1, GATSBY_LOGGER: `ink` },
1618
}
1719
)
1820

@@ -29,11 +31,13 @@ export const GatsbyCLI = {
2931
},
3032

3133
invokeAsync: (args, onExit) => {
34+
const NODE_ENV = args[0] === `develop` ? `development` : `production`
3235
const res = execa(
3336
resolve(`./node_modules/.bin/gatsby`),
3437
[].concat(args),
3538
{
3639
cwd: join(__dirname, `../`, `./${relativeCwd}`),
40+
env: { NODE_ENV, CI: 1, GATSBY_LOGGER: `ink` },
3741
}
3842
)
3943

packages/gatsby/src/services/rebuild-schema-with-site-pages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IQueryRunningContext } from "../state-machines/query-running/types"
55
export async function rebuildSchemaWithSitePage({
66
parentSpan,
77
}: Partial<IQueryRunningContext>): Promise<void> {
8-
const activity = reporter.activityTimer(`updating schema`, {
8+
const activity = reporter.activityTimer(`update schema`, {
99
parentSpan,
1010
})
1111
activity.start()

packages/gatsby/src/state-machines/develop/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,16 @@ const developConfig: MachineConfig<IBuildContext, any, AnyEventObject> = {
7575
`clearWebhookBody`,
7676
`finishParentSpan`,
7777
],
78-
target: `runningQueries`,
78+
target: `runningPostBootstrap`,
7979
},
8080
},
8181
},
82+
runningPostBootstrap: {
83+
invoke: {
84+
src: `postBootstrap`,
85+
onDone: `runningQueries`,
86+
},
87+
},
8288
// Running page and static queries and generating the SSRed HTML and page data
8389
runningQueries: {
8490
on: {

packages/gatsby/src/state-machines/develop/services.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
startWebpackServer,
44
initialize,
55
recompile,
6+
postBootstrap,
67
} from "../../services"
78
import {
89
initializeDataMachine,
@@ -22,4 +23,5 @@ export const developServices: Record<string, ServiceConfig<IBuildContext>> = {
2223
waitForMutations: waitingMachine,
2324
startWebpackServer,
2425
recompile,
26+
postBootstrap,
2527
}

0 commit comments

Comments
 (0)