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

chore(gatsby-cli): use gatsby clean in tests to test gatsby clean #22739

Merged
merged 2 commits into from
Apr 1, 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
8 changes: 3 additions & 5 deletions integration-tests/gatsby-cli/__tests__/build.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { GatsbyCLI, removeFolder } from "../test-helpers"
import { GatsbyCLI } from "../test-helpers"

const MAX_TIMEOUT = 2147483647
jest.setTimeout(MAX_TIMEOUT)

describe(`gatsby build`, () => {
const cwd = `gatsby-sites/gatsby-build`

beforeAll(() => removeFolder(`${cwd}/.cache`))
beforeAll(() => removeFolder(`${cwd}/public`))
afterAll(() => removeFolder(`${cwd}/.cache`))
afterAll(() => removeFolder(`${cwd}/public`))
beforeAll(() => GatsbyCLI.from(cwd).invoke(`clean`))
afterAll(() => GatsbyCLI.from(cwd).invoke(`clean`))

it(`creates a built gatsby site`, () => {
const [code, logs] = GatsbyCLI.from(cwd).invoke(`build`)
Expand Down
11 changes: 4 additions & 7 deletions integration-tests/gatsby-cli/__tests__/develop.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import spawn from "cross-spawn"
import { GatsbyCLI, removeFolder } from "../test-helpers"
import strip from "strip-ansi"
import { GatsbyCLI } from "../test-helpers"

const timeout = seconds =>
new Promise(resolve => {
Expand All @@ -13,17 +12,15 @@ jest.setTimeout(MAX_TIMEOUT)
describe(`gatsby develop`, () => {
const cwd = `gatsby-sites/gatsby-develop`

beforeAll(() => removeFolder(`${cwd}/.cache`))
beforeAll(() => removeFolder(`${cwd}/public`))
afterAll(() => removeFolder(`${cwd}/.cache`))
afterAll(() => removeFolder(`${cwd}/public`))
beforeAll(() => GatsbyCLI.from(cwd).invoke(`clean`))
afterAll(() => GatsbyCLI.from(cwd).invoke(`clean`))

it(`starts a gatsby site on port 8000`, async () => {
// 1. Start the `gatsby develop` command
const [childProcess, getLogs] = GatsbyCLI.from(cwd).invokeAsync(`develop`)

// 2. Wait for the build process to finish
await timeout(30)
await timeout(10)

// 3. kill the `gatsby develop` command so we can get logs
spawn.sync("kill", [childProcess.pid])
Expand Down