diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index e6acc2b7cb3e..a4394c1efee3 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -90,3 +90,44 @@ jobs: run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} env: CI: true + + test-circus: + name: Node LTS on ${{ matrix.os }} using jest-circus + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Set git config + shell: bash + run: | + git config --global core.autocrlf false + git config --global core.symlinks true + if: runner.os == 'Windows' + - uses: actions/checkout@v2 + - name: Get yarn cache + id: yarn-cache + run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + - uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-node-14.x-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node-14.x-yarn- + - name: Use Node.js 14.x + uses: actions/setup-node@v2.1.2 + with: + node-version: 14.x + - name: install + run: yarn --immutable + - name: build + run: yarn build:js + - name: Get number of CPU cores + id: cpu-cores + uses: SimenB/github-actions-cpu-cores@v1 + - name: run tests using jest-circus + run: yarn jest-circus-ci --max-workers ${{ steps.cpu-cores.outputs.count }} + env: + CI: true diff --git a/CHANGELOG.md b/CHANGELOG.md index beca614674f6..68cca5f06e33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Fixes - `[jest-circus]` Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped `describe` block [#10451](https://github.com/facebook/jest/issues/10451) +- `[jest-circus]` Fix `testLocation` on Windows when using `test.each` ([#10871](https://github.com/facebook/jest/pull/10871)) - `[jest-jasmine2]` Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped `describe` block when it has child `tests` marked as either `only` or `todo` [#10451](https://github.com/facebook/jest/issues/10451) - `[jest-jasmine2]` Fixed the issues of child `tests` marked with `only` or `todo` getting executed even if it is inside a skipped parent `describe` block [#10451](https://github.com/facebook/jest/issues/10451) - `[jest-console]` `console.dir` now respects the second argument correctly ([#10638](https://github.com/facebook/jest/pull/10638)) diff --git a/e2e/runJest.ts b/e2e/runJest.ts index d082ca739cea..56c25746739b 100644 --- a/e2e/runJest.ts +++ b/e2e/runJest.ts @@ -23,7 +23,7 @@ type RunJestOptions = { skipPkgJsonCheck?: boolean; // don't complain if can't find package.json stripAnsi?: boolean; // remove colors from stdout and stderr, timeout?: number; // kill the Jest process after X milliseconds - env?: Record; + env?: NodeJS.ProcessEnv; }; // return the result of the spawned process: @@ -74,13 +74,17 @@ function spawnJest( `, ); } - const env = Object.assign({}, process.env, {FORCE_COLOR: '0'}, options.env); + const env: NodeJS.ProcessEnv = { + ...process.env, + FORCE_COLOR: '0', + ...options.env, + }; if (options.nodeOptions) env['NODE_OPTIONS'] = options.nodeOptions; if (options.nodePath) env['NODE_PATH'] = options.nodePath; const spawnArgs = [JEST_PATH, ...args]; - const spawnOptions = { + const spawnOptions: execa.CommonOptions = { cwd: dir, env, reject: false, diff --git a/package.json b/package.json index 3bea730d2ab7..24c9a930bbfe 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,8 @@ "clean-all": "yarn clean-e2e && yarn build-clean && rimraf './packages/*/node_modules' && rimraf './node_modules'", "clean-e2e": "node ./scripts/cleanE2e.js", "jest": "node ./packages/jest-cli/bin/jest.js", + "jest-circus": "JEST_CIRCUS=1 yarn jest", + "jest-circus-ci": "yarn jest-circus --color --config jest.config.ci.js", "jest-coverage": "yarn jest --coverage", "lint": "eslint . --cache --ext js,jsx,ts,tsx,md", "lint:prettier": "prettier '**/*.{md,yml,yaml}' 'website/static/**/*.{css,js}' --write --ignore-path .gitignore", diff --git a/packages/jest-circus/src/utils.ts b/packages/jest-circus/src/utils.ts index 7a52de3a46af..345bdf2b1d54 100644 --- a/packages/jest-circus/src/utils.ts +++ b/packages/jest-circus/src/utils.ts @@ -9,6 +9,7 @@ import * as path from 'path'; import co from 'co'; import dedent = require('dedent'); import isGeneratorFn from 'is-generator-fn'; +import slash = require('slash'); import StackUtils = require('stack-utils'); import type {AssertionResult, Status} from '@jest/test-result'; import type {Circus} from '@jest/types'; @@ -18,7 +19,7 @@ import {ROOT_DESCRIBE_BLOCK_NAME, getState} from './state'; const stackUtils = new StackUtils({cwd: 'A path that does not exist'}); -const jestEachBuildDir = path.dirname(require.resolve('jest-each')); +const jestEachBuildDir = slash(path.dirname(require.resolve('jest-each'))); export const makeDescribe = ( name: Circus.BlockName,