diff --git a/.circleci/config.yml b/.circleci/config.yml index e8d0f9519ce9a..5ecefdfba2294 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,7 @@ aliases: - /blog.+/ test_template: &test_template + parallelism: 4 parameters: npm_rebuild: type: boolean @@ -75,11 +76,16 @@ aliases: condition: << parameters.npm_rebuild >> steps: - run: npm rebuild - - run: yarn list react - - run: yarn why lmdb-store - run: - command: node --max-old-space-size=2048 ./node_modules/.bin/jest -w 1 --ci + name: Step debug info + command: | + yarn list react + yarn why lmdb-store + - run: + name: Run tests + command: yarn jest --ci --runInBand $(yarn jest --listTests | sed 's/\/root\/project//g' | circleci tests split --split-by=timings) environment: + NODE_OPTIONS: --max-old-space-size=2048 GENERATE_JEST_REPORT: true JEST_JUNIT_OUTPUT_DIR: ./test-results/jest-node/ JEST_JUNIT_OUTPUT_NAME: results.xml @@ -193,7 +199,8 @@ jobs: - persist_to_workspace: root: ./ paths: - - "*" + - "packages/" + - "node_modules/" lint: executor: node @@ -506,6 +513,7 @@ jobs: working_directory: ~/project/scripts/i18n windows_unit_tests: + parallelism: 4 executor: name: win/default shell: powershell.exe @@ -519,28 +527,30 @@ jobs: # keys: # - yarn-packages-v2-{{ checksum "yarn.lock" }} # - yarn-packages-v2- + + - <<: *attach_to_bootstrap - run: - name: Install node 12.13 + name: Install node 12.13 and yarn command: | nvm install 12.13.0 nvm alias default 12.13.0 nvm use 12.13.0 choco install yarn - run: - name: Set yarn timeout - command: yarn config set network-timeout 300000 - - run: - name: Install node modules - command: yarn --frozen-lockfile - # Caching is slow, so disabling - # - save_cache: - # paths: - # - C:\Users\circleci\AppData\Local\Yarn\Cache - # key: yarn-packages-v2-{{ checksum "yarn.lock" }} - - run: yarn npm-run-all -s check-versions "lerna-prepare --concurrency=4 --stream" + name: Rebuild packages for windows + command: | + Remove-Item -Recurse -Force -Path "node_modules/sharp/" + yarn - run: - name: "Run Tests" - command: yarn jest -w 1 --ci + name: Run tests + command: yarn jest --ci --runInBand ((yarn jest --listTests) | Foreach-Object {$_ -replace '.*\\packages', 'packages'} | Foreach-Object {$_ -replace '\\', '/'} | circleci tests split --split-by=timings) + environment: + NODE_OPTIONS: --max-old-space-size=2048 + GENERATE_JEST_REPORT: true + JEST_JUNIT_OUTPUT_DIR: ./test-results/jest-node/ + JEST_JUNIT_OUTPUT_NAME: results.xml + - store_test_results: + path: ./test-results/jest-node/ bootstrap-with-experimental-react: executor: node @@ -627,6 +637,7 @@ workflows: <<: *ignore_docs requires: - lint + - bootstrap - unit_tests_node12: <<: *ignore_docs requires: diff --git a/e2e-tests/production-runtime/cypress/integration/resource-loading-resilience.js b/e2e-tests/production-runtime/cypress/integration/resource-loading-resilience.js index 1e0fc62f9750f..fb563316b4847 100644 --- a/e2e-tests/production-runtime/cypress/integration/resource-loading-resilience.js +++ b/e2e-tests/production-runtime/cypress/integration/resource-loading-resilience.js @@ -1,5 +1,5 @@ const waitForAPIOptions = { - timeout: 10000, + timeout: 5000, } function runTests(testNameSuffix) { diff --git a/packages/gatsby/src/utils/worker/__tests__/config.ts b/packages/gatsby/src/utils/worker/__tests__/config.ts index e2b601481f7cc..239979f1ae025 100644 --- a/packages/gatsby/src/utils/worker/__tests__/config.ts +++ b/packages/gatsby/src/utils/worker/__tests__/config.ts @@ -4,6 +4,13 @@ import * as path from "path" let worker: GatsbyTestWorkerPool | undefined +jest.mock(`gatsby-telemetry`, () => { + return { + decorateEvent: jest.fn(), + trackCli: jest.fn(), + } +}) + beforeEach(() => { store.dispatch({ type: `DELETE_CACHE` }) }) diff --git a/packages/gatsby/src/utils/worker/__tests__/datastore.ts b/packages/gatsby/src/utils/worker/__tests__/datastore.ts index 246733e376a89..b215d0ae53b29 100644 --- a/packages/gatsby/src/utils/worker/__tests__/datastore.ts +++ b/packages/gatsby/src/utils/worker/__tests__/datastore.ts @@ -7,6 +7,18 @@ import { store } from "../../../redux" import { actions } from "../../../redux/actions" import { getDataStore } from "../../../datastore" +jest.mock(`gatsby-telemetry`, () => { + return { + decorateEvent: jest.fn(), + trackError: jest.fn(), + trackCli: jest.fn(), + } +}) + +jest.mock(`gatsby-cli/lib/reporter`, () => { + return {} +}) + let worker: GatsbyTestWorkerPool | undefined beforeEach(() => { diff --git a/packages/gatsby/src/utils/worker/__tests__/jobs.ts b/packages/gatsby/src/utils/worker/__tests__/jobs.ts index e42a9affd9ca5..28f3bd9c079a8 100644 --- a/packages/gatsby/src/utils/worker/__tests__/jobs.ts +++ b/packages/gatsby/src/utils/worker/__tests__/jobs.ts @@ -6,6 +6,15 @@ import { waitUntilAllJobsComplete } from "../../jobs/manager" import type { MessagesFromChild, MessagesFromParent } from "../messaging" import { getReduxJobs, getJobsMeta } from "./test-helpers/child-for-tests" +jest.mock(`gatsby-telemetry`, () => { + return { + decorateEvent: jest.fn(), + trackCli: jest.fn(), + } +}) + +// jest.mock(`gatsby-cli/lib/reporter`, () => jest.fn()) + let worker: GatsbyTestWorkerPool | undefined describe(`worker (jobs)`, () => { diff --git a/packages/gatsby/src/utils/worker/__tests__/queries.ts b/packages/gatsby/src/utils/worker/__tests__/queries.ts index fdcceadc467c1..6d33c2eb4541c 100644 --- a/packages/gatsby/src/utils/worker/__tests__/queries.ts +++ b/packages/gatsby/src/utils/worker/__tests__/queries.ts @@ -44,6 +44,14 @@ jest.mock(`chokidar`, () => { return chokidar }) +jest.mock(`gatsby-telemetry`, () => { + return { + decorateEvent: jest.fn(), + trackError: jest.fn(), + trackCli: jest.fn(), + } +}) + const dummyKeys = `a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z`.split( `,` ) diff --git a/packages/gatsby/src/utils/worker/__tests__/schema.ts b/packages/gatsby/src/utils/worker/__tests__/schema.ts index 6eb132a58d020..33e42dc742ae5 100644 --- a/packages/gatsby/src/utils/worker/__tests__/schema.ts +++ b/packages/gatsby/src/utils/worker/__tests__/schema.ts @@ -37,6 +37,14 @@ jest.mock(`chokidar`, () => { return chokidar }) +jest.mock(`gatsby-telemetry`, () => { + return { + decorateEvent: jest.fn(), + trackError: jest.fn(), + trackCli: jest.fn(), + } +}) + describeWhenLMDB(`worker (schema)`, () => { let stateFromWorker: CombinedState diff --git a/packages/gatsby/src/utils/worker/__tests__/share-state.ts b/packages/gatsby/src/utils/worker/__tests__/share-state.ts index c4e793afa34f2..2be3661ce3a68 100644 --- a/packages/gatsby/src/utils/worker/__tests__/share-state.ts +++ b/packages/gatsby/src/utils/worker/__tests__/share-state.ts @@ -7,6 +7,14 @@ import { } from "../../../redux" import { GatsbyStateKeys } from "../../../redux/types" +jest.mock(`gatsby-telemetry`, () => { + return { + decorateEvent: jest.fn(), + trackError: jest.fn(), + trackCli: jest.fn(), + } +}) + let worker: GatsbyTestWorkerPool | undefined const dummyPagePayload = {