Skip to content

Commit

Permalink
Merge branch 'master' into support-non-js-esm
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Dec 4, 2020
2 parents e8f3cc4 + fe144ea commit f5c4429
Show file tree
Hide file tree
Showing 91 changed files with 810 additions and 719 deletions.
234 changes: 204 additions & 30 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ const internalPackages = getPackages()
.sort();

module.exports = {
env: {
'jest/globals': true,
node: true,
},
extends: [
'fb-strict',
'plugin:import/errors',
'plugin:import/typescript',
'prettier',
'prettier/flowtype',
'plugin:eslint-comments/recommended',
],
overrides: [
{
extends: ['plugin:@typescript-eslint/eslint-recommended'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:import/typescript',
'prettier/@typescript-eslint',
],
files: ['*.ts', '*.tsx'],
plugins: ['@typescript-eslint/eslint-plugin', 'local'],
rules: {
Expand Down Expand Up @@ -139,34 +144,22 @@ module.exports = {
rules: {
'arrow-body-style': 'off',
'consistent-return': 'off',
'flowtype/require-valid-file-annotation': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
'jest/valid-expect': 'off',
'no-console': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'off',
'react/jsx-no-undef': 'off',
'react/react-in-jsx-scope': 'off',
'sort-keys': 'off',
},
},
{
files: ['examples/**/*'],
rules: {
'babel/func-params-comma-dangle': 'off',
'import/no-unresolved': ['error', {ignore: ['^react-native$']}],
'import/order': 'off',
},
},
{
files: ['scripts/**/*', 'e2e/**/*'],
rules: {
'babel/func-params-comma-dangle': 'off',
},
},
{
files: 'packages/jest-types/**/*',
rules: {
Expand Down Expand Up @@ -225,23 +218,68 @@ module.exports = {
},
},
{
files: ['test-types/*.test.ts'],
files: ['test-types/*.test.ts', '*.md'],
rules: {
'jest/no-focused-tests': 'off',
'jest/no-identical-title': 'off',
'jest/valid-expect': 'off',
},
},
{
files: [
'scripts/*',
'packages/jest-cli/src/init/index.ts',
'packages/jest-repl/src/cli/runtime-cli.ts',
],
rules: {
'no-console': 'off',
},
},
{
files: [
'e2e/**',
'examples/**',
'scripts/*',
'website/**',
'**/__mocks__/**',
'**/__tests__/**',
'**/__performance_tests__/**',
'packages/diff-sequences/perf/index.js',
'packages/pretty-format/perf/test.js'
],
rules: {
'import/no-unresolved': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
},
},
],
parser: '@typescript-eslint/parser',
plugins: ['markdown', 'import', 'prettier', 'eslint-comments'],
parserOptions: {
sourceType: 'module',
},
plugins: ['markdown', 'import', 'jest'],
rules: {
'arrow-body-style': 'error',
'accessor-pairs': ['warn', {setWithoutGet: true}],
'block-scoped-var': 'off',
'callback-return': 'off',
camelcase: ['off', {properties: 'always'}],
complexity: 'off',
'consistent-return': 'warn',
'consistent-this': ['off', 'self'],
'constructor-super': 'error',
'default-case': 'off',
'dot-notation': 'off',
eqeqeq: ['off', 'allow-null'],
'eslint-comments/disable-enable-pair': ['error', {allowWholeFile: true}],
'eslint-comments/no-unused-disable': 'error',
'flowtype/boolean-style': 'error',
'flowtype/no-primitive-constructor-types': 'error',
'flowtype/require-valid-file-annotation': 'error',
'func-names': 'off',
'func-style': ['off', 'declaration'],
'global-require': 'off',
'guard-for-in': 'off',
'handle-callback-err': 'off',
'id-length': 'off',
'id-match': 'off',
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': [
'error',
Expand Down Expand Up @@ -277,17 +315,153 @@ module.exports = {
'newlines-between': 'never',
},
],
'no-console': 'off',
'init-declarations': 'off',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/valid-expect': 'error',
'lines-around-comment': 'off',
'max-depth': 'off',
'max-nested-callbacks': 'off',
'max-params': 'off',
'max-statements': 'off',
'new-cap': 'off',
'new-parens': 'error',
'newline-after-var': 'off',
'no-alert': 'off',
'no-array-constructor': 'error',
'no-bitwise': 'warn',
'no-caller': 'error',
'no-case-declarations': 'off',
'no-catch-shadow': 'error',
'no-class-assign': 'warn',
'no-cond-assign': 'off',
'no-confusing-arrow': 'off',
'no-console': [
'warn',
{allow: ['warn', 'error', 'time', 'timeEnd', 'timeStamp']},
],
'no-const-assign': 'error',
'no-constant-condition': 'off',
'no-continue': 'off',
'no-control-regex': 'off',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-div-regex': 'off',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'warn',
'no-else-return': 'off',
'no-empty': 'off',
'no-empty-character-class': 'warn',
'no-empty-pattern': 'warn',
'no-eq-null': 'off',
'no-eval': 'error',
'no-ex-assign': 'warn',
'no-extend-native': 'warn',
'no-extra-bind': 'warn',
'no-extra-boolean-cast': 'warn',
'no-fallthrough': 'warn',
'no-floating-decimal': 'error',
'no-func-assign': 'error',
'no-implicit-coercion': 'off',
'no-implied-eval': 'error',
'no-inline-comments': 'off',
'no-inner-declarations': 'off',
'no-invalid-regexp': 'warn',
'no-invalid-this': 'off',
'no-irregular-whitespace': 'error',
'no-iterator': 'off',
'no-label-var': 'warn',
'no-labels': ['error', {allowLoop: true, allowSwitch: true}],
'no-lonely-if': 'off',
'no-loop-func': 'off',
'no-magic-numbers': 'off',
'no-mixed-requires': 'off',
'no-mixed-spaces-and-tabs': 'error',
'no-multi-str': 'error',
'no-multiple-empty-lines': 'off',
'no-native-reassign': ['error', {exceptions: ['Map', 'Set']}],
'no-negated-condition': 'off',
'no-negated-in-lhs': 'error',
'no-nested-ternary': 'off',
'no-new': 'warn',
'no-new-func': 'error',
'no-new-object': 'warn',
'no-new-require': 'off',
'no-new-wrappers': 'warn',
'no-obj-calls': 'error',
'no-octal': 'warn',
'no-octal-escape': 'warn',
'no-param-reassign': 'off',
'no-path-concat': 'off',
'no-plusplus': 'off',
'no-process-env': 'off',
'no-process-exit': 'off',
'no-proto': 'error',
'no-redeclare': 'warn',
'no-regex-spaces': 'warn',
'no-restricted-imports': [
'error',
{
message: 'Please use graceful-fs instead.',
name: 'fs',
},
{message: 'Please use graceful-fs instead.', name: 'fs'},
],
'no-restricted-modules': 'off',
'no-restricted-syntax': 'off',
'no-return-assign': 'off',
'no-script-url': 'error',
'no-self-compare': 'warn',
'no-sequences': 'warn',
'no-shadow': 'off',
'no-shadow-restricted-names': 'warn',
'no-sparse-arrays': 'error',
'no-sync': 'off',
'no-ternary': 'off',
'no-this-before-super': 'error',
'no-throw-literal': 'error',
'no-undef': 'error',
'no-undef-init': 'off',
'no-undefined': 'off',
'no-underscore-dangle': 'off',
'no-unneeded-ternary': 'warn',
'no-unreachable': 'error',
'no-unused-expressions': 'off',
'no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
'no-use-before-define': 'off',
'no-useless-call': 'warn',
'no-useless-computed-key': 'error',
'no-useless-concat': 'warn',
'no-var': 'error',
'no-void': 'off',
'no-warn-comments': 'off',
'no-with': 'off',
'object-shorthand': 'error',
'one-var': ['warn', {initialized: 'never'}],
'operator-assignment': ['warn', 'always'],
'operator-linebreak': 'off',
'padded-blocks': 'off',
'prefer-arrow-callback': ['error', {allowNamedFunctions: true}],
'prefer-const': 'error',
'prefer-template': 'off',
quotes: [
'error',
'single',
{allowTemplateLiterals: true, avoidEscape: true},
],
'no-unused-vars': 'error',
'prettier/prettier': 'error',
radix: 'warn',
'require-jsdoc': 'off',
'require-yield': 'off',
'sort-imports': ['error', {ignoreDeclarationSort: true}],
'sort-keys': 'error',
'sort-vars': 'off',
'spaced-comment': ['off', 'always', {exceptions: ['eslint', 'global']}],
strict: 'off',
'use-isnan': 'error',
'valid-jsdoc': 'off',
'valid-typeof': 'error',
'vars-on-top': 'off',
'wrap-iife': 'off',
'wrap-regex': 'off',
yoda: 'off',
},
settings: {
'import/ignore': ['react-native'],
Expand Down
2 changes: 1 addition & 1 deletion .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .yarn/releases/yarn-sources.cjs

Large diffs are not rendered by default.

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

### Fixes

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

### Chore & Maintenance

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

### Performance

Expand Down
4 changes: 2 additions & 2 deletions docs/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ It's also possible to create custom matchers for inline snapshots, the snapshots
const {toMatchInlineSnapshot} = require('jest-snapshot');

expect.extend({
toMatchTrimmedInlineSnapshot(received) {
return toMatchInlineSnapshot.call(this, received.substring(0, 10));
toMatchTrimmedInlineSnapshot(received, ...rest) {
return toMatchInlineSnapshot.call(this, received.substring(0, 10), ...rest);
},
});

Expand Down
2 changes: 1 addition & 1 deletion docs/JestPlatform.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Exports a function that converts any JavaScript value into a human-readable stri
### Example

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

const val = {object: {}};
val.circularReference = val;
Expand Down
Loading

0 comments on commit f5c4429

Please sign in to comment.