Skip to content

Commit f8a70c7

Browse files
committed
Merge branch 'main' into bug-13222
2 parents 2f4ee48 + 70340d0 commit f8a70c7

File tree

2,511 files changed

+63380
-48247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,511 files changed

+63380
-48247
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ aliases:
1212
app-dir: ~/jest
1313

1414
orbs:
15-
node: circleci/node@5.0.0
15+
node: circleci/node@5.1.0
1616

1717
jobs:
1818
test-node:
@@ -58,5 +58,6 @@ workflows:
5858
name: test-node-partial-<< matrix.node-version >>
5959
matrix:
6060
parameters:
61-
node-version: ['14', '16', '18']
61+
# For some reason, v20 fails to run yarn install…
62+
node-version: ['16', '18']
6263
- test-jest-jasmine

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ bin/
55
packages/*/build/**
66
packages/*/dist/**
77
website/.docusaurus
8-
website/blog
98
website/build
109
website/node_modules
1110
website/i18n/*.js

.eslintplugin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.

.eslintrc.cjs

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -40,11 +40,7 @@ module.exports = {
4040
},
4141
overrides: [
4242
{
43-
extends: [
44-
'plugin:@typescript-eslint/recommended',
45-
'plugin:@typescript-eslint/eslint-recommended',
46-
'plugin:import/typescript',
47-
],
43+
extends: ['plugin:@typescript-eslint/strict', 'plugin:import/typescript'],
4844
files: ['*.ts', '*.tsx'],
4945
plugins: ['@typescript-eslint/eslint-plugin', 'local'],
5046
rules: {
@@ -61,9 +57,15 @@ module.exports = {
6157
'consistent-return': 'off',
6258
'no-dupe-class-members': 'off',
6359
'no-unused-vars': 'off',
60+
'@typescript-eslint/no-dynamic-delete': 'off',
6461
// TODO: enable at some point
6562
'@typescript-eslint/no-explicit-any': 'off',
6663
'@typescript-eslint/no-non-null-assertion': 'off',
64+
'@typescript-eslint/no-invalid-void-type': 'off',
65+
66+
// TODO: part of "stylistic" rules, remove explicit activation when that lands
67+
'@typescript-eslint/no-empty-function': 'error',
68+
'@typescript-eslint/no-empty-interface': 'error',
6769
},
6870
},
6971
{
@@ -128,7 +130,7 @@ module.exports = {
128130
rules: {
129131
'@typescript-eslint/ban-types': [
130132
'error',
131-
// TODO: remove these overrides: https://github.com/facebook/jest/issues/10177
133+
// TODO: remove these overrides: https://github.com/jestjs/jest/issues/10177
132134
{types: {Function: false, object: false, '{}': false}},
133135
],
134136
'local/ban-types-eventually': [
@@ -162,14 +164,36 @@ module.exports = {
162164
],
163165
env: {'jest/globals': true},
164166
excludedFiles: ['**/__typetests__/**'],
167+
extends: ['plugin:jest/style'],
165168
plugins: ['jest'],
166169
rules: {
170+
'jest/no-alias-methods': 'error',
167171
'jest/no-focused-tests': 'error',
168172
'jest/no-identical-title': 'error',
173+
'jest/require-to-throw-message': 'error',
169174
'jest/valid-expect': 'error',
170175
},
171176
},
172177

178+
{
179+
files: ['e2e/__tests__/*'],
180+
rules: {
181+
'jest/no-restricted-jest-methods': [
182+
'error',
183+
{
184+
fn: 'Please use fixtures instead of mocks in the end-to-end tests.',
185+
mock: 'Please use fixtures instead of mocks in the end-to-end tests.',
186+
doMock:
187+
'Please use fixtures instead of mocks in the end-to-end tests.',
188+
setMock:
189+
'Please use fixtures instead of mocks in the end-to-end tests.',
190+
spyOn:
191+
'Please use fixtures instead of mocks in the end-to-end tests.',
192+
},
193+
],
194+
},
195+
},
196+
173197
// to make it more suitable for running on code examples in docs/ folder
174198
{
175199
files: ['**/*.md/**'],
@@ -178,19 +202,50 @@ module.exports = {
178202
'@typescript-eslint/no-empty-function': 'off',
179203
'@typescript-eslint/no-namespace': 'off',
180204
'@typescript-eslint/no-empty-interface': 'off',
181-
'arrow-body-style': 'off',
182205
'consistent-return': 'off',
183206
'import/export': 'off',
184207
'import/no-extraneous-dependencies': 'off',
185208
'import/no-unresolved': 'off',
186209
'jest/no-focused-tests': 'off',
210+
'jest/require-to-throw-message': 'off',
187211
'no-console': 'off',
188212
'no-undef': 'off',
189213
'no-unused-vars': 'off',
190-
'prettier/prettier': 'off',
191214
'sort-keys': 'off',
192215
},
193216
},
217+
// demonstration of matchers usage
218+
{
219+
files: ['**/UsingMatchers.md/**'],
220+
rules: {
221+
'jest/prefer-to-be': 'off',
222+
},
223+
},
224+
// demonstration of 'jest/valid-expect' rule
225+
{
226+
files: [
227+
'**/2017-05-06-jest-20-delightful-testing-multi-project-runner.md/**',
228+
],
229+
rules: {
230+
'jest/valid-expect': 'off',
231+
},
232+
},
233+
// Jest 11 did not had `toHaveLength` matcher
234+
{
235+
files: ['**/2016-04-12-jest-11.md/**'],
236+
rules: {
237+
'jest/prefer-to-have-length': 'off',
238+
},
239+
},
240+
// snapshot in an example needs to keep escapes
241+
{
242+
files: [
243+
'**/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md/**',
244+
],
245+
rules: {
246+
'no-useless-escape': 'off',
247+
},
248+
},
194249

195250
// snapshots in examples plus inline snapshots need to keep backtick
196251
{
@@ -216,8 +271,7 @@ module.exports = {
216271
{
217272
files: ['examples/**/*'],
218273
rules: {
219-
'import/no-unresolved': ['error', {ignore: ['^react-native$']}],
220-
'import/order': 'off',
274+
'no-restricted-imports': 'off',
221275
},
222276
},
223277
{
@@ -295,6 +349,8 @@ module.exports = {
295349
files: ['**/__typetests__/**'],
296350
rules: {
297351
'@typescript-eslint/no-empty-function': 'off',
352+
'@typescript-eslint/no-invalid-void-type': 'off',
353+
'@typescript-eslint/no-useless-constructor': 'off',
298354
},
299355
},
300356
{
@@ -305,7 +361,7 @@ module.exports = {
305361
files: [
306362
'scripts/*',
307363
'packages/*/__benchmarks__/test.js',
308-
'packages/jest-cli/src/init/index.ts',
364+
'packages/create-jest/src/runCreate.ts',
309365
'packages/jest-repl/src/cli/runtime-cli.ts',
310366
],
311367
rules: {
@@ -322,6 +378,7 @@ module.exports = {
322378
'**/__typetests__/**',
323379
],
324380
rules: {
381+
'@typescript-eslint/no-extraneous-class': 'off',
325382
'@typescript-eslint/no-unused-vars': 'off',
326383
'import/no-unresolved': 'off',
327384
'no-console': 'off',
@@ -333,7 +390,7 @@ module.exports = {
333390
parserOptions: {
334391
sourceType: 'module',
335392
},
336-
plugins: ['import'],
393+
plugins: ['import', 'jsdoc', 'unicorn'],
337394
rules: {
338395
'accessor-pairs': ['warn', {setWithoutGet: true}],
339396
'block-scoped-var': 'off',
@@ -390,6 +447,7 @@ module.exports = {
390447
},
391448
],
392449
'init-declarations': 'off',
450+
'jsdoc/check-alignment': 'error',
393451
'lines-around-comment': 'off',
394452
'max-depth': 'off',
395453
'max-nested-callbacks': 'off',
@@ -537,6 +595,13 @@ module.exports = {
537595
'wrap-iife': 'off',
538596
'wrap-regex': 'off',
539597
yoda: 'off',
598+
599+
'unicorn/explicit-length-check': 'error',
600+
'unicorn/no-array-for-each': 'error',
601+
'unicorn/no-negated-condition': 'error',
602+
'unicorn/prefer-default-parameters': 'error',
603+
'unicorn/prefer-includes': 'error',
604+
'unicorn/template-indent': 'error',
540605
},
541606
settings: {
542607
'import/ignore': ['react-native'],

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 👉 [Please follow one of these issue templates](https://github.com/facebook/jest/issues/new/choose) 👈
1+
## 👉 [Please follow one of these issue templates](https://github.com/jestjs/jest/issues/new/choose) 👈
22

33
<!-- Love Jest? Please consider supporting our collective: 👉 https://opencollective.com/jest/donate -->
44

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ body:
4141
label: Version
4242
description: |
4343
The version of Jest you are using.
44-
Is it the [latest](https://github.com/facebook/jest/releases)? Test and see if the bug has already been fixed.
44+
Is it the [latest](https://github.com/jestjs/jest/releases)? Test and see if the bug has already been fixed.
4545
placeholder: ex. 27.0.6
4646
validations:
4747
required: true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Documentation 📖
2+
description: Submit a request to add or update documentation
3+
title: '[Docs]: '
4+
labels: ['Documentation :book:']
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
### Thank you for helping us improve our documentation!
10+
11+
Please be sure you are looking at [the latest version of the documentation](https://jestjs.io/docs) before opening an issue here.
12+
- type: textarea
13+
id: links
14+
attributes:
15+
label: Page(s)
16+
description: |
17+
Links to one or more documentation pages that should be modified.
18+
If you are reporting an issue with a specific section of a page, try to link directly to the nearest anchor.
19+
If you are suggesting that a new page be created, link to the parent of the proposed page.
20+
validations:
21+
required: true
22+
- type: textarea
23+
id: description
24+
attributes:
25+
label: Description
26+
description: |
27+
Describe the change you are requesting.
28+
If the issue pertains to a single function or matcher, be sure to specify the entire call signature.
29+
validations:
30+
required: true

.github/dependabot.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/renovate.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": ["config:base"],
4+
"lockFileMaintenance": {"enabled": true, "automerge": false},
5+
"rangeStrategy": "replace",
6+
"postUpdateOptions": ["yarnDedupeHighest"],
7+
"packageRules": [
8+
{
9+
"matchPackageNames": ["@tsd/typescript", "typescript"],
10+
"groupName": "typescript"
11+
},
12+
{
13+
"matchPackageNames": ["jest-runner-tsd", "tsd-lite"],
14+
"groupName": "tsd"
15+
}
16+
]
17+
}

.github/workflows/close-stale.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
name: 'Close stale issues and PRs'
22
on:
33
schedule:
4-
- cron: '*/10 * * * *'
4+
- cron: '0 * * * *'
5+
6+
permissions:
7+
issues: write # to close stale issues (actions/stale)
8+
pull-requests: write # to close stale PRs (actions/stale)
59

610
jobs:
711
stale:
812
name: 'Close month old issues and PRs'
913
runs-on: ubuntu-latest
1014
steps:
11-
- uses: actions/stale@v6
15+
- uses: actions/stale@v8
1216
with:
1317
start-date: '2022-01-01T00:00:00Z'
1418
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.'
@@ -21,13 +25,14 @@ jobs:
2125
days-before-pr-close: 30
2226
exempt-all-milestones: true
2327
exempt-issue-labels: Pinned
28+
exempt-pr-labels: Pinned
2429
exempt-draft-pr: true
2530
operations-per-run: 1750
2631
stale-legacy:
2732
name: 'Close year old issues and PRs'
2833
runs-on: ubuntu-latest
2934
steps:
30-
- uses: actions/stale@v6
35+
- uses: actions/stale@v8
3136
with:
3237
stale-issue-message: 'This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.'
3338
stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.'
@@ -39,4 +44,5 @@ jobs:
3944
days-before-pr-close: 30
4045
exempt-all-milestones: true
4146
exempt-issue-labels: Pinned
47+
exempt-pr-labels: Pinned
4248
operations-per-run: 1750

.github/workflows/issues.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,25 @@ on:
44
issues:
55
types: [labeled]
66

7+
permissions:
8+
issues: write # to close issues (peter-evans/close-issue)
9+
710
jobs:
811
questions:
912
name: Questions
1013
runs-on: ubuntu-latest
1114
steps:
12-
- name: Close Issue
13-
uses: peter-evans/close-issue@v2
14-
if: "${{ github.event.label.name == ':speech_balloon: Question' }}"
15-
with:
16-
comment: Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions.
15+
- if: "${{ github.event.label.name == ':speech_balloon: Question' }}"
16+
run: gh issue close $ISSUE --comment "Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions."
17+
env:
18+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
ISSUE: ${{ github.event.issue.html_url }}
1720
bug-without-repro:
1821
name: Bug reports without reproductions
1922
runs-on: ubuntu-latest
2023
steps:
21-
- name: Close Issue
22-
uses: peter-evans/close-issue@v2
23-
if: "${{ github.event.label.name == 'Needs Reproduction' }}"
24-
with:
25-
comment: As noted in the [Bug Report template](https://github.com/facebook/jest/blob/main/.github/ISSUE_TEMPLATE/bug.yml), all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example.
24+
- if: "${{ github.event.label.name == 'Needs Reproduction' }}"
25+
run: gh issue close $ISSUE --comment "As noted in the [Bug Report template](https://github.com/jestjs/jest/blob/main/.github/ISSUE_TEMPLATE/bug.yml), all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example."
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
ISSUE: ${{ github.event.issue.html_url }}

0 commit comments

Comments
 (0)