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

fix: Enable CLI integration tests #25997

Merged
merged 9 commits into from
Jul 24, 2020
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ jobs:
executor: node
steps:
- e2e-test:
test_path: integration-tests/gatsby-pipeline
test_path: integration-tests/gatsby-cli
trigger_pattern: packages/gatsby-cli/*|packages/gatsby/*|integration-tests/gatsby-cli/*

integration_tests_structured_logging:
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/gatsby-cli/__tests__/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe(`gatsby build`, () => {
logs.should.contain(
`success Building production JavaScript and CSS bundles`
)
logs.should.contain(`success run queries`)
logs.should.contain(`success run page queries`)
logs.should.contain(`success Building static HTML for pages`)
logs.should.contain(`success onPostBuild`)
logs.should.contain(`info Done building`)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/gatsby-cli/__tests__/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe(`gatsby develop`, () => {
// 1. Start the `gatsby develop` command
const [childProcess, getLogs] = GatsbyCLI.from(cwd).invokeAsync(
`develop`,
log => log.includes("To create a production build, use gatsby build")
log => log.includes(`Building development bundle`)
)

// 2. kill the `gatsby develop` command so we can get logs
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/gatsby-cli/__tests__/recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe(`gatsby recipes`, () => {
beforeAll(() => GatsbyCLI.from(cwd).invoke(`clean`))
afterAll(() => GatsbyCLI.from(cwd).invoke(`clean`))

it(`begins running the jest recipe`, async () => {
xit(`begins running the jest recipe`, async () => {
// 1. Start the `gatsby recipes` command
const [childProcess, getLogs] = GatsbyCLI.from(cwd).invokeAsync(
[`recipes`, `jest`],
Expand Down
1 change: 0 additions & 1 deletion integration-tests/gatsby-cli/__tests__/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe(`gatsby repl`, () => {
logs.should.contain(`success onPreExtractQueries`)
logs.should.contain(`success update schema`)
logs.should.contain(`success extract queries from components`)
logs.should.contain(`success write out requires`)
logs.should.contain(`success write out redirect data`)
logs.should.contain(`success onPostBootstrap`)
logs.should.contain(`info bootstrap finished`)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Disable eslint-loader
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gatsby-starter-default",
"name": "gatsby-starter-default-build-errors",
"private": true,
"description": "A simple starter to get up and developing quickly with Gatsby",
"version": "0.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Disable eslint-loader
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gatsby-starter-default",
"name": "gatsby-starter-default-build-ssr-errors",
"private": true,
"description": "A simple starter to get up and developing quickly with Gatsby",
"version": "0.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Disable eslint-loader
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gatsby-starter-default",
"name": "gatsby-starter-default-build",
"private": true,
"description": "A simple starter to get up and developing quickly with Gatsby",
"version": "0.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Disable eslint-loader
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gatsby-starter-default",
"name": "gatsby-starter-default-develop",
"private": true,
"description": "A simple starter to get up and developing quickly with Gatsby",
"version": "0.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "gatsby-starter-default",
"name": "gatsby-starter-default-repl",
"private": true,
"description": "A simple starter to get up and developing quickly with Gatsby",
"version": "0.1.0",
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/gatsby-cli/test-helpers/invoke-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ export const GatsbyCLI = {
from(relativeCwd) {
return {
invoke(args) {
const NODE_ENV = args[0] === `develop` ? `development` : `production`
try {
const results = sync(
resolve(`./node_modules/.bin/gatsby`),
[].concat(args),
{
cwd: join(__dirname, `../`, `./${relativeCwd}`),
env: { NODE_ENV, CI: 1, GATSBY_LOGGER: `ink` },
}
)

Expand All @@ -29,11 +31,13 @@ export const GatsbyCLI = {
},

invokeAsync: (args, onExit) => {
const NODE_ENV = args[0] === `develop` ? `development` : `production`
const res = execa(
resolve(`./node_modules/.bin/gatsby`),
[].concat(args),
{
cwd: join(__dirname, `../`, `./${relativeCwd}`),
env: { NODE_ENV, CI: 1, GATSBY_LOGGER: `ink` },
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IQueryRunningContext } from "../state-machines/query-running/types"
export async function rebuildSchemaWithSitePage({
parentSpan,
}: Partial<IQueryRunningContext>): Promise<void> {
const activity = reporter.activityTimer(`updating schema`, {
const activity = reporter.activityTimer(`update schema`, {
parentSpan,
})
activity.start()
Expand Down
8 changes: 7 additions & 1 deletion packages/gatsby/src/state-machines/develop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ const developConfig: MachineConfig<IBuildContext, any, AnyEventObject> = {
`clearWebhookBody`,
`finishParentSpan`,
],
target: `runningQueries`,
target: `runningPostBootstrap`,
},
},
},
runningPostBootstrap: {
invoke: {
src: `postBootstrap`,
onDone: `runningQueries`,
},
},
// Running page and static queries and generating the SSRed HTML and page data
runningQueries: {
on: {
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby/src/state-machines/develop/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
startWebpackServer,
initialize,
recompile,
postBootstrap,
} from "../../services"
import {
initializeDataMachine,
Expand All @@ -22,4 +23,5 @@ export const developServices: Record<string, ServiceConfig<IBuildContext>> = {
waitForMutations: waitingMachine,
startWebpackServer,
recompile,
postBootstrap,
}