Skip to content

Commit

Permalink
fix: test location for test.each on windows (#10871)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Nov 26, 2020
1 parent 64207cc commit e442dec
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/nodejs.yml
Expand Up @@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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))
Expand Down
10 changes: 7 additions & 3 deletions e2e/runJest.ts
Expand Up @@ -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<string, string>;
env?: NodeJS.ProcessEnv;
};

// return the result of the spawned process:
Expand Down Expand Up @@ -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<string> = {
cwd: dir,
env,
reject: false,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-circus/src/utils.ts
Expand Up @@ -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';
Expand All @@ -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,
Expand Down

0 comments on commit e442dec

Please sign in to comment.