Skip to content

Commit

Permalink
Merge branch 'main' into chore/deprecate-jest-cli-init
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Sep 19, 2023
2 parents 950d107 + ea685a5 commit 5c50550
Show file tree
Hide file tree
Showing 207 changed files with 1,530 additions and 1,379 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ workflows:
matrix:
parameters:
# For some reason, v20 fails to run yarn install…
node-version: ['14', '16', '18', '19']
node-version: ['16', '18']
- test-jest-jasmine
8 changes: 7 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ module.exports = {
parserOptions: {
sourceType: 'module',
},
plugins: ['import', 'jsdoc'],
plugins: ['import', 'jsdoc', 'unicorn'],
rules: {
'accessor-pairs': ['warn', {setWithoutGet: true}],
'block-scoped-var': 'off',
Expand Down Expand Up @@ -590,6 +590,12 @@ module.exports = {
'wrap-iife': 'off',
'wrap-regex': 'off',
yoda: 'off',

'unicorn/explicit-length-check': 'error',
'unicorn/no-negated-condition': 'error',
'unicorn/prefer-default-parameters': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/template-indent': 'error',
},
settings: {
'import/ignore': ['react-native'],
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Node Nightly CI

on:
workflow_dispatch:
schedule:
- cron: '0 12 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
prepare-yarn-cache-ubuntu:
uses: ./.github/workflows/prepare-cache.yml
with:
os: ubuntu-latest
prepare-yarn-cache-macos:
uses: ./.github/workflows/prepare-cache.yml
with:
os: macos-latest
prepare-yarn-cache-windows:
uses: ./.github/workflows/prepare-cache.yml
with:
os: windows-latest

test-ubuntu:
uses: ./.github/workflows/test-nightly.yml
needs: prepare-yarn-cache-ubuntu
with:
os: ubuntu-latest
test-macos:
uses: ./.github/workflows/test-nightly.yml
needs: prepare-yarn-cache-macos
with:
os: macos-latest
test-windows:
uses: ./.github/workflows/test-nightly.yml
needs: prepare-yarn-cache-windows
with:
os: windows-latest
notify:
name: Notify failed build
needs: [test-ubuntu, test-macos, test-windows]
if: failure()
runs-on: ubuntu-latest
steps:
- uses: jayqi/failed-build-issue-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ on:
branches:
- main
pull_request:
branches:
- '**'
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/test-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Test

on:
workflow_call:
inputs:
os:
required: true
type: string

jobs:
test:
strategy:
fail-fast: false
matrix:
shard: ['1/4', '2/4', '3/4', '4/4']
name: Node nightly on ${{ inputs.os }} (${{ matrix.shard }})
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: 21-nightly
cache: yarn
- 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@v2
- name: run tests
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}

test-jasmine:
strategy:
fail-fast: false
matrix:
shard: ['1/4', '2/4', '3/4', '4/4']
name: Node Nightly on ${{ inputs.os }} using jest-jasmine2 (${{ matrix.shard }})
runs-on: ${{ inputs.os }}

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 21-nightly
cache: yarn
- 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@v2
- name: run tests using jest-jasmine
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x, 18.x, 19.x, 20.x]
node-version: [16.x, 18.x, 20.x]
shard: ['1/4', '2/4', '3/4', '4/4']
name: Node v${{ matrix.node-version }} on ${{ inputs.os }} (${{ matrix.shard }})
runs-on: ${{ inputs.os }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

### Features

- `[@jest/test-sequencer, jest-core]` [**BREAKING**] Exposes `globalConfig` & `contexts` to `TestSequencer` ([#14535](https://github.com/jestjs/jest/pull/14535), & [#14543](https://github.com/jestjs/jest/pull/14543))

### Fixes

- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))

### Performance

### Chore & Maintenance

- `[*]` [**BREAKING**] Drop support for Node.js versions 14 and 19 ([#14460](https://github.com/jestjs/jest/pull/14460))

## 29.7.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ gen_enforced_field(WorkspaceCwd, 'publishConfig.access', null) :-
workspace_field(WorkspaceCwd, 'private', true).

% Enforces the engines.node field for public workspace
gen_enforced_field(WorkspaceCwd, 'engines.node', '^14.15.0 || ^16.10.0 || >=18.0.0') :-
gen_enforced_field(WorkspaceCwd, 'engines.node', '^16.10.0 || ^18.12.0 || >=20.0.0') :-
\+ workspace_field(WorkspaceCwd, 'private', true).

% Enforces the main and types field to start with ./
Expand Down
14 changes: 7 additions & 7 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1739,14 +1739,14 @@ test('does not show prototypes for object and array inline', () => {
array: [{hello: 'Danger'}],
};
expect(object).toMatchInlineSnapshot(`
{
"array": [
{
"hello": "Danger",
},
],
}
`);
"array": [
{
"hello": "Danger",
},
],
}
`);
});
```

Expand Down
24 changes: 12 additions & 12 deletions docs/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -1186,10 +1186,10 @@ function areVolumesEqual(a, b) {

if (isAVolume && isBVolume) {
return a.equals(b);
} else if (isAVolume !== isBVolume) {
return false;
} else {
} else if (isAVolume === isBVolume) {
return undefined;
} else {
return false;
}
}

Expand Down Expand Up @@ -1243,10 +1243,10 @@ function areVolumesEqual(a: unknown, b: unknown): boolean | undefined {

if (isAVolume && isBVolume) {
return a.equals(b);
} else if (isAVolume !== isBVolume) {
return false;
} else {
} else if (isAVolume === isBVolume) {
return undefined;
} else {
return false;
}
}

Expand Down Expand Up @@ -1297,10 +1297,10 @@ function areAuthorEqual(a, b) {
if (isAAuthor && isBAuthor) {
// Authors are equal if they have the same name
return a.name === b.name;
} else if (isAAuthor !== isBAuthor) {
return false;
} else {
} else if (isAAuthor === isBAuthor) {
return undefined;
} else {
return false;
}
}

Expand All @@ -1315,10 +1315,10 @@ function areBooksEqual(a, b, customTesters) {
return (
a.name === b.name && this.equals(a.authors, b.authors, customTesters)
);
} else if (isABook !== isBBook) {
return false;
} else {
} else if (isABook === isBBook) {
return undefined;
} else {
return false;
}
}

Expand Down
18 changes: 9 additions & 9 deletions docs/SnapshotTesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ it('renders correctly', () => {
.create(<Link page="https://example.com">Example Site</Link>)
.toJSON();
expect(tree).toMatchInlineSnapshot(`
<a
className="normal"
href="https://example.com"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
Example Site
</a>
`);
<a
className="normal"
href="https://example.com"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
Example Site
</a>
`);
});
```

Expand Down
48 changes: 24 additions & 24 deletions e2e/__tests__/__snapshots__/wrongEnv.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Wrong globals for environment on node <21 print useful error for navigator 1`] = `
"FAIL __tests__/node.js
✕ use navigator
○ skipped use document
○ skipped use window
● use navigator
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string.
Consider using the "jsdom" test environment.
ReferenceError: navigator is not defined
30 |
31 | test('use navigator', () => {
> 32 | const userAgent = navigator.userAgent;
| ^
33 |
34 | console.log(userAgent);
35 |
at Object.navigator (__tests__/node.js:32:21)"
`;
exports[`Wrong globals for environment print useful error for document 1`] = `
"FAIL __tests__/node.js
✕ use document
Expand All @@ -24,30 +48,6 @@ exports[`Wrong globals for environment print useful error for document 1`] = `
at Object.document (__tests__/node.js:16:15)"
`;
exports[`Wrong globals for environment print useful error for navigator 1`] = `
"FAIL __tests__/node.js
✕ use navigator
○ skipped use document
○ skipped use window
● use navigator
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string.
Consider using the "jsdom" test environment.
ReferenceError: navigator is not defined
30 |
31 | test('use navigator', () => {
> 32 | const userAgent = navigator.userAgent;
| ^
33 |
34 | console.log(userAgent);
35 |
at Object.navigator (__tests__/node.js:32:21)"
`;
exports[`Wrong globals for environment print useful error for unref 1`] = `
"FAIL __tests__/jsdom.js
✕ use unref
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/customInlineSnapshotMatchers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('works with custom inline snapshot matchers', () => {

rest = rest
.split('\n')
.filter(line => line.indexOf('at Error (native)') < 0)
.filter(line => !line.includes('at Error (native)'))
.join('\n');

expect(rest).toMatchSnapshot();
Expand All @@ -36,7 +36,7 @@ test('can bail with a custom inline snapshot matcher', () => {

rest = rest
.split('\n')
.filter(line => line.indexOf('at Error (native)') < 0)
.filter(line => !line.includes('at Error (native)'))
.join('\n');

expect(rest).toMatchSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/customMatcherStackTrace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('works with custom matchers', () => {

rest = rest
.split('\n')
.filter(line => line.indexOf('at Error (native)') < 0)
.filter(line => !line.includes('at Error (native)'))
.join('\n');

expect(rest).toMatchSnapshot();
Expand Down
Loading

0 comments on commit 5c50550

Please sign in to comment.