Skip to content

Commit f5c4429

Browse files
authored
Merge branch 'master' into support-non-js-esm
2 parents e8f3cc4 + fe144ea commit f5c4429

91 files changed

Lines changed: 810 additions & 719 deletions

File tree

Some content is hidden

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

.eslintrc.js

Lines changed: 204 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@ const internalPackages = getPackages()
1717
.sort();
1818

1919
module.exports = {
20+
env: {
21+
'jest/globals': true,
22+
node: true,
23+
},
2024
extends: [
21-
'fb-strict',
2225
'plugin:import/errors',
23-
'plugin:import/typescript',
2426
'prettier',
25-
'prettier/flowtype',
2627
'plugin:eslint-comments/recommended',
2728
],
2829
overrides: [
2930
{
30-
extends: ['plugin:@typescript-eslint/eslint-recommended'],
31+
extends: [
32+
'plugin:@typescript-eslint/eslint-recommended',
33+
'plugin:import/typescript',
34+
'prettier/@typescript-eslint',
35+
],
3136
files: ['*.ts', '*.tsx'],
3237
plugins: ['@typescript-eslint/eslint-plugin', 'local'],
3338
rules: {
@@ -139,34 +144,22 @@ module.exports = {
139144
rules: {
140145
'arrow-body-style': 'off',
141146
'consistent-return': 'off',
142-
'flowtype/require-valid-file-annotation': 'off',
143147
'import/no-extraneous-dependencies': 'off',
144148
'import/no-unresolved': 'off',
145-
'jest/no-focused-tests': 'off',
146-
'jest/no-identical-title': 'off',
147-
'jest/valid-expect': 'off',
149+
'no-console': 'off',
148150
'no-undef': 'off',
149151
'no-unused-vars': 'off',
150152
'prettier/prettier': 'off',
151-
'react/jsx-no-undef': 'off',
152-
'react/react-in-jsx-scope': 'off',
153153
'sort-keys': 'off',
154154
},
155155
},
156156
{
157157
files: ['examples/**/*'],
158158
rules: {
159-
'babel/func-params-comma-dangle': 'off',
160159
'import/no-unresolved': ['error', {ignore: ['^react-native$']}],
161160
'import/order': 'off',
162161
},
163162
},
164-
{
165-
files: ['scripts/**/*', 'e2e/**/*'],
166-
rules: {
167-
'babel/func-params-comma-dangle': 'off',
168-
},
169-
},
170163
{
171164
files: 'packages/jest-types/**/*',
172165
rules: {
@@ -225,23 +218,68 @@ module.exports = {
225218
},
226219
},
227220
{
228-
files: ['test-types/*.test.ts'],
221+
files: ['test-types/*.test.ts', '*.md'],
229222
rules: {
230223
'jest/no-focused-tests': 'off',
231224
'jest/no-identical-title': 'off',
232225
'jest/valid-expect': 'off',
233226
},
234227
},
228+
{
229+
files: [
230+
'scripts/*',
231+
'packages/jest-cli/src/init/index.ts',
232+
'packages/jest-repl/src/cli/runtime-cli.ts',
233+
],
234+
rules: {
235+
'no-console': 'off',
236+
},
237+
},
238+
{
239+
files: [
240+
'e2e/**',
241+
'examples/**',
242+
'scripts/*',
243+
'website/**',
244+
'**/__mocks__/**',
245+
'**/__tests__/**',
246+
'**/__performance_tests__/**',
247+
'packages/diff-sequences/perf/index.js',
248+
'packages/pretty-format/perf/test.js'
249+
],
250+
rules: {
251+
'import/no-unresolved': 'off',
252+
'no-console': 'off',
253+
'no-unused-vars': 'off',
254+
},
255+
},
235256
],
236257
parser: '@typescript-eslint/parser',
237-
plugins: ['markdown', 'import', 'prettier', 'eslint-comments'],
258+
parserOptions: {
259+
sourceType: 'module',
260+
},
261+
plugins: ['markdown', 'import', 'jest'],
238262
rules: {
239-
'arrow-body-style': 'error',
263+
'accessor-pairs': ['warn', {setWithoutGet: true}],
264+
'block-scoped-var': 'off',
265+
'callback-return': 'off',
266+
camelcase: ['off', {properties: 'always'}],
267+
complexity: 'off',
268+
'consistent-return': 'warn',
269+
'consistent-this': ['off', 'self'],
270+
'constructor-super': 'error',
271+
'default-case': 'off',
272+
'dot-notation': 'off',
273+
eqeqeq: ['off', 'allow-null'],
240274
'eslint-comments/disable-enable-pair': ['error', {allowWholeFile: true}],
241275
'eslint-comments/no-unused-disable': 'error',
242-
'flowtype/boolean-style': 'error',
243-
'flowtype/no-primitive-constructor-types': 'error',
244-
'flowtype/require-valid-file-annotation': 'error',
276+
'func-names': 'off',
277+
'func-style': ['off', 'declaration'],
278+
'global-require': 'off',
279+
'guard-for-in': 'off',
280+
'handle-callback-err': 'off',
281+
'id-length': 'off',
282+
'id-match': 'off',
245283
'import/no-duplicates': 'error',
246284
'import/no-extraneous-dependencies': [
247285
'error',
@@ -277,17 +315,153 @@ module.exports = {
277315
'newlines-between': 'never',
278316
},
279317
],
280-
'no-console': 'off',
318+
'init-declarations': 'off',
319+
'jest/no-focused-tests': 'error',
320+
'jest/no-identical-title': 'error',
321+
'jest/valid-expect': 'error',
322+
'lines-around-comment': 'off',
323+
'max-depth': 'off',
324+
'max-nested-callbacks': 'off',
325+
'max-params': 'off',
326+
'max-statements': 'off',
327+
'new-cap': 'off',
328+
'new-parens': 'error',
329+
'newline-after-var': 'off',
330+
'no-alert': 'off',
331+
'no-array-constructor': 'error',
332+
'no-bitwise': 'warn',
333+
'no-caller': 'error',
334+
'no-case-declarations': 'off',
335+
'no-catch-shadow': 'error',
336+
'no-class-assign': 'warn',
337+
'no-cond-assign': 'off',
338+
'no-confusing-arrow': 'off',
339+
'no-console': [
340+
'warn',
341+
{allow: ['warn', 'error', 'time', 'timeEnd', 'timeStamp']},
342+
],
343+
'no-const-assign': 'error',
344+
'no-constant-condition': 'off',
345+
'no-continue': 'off',
346+
'no-control-regex': 'off',
347+
'no-debugger': 'error',
348+
'no-delete-var': 'error',
349+
'no-div-regex': 'off',
350+
'no-dupe-args': 'error',
351+
'no-dupe-class-members': 'error',
352+
'no-dupe-keys': 'error',
353+
'no-duplicate-case': 'warn',
354+
'no-else-return': 'off',
355+
'no-empty': 'off',
356+
'no-empty-character-class': 'warn',
357+
'no-empty-pattern': 'warn',
358+
'no-eq-null': 'off',
359+
'no-eval': 'error',
360+
'no-ex-assign': 'warn',
361+
'no-extend-native': 'warn',
362+
'no-extra-bind': 'warn',
363+
'no-extra-boolean-cast': 'warn',
364+
'no-fallthrough': 'warn',
365+
'no-floating-decimal': 'error',
366+
'no-func-assign': 'error',
367+
'no-implicit-coercion': 'off',
368+
'no-implied-eval': 'error',
369+
'no-inline-comments': 'off',
370+
'no-inner-declarations': 'off',
371+
'no-invalid-regexp': 'warn',
372+
'no-invalid-this': 'off',
373+
'no-irregular-whitespace': 'error',
374+
'no-iterator': 'off',
375+
'no-label-var': 'warn',
376+
'no-labels': ['error', {allowLoop: true, allowSwitch: true}],
377+
'no-lonely-if': 'off',
378+
'no-loop-func': 'off',
379+
'no-magic-numbers': 'off',
380+
'no-mixed-requires': 'off',
381+
'no-mixed-spaces-and-tabs': 'error',
382+
'no-multi-str': 'error',
383+
'no-multiple-empty-lines': 'off',
384+
'no-native-reassign': ['error', {exceptions: ['Map', 'Set']}],
385+
'no-negated-condition': 'off',
386+
'no-negated-in-lhs': 'error',
387+
'no-nested-ternary': 'off',
388+
'no-new': 'warn',
389+
'no-new-func': 'error',
390+
'no-new-object': 'warn',
391+
'no-new-require': 'off',
392+
'no-new-wrappers': 'warn',
393+
'no-obj-calls': 'error',
394+
'no-octal': 'warn',
395+
'no-octal-escape': 'warn',
396+
'no-param-reassign': 'off',
397+
'no-path-concat': 'off',
398+
'no-plusplus': 'off',
399+
'no-process-env': 'off',
400+
'no-process-exit': 'off',
401+
'no-proto': 'error',
402+
'no-redeclare': 'warn',
403+
'no-regex-spaces': 'warn',
281404
'no-restricted-imports': [
282405
'error',
283-
{
284-
message: 'Please use graceful-fs instead.',
285-
name: 'fs',
286-
},
406+
{message: 'Please use graceful-fs instead.', name: 'fs'},
407+
],
408+
'no-restricted-modules': 'off',
409+
'no-restricted-syntax': 'off',
410+
'no-return-assign': 'off',
411+
'no-script-url': 'error',
412+
'no-self-compare': 'warn',
413+
'no-sequences': 'warn',
414+
'no-shadow': 'off',
415+
'no-shadow-restricted-names': 'warn',
416+
'no-sparse-arrays': 'error',
417+
'no-sync': 'off',
418+
'no-ternary': 'off',
419+
'no-this-before-super': 'error',
420+
'no-throw-literal': 'error',
421+
'no-undef': 'error',
422+
'no-undef-init': 'off',
423+
'no-undefined': 'off',
424+
'no-underscore-dangle': 'off',
425+
'no-unneeded-ternary': 'warn',
426+
'no-unreachable': 'error',
427+
'no-unused-expressions': 'off',
428+
'no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
429+
'no-use-before-define': 'off',
430+
'no-useless-call': 'warn',
431+
'no-useless-computed-key': 'error',
432+
'no-useless-concat': 'warn',
433+
'no-var': 'error',
434+
'no-void': 'off',
435+
'no-warn-comments': 'off',
436+
'no-with': 'off',
437+
'object-shorthand': 'error',
438+
'one-var': ['warn', {initialized: 'never'}],
439+
'operator-assignment': ['warn', 'always'],
440+
'operator-linebreak': 'off',
441+
'padded-blocks': 'off',
442+
'prefer-arrow-callback': ['error', {allowNamedFunctions: true}],
443+
'prefer-const': 'error',
444+
'prefer-template': 'off',
445+
quotes: [
446+
'error',
447+
'single',
448+
{allowTemplateLiterals: true, avoidEscape: true},
287449
],
288-
'no-unused-vars': 'error',
289-
'prettier/prettier': 'error',
450+
radix: 'warn',
451+
'require-jsdoc': 'off',
452+
'require-yield': 'off',
290453
'sort-imports': ['error', {ignoreDeclarationSort: true}],
454+
'sort-keys': 'error',
455+
'sort-vars': 'off',
456+
'spaced-comment': ['off', 'always', {exceptions: ['eslint', 'global']}],
457+
strict: 'off',
458+
'use-isnan': 'error',
459+
'valid-jsdoc': 'off',
460+
'valid-typeof': 'error',
461+
'vars-on-top': 'off',
462+
'wrap-iife': 'off',
463+
'wrap-regex': 'off',
464+
yoda: 'off',
291465
},
292466
settings: {
293467
'import/ignore': ['react-native'],

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

.yarn/releases/yarn-sources.cjs

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,50 @@
55
- `[jest-config]` [**BREAKING**] Default to Node testing environment instead of browser (JSDOM) ([#9874](https://github.com/facebook/jest/pull/9874))
66
- `[jest-config]` [**BREAKING**] Use `jest-circus` as default test runner ([#10686](https://github.com/facebook/jest/pull/10686))
77
- `[jest-config, jest-runtime]` Support ESM for files other than `.js` and `.mjs` ([#10823](https://github.com/facebook/jest/pull/10823))
8+
- `[jest-repl, jest-runner]` [**BREAKING**] Run transforms over environment ([#8751](https://github.com/facebook/jest/pull/8751))
89
- `[jest-runner]` [**BREAKING**] set exit code to 1 if test logs after teardown ([#10728](https://github.com/facebook/jest/pull/10728))
910
- `[jest-snapshot]`: [**BREAKING**] Make prettier optional for inline snapshots - fall back to string replacement ([#7792](https://github.com/facebook/jest/pull/7792))
10-
- `[jest-repl, jest-runner]` [**BREAKING**] Run transforms over environment ([#8751](https://github.com/facebook/jest/pull/8751))
11+
- `[jest-snapshot]` [**BREAKING**] Make prettier optional for inline snapshots - fall back to string replacement ([#7792](https://github.com/facebook/jest/pull/7792))
1112
- `[jest-runner]` [**BREAKING**] Run transforms over `runnner` ([#8823](https://github.com/facebook/jest/pull/8823))
1213
- `[jest-runner]` [**BREAKING**] Run transforms over `testRunnner` ([#8823](https://github.com/facebook/jest/pull/8823))
1314

1415
### Fixes
1516

17+
- `[babel-plugin-jest-hoist]` Add `__dirname` and `__filename` to whitelisted globals ([#10903](https://github.com/facebook/jest/pull/10903))
18+
- `[expect]` [**BREAKING**] Revise `expect.not.objectContaining()` to be the inverse of `expect.objectContaining()`, as documented. ([#10708](https://github.com/facebook/jest/pull/10708))
1619
- `[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)
1720
- `[jest-circus]` Fix `testLocation` on Windows when using `test.each` ([#10871](https://github.com/facebook/jest/pull/10871))
21+
- `[jest-console]` `console.dir` now respects the second argument correctly ([#10638](https://github.com/facebook/jest/pull/10638))
22+
- `[jest-environment-jsdom]` Use inner realm’s `ArrayBuffer` constructor ([#10885](https://github.com/facebook/jest/pull/10885))
1823
- `[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)
1924
- `[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)
20-
- `[jest-console]` `console.dir` now respects the second argument correctly ([#10638](https://github.com/facebook/jest/pull/10638))
21-
- `[expect]` [**BREAKING**] Revise `expect.not.objectContaining()` to be the inverse of `expect.objectContaining()`, as documented. ([#10708](https://github.com/facebook/jest/pull/10708))
2225
- `[jest-reporter]` Handle empty files when reporting code coverage with V8 ([#10819](https://github.com/facebook/jest/pull/10819))
2326
- `[jest-resolve]` Replace read-pkg-up with escalade package ([#10781](https://github.com/facebook/jest/pull/10781))
2427
- `[jest-resolve]` Disable `jest-pnp-resolver` for Yarn 2 ([#10847](https://github.com/facebook/jest/pull/10847))
2528
- `[jest-runtime]` [**BREAKING**] Do not inject `global` variable into module wrapper ([#10644](https://github.com/facebook/jest/pull/10644))
2629
- `[jest-runtime]` [**BREAKING**] remove long-deprecated `jest.addMatchers`, `jest.resetModuleRegistry`, and `jest.runTimersToTime` ([#9853](https://github.com/facebook/jest/pull/9853))
30+
- `[jest-runtime]` Fix stack overflow and promise deadlock when importing mutual dependant ES module ([#10892](https://github.com/facebook/jest/pull/10892))
2731
- `[jest-transform]` Show enhanced `SyntaxError` message for all `SyntaxError`s ([#10749](https://github.com/facebook/jest/pull/10749))
2832
- `[jest-transform]` [**BREAKING**] Refactor API to pass an options bag around rather than multiple boolean options ([#10753](https://github.com/facebook/jest/pull/10753))
2933
- `[jest-transform]` [**BREAKING**] Refactor API of transformers to pass an options bag rather than separate `config` and other options
34+
- `[pretty-format]` [**BREAKING**] Convert to ES Modules ([#10515](https://github.com/facebook/jest/pull/10515))
3035

3136
### Chore & Maintenance
3237

33-
- `[jest-console]` [**BREAKING**] Move `root` into `config` and take `GlobalConfig` as mandatory parameter for `getConsoleOutput` ([#10126](https://github.com/facebook/jest/pull/10126))
3438
- `[*]` [**BREAKING**] Only support Node LTS releases and Node 15 ([#10685](https://github.com/facebook/jest/pull/10685))
3539
- `[*]` [**BREAKING**] Add `exports` field to all `package.json`s ([#9921](https://github.com/facebook/jest/pull/9921))
3640
- `[*]` Make it easier for Jest's packages to use the VM escape hatch ([#10824](https://github.com/facebook/jest/pull/10824))
3741
- `[jest-config]` [**BREAKING**] Remove `enabledTestsMap` config, use `filter` instead ([#10787](https://github.com/facebook/jest/pull/10787))
38-
- `[jest-resolve]` [**BREAKING**] Migrate to ESM ([#10688](https://github.com/facebook/jest/pull/10688))
42+
- `[jest-console]` [**BREAKING**] Move `root` into `config` and take `GlobalConfig` as mandatory parameter for `getConsoleOutput` ([#10126](https://github.com/facebook/jest/pull/10126))
43+
- `[jest-fake-timers]` Clarify global behavior of `jest.useFakeTimers` and `jest.useRealTimers` ([#10867](https://github.com/facebook/jest/pull/10867))
44+
- `[jest-haste-map]` [**BREAKING**] Migrate to ESM ([#10875](https://github.com/facebook/jest/pull/10875))
45+
- `[jest-jasmine2]` [**BREAKING**] Migrate to ESM ([#10906](https://github.com/facebook/jest/pull/10906))
3946
- `[jest-repl, jest-runtime]` [**BREAKING**] Move the `jest-runtime` CLI into `jest-repl` ([#10016](https://github.com/facebook/jest/pull/10016))
47+
- `[jest-resolve]` [**BREAKING**] Migrate to ESM ([#10688](https://github.com/facebook/jest/pull/10688))
48+
- `[jest-resolve-dependencies]` [**BREAKING**] Migrate to ESM ([#10876](https://github.com/facebook/jest/pull/10876))
49+
- `[jest-mock]` [**BREAKING**] Migrate to ESM ([#10887](https://github.com/facebook/jest/pull/10887))
50+
- `[jest-runner]` [**BREAKING**] Migrate to ESM ([#10900](https://github.com/facebook/jest/pull/10900))
4051
- `[jest-util]` No longer checking `enumerable` when adding `process.domain` ([#10862](https://github.com/facebook/jest/pull/10862))
41-
- `[jest-fake-timers]` Clarify global behavior of `jest.useFakeTimers` and `jest.useRealTimers` ([#10867](https://github.com/facebook/jest/pull/10867))
4252

4353
### Performance
4454

docs/ExpectAPI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ It's also possible to create custom matchers for inline snapshots, the snapshots
239239
const {toMatchInlineSnapshot} = require('jest-snapshot');
240240

241241
expect.extend({
242-
toMatchTrimmedInlineSnapshot(received) {
243-
return toMatchInlineSnapshot.call(this, received.substring(0, 10));
242+
toMatchTrimmedInlineSnapshot(received, ...rest) {
243+
return toMatchInlineSnapshot.call(this, received.substring(0, 10), ...rest);
244244
},
245245
});
246246

docs/JestPlatform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Exports a function that converts any JavaScript value into a human-readable stri
160160
### Example
161161

162162
```javascript
163-
const prettyFormat = require('pretty-format');
163+
const {format: prettyFormat} = require('pretty-format');
164164

165165
const val = {object: {}};
166166
val.circularReference = val;

0 commit comments

Comments
 (0)