Skip to content

Commit

Permalink
chore(gatsby-cli): use gatsby clean in tests to test gatsby clean (
Browse files Browse the repository at this point in the history
…#22739)

* chore(gatsby-cli): use `gatsby clean` in tests to test `gatsby clean`

* cleanup
  • Loading branch information
blainekasten authored Apr 1, 2020
1 parent 18b1bbc commit 231c7ef
Showing 2 changed files with 7 additions and 12 deletions.
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`)
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 => {
@@ -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])

0 comments on commit 231c7ef

Please sign in to comment.