From 231c7ef16db9e5845e013d9dad54ad42c76b9971 Mon Sep 17 00:00:00 2001 From: Blaine Kasten Date: Wed, 1 Apr 2020 17:17:46 -0500 Subject: [PATCH] chore(gatsby-cli): use `gatsby clean` in tests to test `gatsby clean` (#22739) * chore(gatsby-cli): use `gatsby clean` in tests to test `gatsby clean` * cleanup --- integration-tests/gatsby-cli/__tests__/build.js | 8 +++----- integration-tests/gatsby-cli/__tests__/develop.js | 11 ++++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/integration-tests/gatsby-cli/__tests__/build.js b/integration-tests/gatsby-cli/__tests__/build.js index f33b4c551fad9..770b017d8fe7d 100644 --- a/integration-tests/gatsby-cli/__tests__/build.js +++ b/integration-tests/gatsby-cli/__tests__/build.js @@ -1,4 +1,4 @@ -import { GatsbyCLI, removeFolder } from "../test-helpers" +import { GatsbyCLI } from "../test-helpers" const MAX_TIMEOUT = 2147483647 jest.setTimeout(MAX_TIMEOUT) @@ -6,10 +6,8 @@ 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`) diff --git a/integration-tests/gatsby-cli/__tests__/develop.js b/integration-tests/gatsby-cli/__tests__/develop.js index b3c74b0931474..864a7f6568440 100644 --- a/integration-tests/gatsby-cli/__tests__/develop.js +++ b/integration-tests/gatsby-cli/__tests__/develop.js @@ -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])