Skip to content

Commit

Permalink
Merge branch 'master' into fix/transformed-sourcemap
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 8, 2020
2 parents 3e5449e + bb45b8c commit d8c9883
Show file tree
Hide file tree
Showing 145 changed files with 4,670 additions and 1,582 deletions.
2 changes: 2 additions & 0 deletions .eslintplugin/index.js
Expand Up @@ -9,4 +9,6 @@ exports.rules = {
'ban-types-eventually': require('@typescript-eslint/eslint-plugin').rules[
'ban-types'
],
'prefer-rest-params-eventually': require('eslint/lib/rules/prefer-rest-params'),
'prefer-spread-eventually': require('eslint/lib/rules/prefer-spread'),
};
35 changes: 34 additions & 1 deletion .eslintrc.js
Expand Up @@ -32,8 +32,41 @@ module.exports = {
'import/default': 'off',
'no-dupe-class-members': 'off',
'no-unused-vars': 'off',
// TODO: turn these on at some point
},
},
{
files: [
'packages/jest-jasmine2/src/jasmine/Env.ts',
'packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts',
'packages/jest-jasmine2/src/jasmine/Spec.ts',
'packages/jest-jasmine2/src/jasmine/SpyStrategy.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-jasmine2/src/jasmine/createSpy.ts',
'packages/jest-jasmine2/src/jasmine/jasmineLight.ts',
'packages/jest-mock/src/__tests__/index.test.ts',
'packages/jest-mock/src/index.ts',
'packages/pretty-format/src/__tests__/Immutable.test.ts',
'packages/pretty-format/src/__tests__/prettyFormat.test.ts',
],
rules: {
'local/prefer-rest-params-eventually': 'warn',
'prefer-rest-params': 'off',
},
},
{
files: [
'packages/expect/src/index.ts',
'packages/jest-fake-timers/src/legacyFakeTimers.ts',
'packages/jest-jasmine2/src/jasmine/Env.ts',
'packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts',
'packages/jest-jasmine2/src/jasmine/Spec.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-jasmine2/src/jasmine/jasmineLight.ts',
'packages/jest-jasmine2/src/jestExpect.ts',
'packages/jest-resolve/src/index.ts',
],
rules: {
'local/prefer-spread-eventually': 'warn',
'prefer-spread': 'off',
},
},
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Expand Up @@ -32,7 +32,7 @@ jobs:
key: ubuntu-latest-node-12.x-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
ubuntu-latest-node-12.x-yarn-
- uses: actions/setup-node@v2.1.1
- uses: actions/setup-node@v2.1.2
with:
node-version: 12.x
- name: install
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
restore-keys: |
${{ runner.os }}-node-${{ matrix.node-version }}-yarn-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.1.1
uses: actions/setup-node@v2.1.2
with:
node-version: ${{ matrix.node-version }}
- name: install
Expand Down
1 change: 1 addition & 0 deletions .watchmanconfig
@@ -0,0 +1 @@
[]
2 changes: 1 addition & 1 deletion .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions .yarn/releases/yarn-2.3.1.cjs

Large diffs are not rendered by default.

55 changes: 0 additions & 55 deletions .yarn/releases/yarn-sources.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .yarnrc
Expand Up @@ -3,4 +3,4 @@


lastUpdateCheck 1576854265612
yarn-path ".yarn/releases/yarn-sources.cjs"
yarn-path ".yarn/releases/yarn-2.3.1.cjs"
2 changes: 1 addition & 1 deletion .yarnrc.yml
Expand Up @@ -6,4 +6,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'

yarnPath: .yarn/releases/yarn-sources.cjs
yarnPath: .yarn/releases/yarn-2.3.1.cjs
35 changes: 33 additions & 2 deletions CHANGELOG.md
Expand Up @@ -2,19 +2,50 @@

### Features

### Fixes

- `[jest-transform]` Fix source mapping of transformed code in the debugger ([#10534](https://github.com/facebook/jest/pull/10534))
- `[jest-validate]` Show suggestion only when unrecognized cli param is longer than 1 character ([#10604](https://github.com/facebook/jest/pull/10604))
- `[jest-validate]` Validate `testURL` as CLI option ([#10595](https://github.com/facebook/jest/pull/10595))

### Chore & Maintenance

### Performance

## 26.5.2

### Fixes

- `[*]` Revert usage of Escalade and rollback Yargs to v15 as it breaks Node 13 ([#10599](https://github.com/facebook/jest/pull/10599))
- `[jest-circus]` Setup globals before emitting `setup`, and include Jest globals in the `setup` payload ([#10598](https://github.com/facebook/jest/pull/10598))
- `[jest-mock]` Fix typings for `mockResolvedValue`, `mockResolvedValueOnce`, `mockRejectedValue` and `mockRejectedValueOnce` ([#10600](https://github.com/facebook/jest/pull/10600))

## 26.5.1

### Fixes

- `[jest-circus]` Handle older `jest-runtime` in `jest-circus`

## 26.5.0

### Features

- `[jest-circus, jest-config, jest-runtime]` Add new `injectGlobals` config and CLI option to disable injecting global variables into the runtime ([#10484](https://github.com/facebook/jest/pull/10484))
- `[jest-each]` Fixes `.each` type to always be callable ([#10447](https://github.com/facebook/jest/pull/10447))
- `[jest-runner]` Add support for `moduleLoader`s with `default` exports ([#10541](https://github.com/facebook/jest/pull/10541))
- `[@jest/create-cache-key-function]` Added a new package for creating cache keys ([#10587](https://github.com/facebook/jest/pull/10587))

### Fixes

- `[jest-circus, jest-jasmine2]` Find correct location for `test.each` tests ([#10413](https://github.com/facebook/jest/pull/10413))
- `[jest-console]` Add `Console` constructor to `console` object ([#10502](https://github.com/facebook/jest/pull/10502))
- `[jest-globals]` Fix lifecycle hook function types ([#10480](https://github.com/facebook/jest/pull/10480))
- `[jest-transform]` Fix source mapping of transformed code in the debugger ([#10534](https://github.com/facebook/jest/pull/10534))
- `[jest-runtime]` Remove usage of `vm.compileFunction` due to a performance issue ([#10586](https://github.com/facebook/jest/pull/10586))

### Chore & Maintenance

### Performance
- `[jest-resolve]` Replace read-pkg-up with escalade package ([10558](https://github.com/facebook/jest/pull/10558))
- `[jest-environment-jsdom]` Update jsdom to 16.4.0 ([10578](https://github.com/facebook/jest/pull/10578))

## 26.4.2

Expand Down
1 change: 1 addition & 0 deletions TestUtils.ts
Expand Up @@ -83,6 +83,7 @@ const DEFAULT_PROJECT_CONFIG: Config.ProjectConfig = {
globalTeardown: undefined,
globals: {},
haste: {},
injectGlobals: true,
moduleDirectories: [],
moduleFileExtensions: ['js'],
moduleLoader: '/test_module_loader_path',
Expand Down
8 changes: 8 additions & 0 deletions docs/Configuration.md
Expand Up @@ -1032,6 +1032,14 @@ Default: `{}`

Test environment options that will be passed to the `testEnvironment`. The relevant options depend on the environment. For example you can override options given to [jsdom](https://github.com/jsdom/jsdom) such as `{userAgent: "Agent/007"}`.

### `testFailureExitCode` [number]

Default: `1`

The exit code Jest returns on test failure.

_Note: This does not change the exit code in the case of Jest errors (e.g. invalid configuration)._

### `testMatch` [array\<string>]

(default: `[ "**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)" ]`)
Expand Down
2 changes: 1 addition & 1 deletion docs/GettingStarted.md
Expand Up @@ -9,7 +9,7 @@ Install Jest using [`yarn`](https://yarnpkg.com/en/package/jest):
yarn add --dev jest
```

Or [`npm`](https://www.npmjs.com/):
Or [`npm`](https://www.npmjs.com/package/jest):

```bash
npm install --save-dev jest
Expand Down
2 changes: 1 addition & 1 deletion docs/GlobalAPI.md
Expand Up @@ -471,7 +471,7 @@ Also under the alias: `it.concurrent(name, fn, timeout)`

Use `test.concurrent` if you want the test to run concurrently.

> Note: `test.concurrent` is considered experimental - see [here])https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues
> Note: `test.concurrent` is considered experimental - see [here](https://github.com/facebook/jest/labels/Area%3A%20Concurrent) for details on missing features and other issues
The first argument is the test name; the second argument is an asynchronous function that contains the expectations to test. The third argument (optional) is `timeout` (in milliseconds) for specifying how long to wait before aborting. _Note: The default timeout is 5 seconds._

Expand Down
Expand Up @@ -20,6 +20,6 @@ exports[`prints console.logs when run with forceExit 3`] = `
console.log
Hey
at Object.log (__tests__/a-banana.js:1:30)
at Object.<anonymous> (__tests__/a-banana.js:1:1)
`;
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/globals.test.ts.snap
Expand Up @@ -24,9 +24,9 @@ FAIL __tests__/onlyConstructs.test.js
Missing second argument. It must be a callback function.
> 1 | describe('describe, no implementation');
| ^
| ^
at Object.describe (__tests__/onlyConstructs.test.js:1:1)
at Object.<anonymous> (__tests__/onlyConstructs.test.js:1:10)
`;
exports[`cannot have describe with no implementation 2`] = `
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`on node ^12.16.0 || >=13.2.0 runs test with native ESM 1`] = `
exports[`on node ^12.16.0 || >=13.7.0 runs test with native ESM 1`] = `
Test Suites: 1 passed, 1 total
Tests: 12 passed, 12 total
Snapshots: 0 total
Expand Down
16 changes: 15 additions & 1 deletion e2e/__tests__/consoleLogOutputWhenRunInBand.test.ts
Expand Up @@ -15,6 +15,8 @@ const DIR = path.resolve(__dirname, '../console-log-output-when-run-in-band');
beforeEach(() => cleanup(DIR));
afterAll(() => cleanup(DIR));

const nodeMajorVersion = Number(process.versions.node.split('.')[0]);

test('prints console.logs when run with forceExit', () => {
writeFiles(DIR, {
'__tests__/a-banana.js': `
Expand All @@ -23,14 +25,26 @@ test('prints console.logs when run with forceExit', () => {
'package.json': '{}',
});

const {stderr, stdout, exitCode} = runJest(DIR, [
const {stderr, exitCode, ...res} = runJest(DIR, [
'-i',
'--ci=false',
'--forceExit',
]);
let {stdout} = res;

const {rest, summary} = extractSummary(stderr);

if (nodeMajorVersion < 12) {
expect(stdout).toContain(
'at Object.<anonymous>.test (__tests__/a-banana.js:1:1)',
);

stdout = stdout.replace(
'at Object.<anonymous>.test (__tests__/a-banana.js:1:1)',
'at Object.<anonymous> (__tests__/a-banana.js:1:1)',
);
}

expect(exitCode).toBe(0);
expect(wrap(rest)).toMatchSnapshot();
expect(wrap(summary)).toMatchSnapshot();
Expand Down
24 changes: 9 additions & 15 deletions e2e/__tests__/errorOnDeprecated.test.ts
Expand Up @@ -43,24 +43,18 @@ testFiles.forEach(testFile => {
expect(result.exitCode).toBe(1);
let {rest} = extractSummary(result.stderr);

if (testFile === 'defaultTimeoutInterval.test.js') {
if (
nodeMajorVersion < 12 &&
testFile === 'defaultTimeoutInterval.test.js'
) {
const lineEntry = '(__tests__/defaultTimeoutInterval.test.js:10:3)';

if (nodeMajorVersion < 10) {
expect(rest).toContain(`at Object.<anonymous>.test ${lineEntry}`);
expect(rest).toContain(`at Object.<anonymous>.test ${lineEntry}`);

rest = rest.replace(
`at Object.<anonymous>.test ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
} else if (nodeMajorVersion < 12) {
expect(rest).toContain(`at Object.test ${lineEntry}`);

rest = rest.replace(
`at Object.test ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
}
rest = rest.replace(
`at Object.<anonymous>.test ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
}

expect(wrap(rest)).toMatchSnapshot();
Expand Down
11 changes: 1 addition & 10 deletions e2e/__tests__/failures.test.ts
Expand Up @@ -39,7 +39,7 @@ test('not throwing Error objects', () => {
expect(wrap(cleanStderr(stderr))).toMatchSnapshot();
stderr = runJest(dir, ['duringTests.test.js']).stderr;

if (nodeMajorVersion < 10) {
if (nodeMajorVersion < 12) {
const lineEntry = '(__tests__/duringTests.test.js:38:8)';

expect(stderr).toContain(`at Object.<anonymous>.done ${lineEntry}`);
Expand All @@ -48,15 +48,6 @@ test('not throwing Error objects', () => {
`at Object.<anonymous>.done ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
} else if (nodeMajorVersion < 12) {
const lineEntry = '(__tests__/duringTests.test.js:38:8)';

expect(stderr).toContain(`at Object.done ${lineEntry}`);

stderr = stderr.replace(
`at Object.done ${lineEntry}`,
`at Object.<anonymous> ${lineEntry}`,
);
}

expect(wrap(cleanStderr(stderr))).toMatchSnapshot();
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/nativeEsm.test.ts
Expand Up @@ -20,8 +20,8 @@ test('test config is without transform', () => {
expect(configs[0].transform).toEqual([]);
});

// The versions vm.Module was introduced
onNodeVersions('^12.16.0 || >=13.2.0', () => {
// The versions where vm.Module exists and commonjs with "exports" is not broken
onNodeVersions('^12.16.0 || >=13.7.0', () => {
test('runs test with native ESM', () => {
const {exitCode, stderr, stdout} = runJest(DIR, [], {
nodeOptions: '--experimental-vm-modules',
Expand Down

0 comments on commit d8c9883

Please sign in to comment.