Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into uglier-inline-sna…
Browse files Browse the repository at this point in the history
…pshots

* upstream/master: (39 commits)
  Prints the Symbol name into the error message with a custom asymmetric matcher (jestjs#9888)
  Show coverage of sources related to tests in changed files (jestjs#9769)
  fix: don't /// <reference types="jest" /> (jestjs#9875)
  noCodeFrame respects noStackTrace (jestjs#9866)
  chore: update example to react-native@0.62 (jestjs#9746)
  Improve source map handling when instrumenting transformed code (jestjs#9811)
  Update .vscode/launch.json settings (jestjs#9868)
  chore: verify all packages have the same engine requirement (jestjs#9871)
  fix: pass custom cached realpath function to `resolve` (jestjs#9873)
  chore: mock stealthy-require in tests (jestjs#9855)
  chore: update resolve (jestjs#9872)
  chore: run CircleCI on node 14 (jestjs#9870)
  Add an option to vscode settings to always use workspace TS (jestjs#9869)
  fix(esm): handle parallel imports (jestjs#9858)
  chore: run CI on Node 14 (jestjs#9861)
  feat: add `@jest/globals` package for importing globals explici… (jestjs#9849)
  chore: bump resolve package (jestjs#9859)
  chore(runtime): simplify `createJestObjectFor` (jestjs#9857)
  chore: fix symlink creation failures on windows in tests (jestjs#9852)
  chore: skip mercurial tests when no hg installed (jestjs#9840)
  ...
  • Loading branch information
jeysal committed Apr 26, 2020
2 parents dae5678 + d814646 commit 78edd86
Show file tree
Hide file tree
Showing 200 changed files with 2,846 additions and 1,055 deletions.
17 changes: 16 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ jobs:
- store_test_results:
path: reports/junit

test-node-14:
working_directory: ~/jest
docker:
- image: circleci/node:14
steps:
- checkout
- restore-cache: *restore-cache
- run: *install
- save-cache: *save-cache
- run:
command: yarn test-ci-partial
- store_test_results:
path: reports/junit

test-browser:
working_directory: ~/jest
docker:
Expand Down Expand Up @@ -123,7 +137,8 @@ workflows:
- test-node-8
- test-node-10
- test-node-12
- test-node-13 # current
- test-node-13
- test-node-14 # current
- test-jest-circus
- test-browser
- test-or-deploy-website:
Expand Down
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module.exports = {
'**/__mocks__/**',
'**/?(*.)(spec|test).js?(x)',
'scripts/**',
'eslintImportResolver.js',
'babel.config.js',
'testSetupFile.js',
],
},
Expand All @@ -146,4 +146,7 @@ module.exports = {
'prettier/prettier': 2,
'sort-imports': [2, {ignoreDeclarationSort: true}],
},
settings: {
'import/ignore': ['react-native'],
},
};
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
fail-fast: false
matrix:
# https://github.com/actions/setup-node/issues/27
node-version: [8.17.0, 10.x, 12.x, 13.x]
node-version: [8.17.0, 10.x, 12.x, 13.x, 14.x]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}

Expand Down
13 changes: 9 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
{
"type": "node",
"request": "launch",
"name": "Debug Jest with current test file",
"program": "${workspaceFolder}/packages/jest-cli/bin/jest.js",
"args": ["--runInBand", "${file}"],
"runtimeArgs": ["-r", "flow-remove-types/register"]
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["${fileBasenameNoExtension}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
}
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"jest.pathToJest": "yarn jest --",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
},
"typescript.tsdk": "node_modules/typescript/lib"
}
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,45 @@
### Features

- `[@jest/globals]` New package so Jest's globals can be explicitly imported ([#9801](https://github.com/facebook/jest/pull/9801))
- `[jest-core]` Show coverage of sources related to tests in changed files ([#9769](https://github.com/facebook/jest/pull/9769))
- `[jest-runtime]` Populate `require.cache` ([#9841](https://github.com/facebook/jest/pull/9841))
- `[jest-snapshot]`: Make prettier optional for inline snapshots - fall back to string replacement ([#7792](https://github.com/facebook/jest/pull/7792))

### Fixes

- `[expect]` Prints the Symbol name into the error message with a custom asymmetric matcher ([#9888](https://github.com/facebook/jest/pull/9888))
- `[@jest/environment]` Make sure not to reference Jest types ([#9875](https://github.com/facebook/jest/pull/9875))
- `[jest-message-util]` Code frame printing should respect `--noStackTrace` flag ([#9866](https://github.com/facebook/jest/pull/9866))
- `[jest-runtime]` Support importing CJS from ESM using `import` statements ([#9850](https://github.com/facebook/jest/pull/9850))
- `[jest-runtime]` Support importing parallel dynamic `import`s ([#9858](https://github.com/facebook/jest/pull/9858))
- `[jest-transform]` Improve source map handling when instrumenting transformed code ([#9811](https://github.com/facebook/jest/pull/9811))

### Chore & Maintenance

### Performance

- `[jest-resolve]` Update `resolve` to a version using native `realpath`, which is faster than the default JS implementation ([#9872](https://github.com/facebook/jest/pull/9872))
- `[jest-resolve]` Pass custom cached `realpath` function to `resolve` ([#9873](https://github.com/facebook/jest/pull/9873))

## 25.4.0

- `[expect]` Support `async function`s in `toThrow` ([#9817](https://github.com/facebook/jest/pull/9817))
- `[jest-console]` Add code frame to `console.error` and `console.warn` ([#9741](https://github.com/facebook/jest/pull/9741))
- `[jest-runtime, jest-jasmine2, jest-circus]` Experimental, limited ECMAScript Modules support ([#9772](https://github.com/facebook/jest/pull/9772) & [#9842](https://github.com/facebook/jest/pull/9842))

### Fixes

- `[expect]` Restore support for passing functions to `toHaveLength` matcher ([#9796](https://github.com/facebook/jest/pull/9796))
- `[jest-changed-files]` `--only-changed` should include staged files ([#9799](https://github.com/facebook/jest/pull/9799))
- `[jest-circus]` Throw on nested test definitions ([#9828](https://github.com/facebook/jest/pull/9828))
- `[jest-each]` `each` will throw an error when called with too many arguments ([#9818](https://github.com/facebook/jest/pull/9818))
- `[jest-runner]` Don't print warning to stdout when using `--json` ([#9843](https://github.com/facebook/jest/pull/9843))

### Chore & Maintenance

- `[*]` Do not generate TypeScript declaration source maps ([#9822](https://github.com/facebook/jest/pull/9822))
- `[*]` Transpile code for Node 8.3, not 8.0 ([#9827](https://github.com/facebook/jest/pull/9827))

### Performance

## 25.3.0
Expand Down
11 changes: 8 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

const semver = require('semver');
const pkg = require('./package.json');

const supportedNodeVersion = semver.minVersion(pkg.engines.node).version;

module.exports = {
babelrcRoots: ['examples/*'],
// we don't wanna run the transforms in this file over react native
Expand All @@ -15,7 +20,7 @@ module.exports = {
'babel-plugin-typescript-strip-namespaces',
'babel-plugin-replace-ts-export-assignment',
require.resolve(
'./scripts/babel-plugin-jest-replace-ts-require-assignment.js'
'./scripts/babel-plugin-jest-replace-ts-require-assignment.js',
),
],
presets: ['@babel/preset-typescript'],
Expand All @@ -31,7 +36,7 @@ module.exports = {
{
exclude: ['@babel/plugin-proposal-dynamic-import'],
shippedProposals: true,
targets: {node: 8},
targets: {node: supportedNodeVersion},
},
],
],
Expand All @@ -48,7 +53,7 @@ module.exports = {
'@babel/preset-env',
{
shippedProposals: true,
targets: {node: 8},
targets: {node: supportedNodeVersion},
},
],
],
Expand Down
2 changes: 1 addition & 1 deletion docs/JestPlatform.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ You can read more about `jest-validate` in the [readme file](https://github.com/

## jest-worker

Module used for parallelization of tasks. Exports a class `Worker` that takes the path of Node.js module and lets you call the module's exported methods as if they were class methods, returning a promise that resolves when the specified method finishes its execution in a forked process.
Module used for parallelization of tasks. Exports a class `JestWorker` that takes the path of Node.js module and lets you call the module's exported methods as if they were class methods, returning a promise that resolves when the specified method finishes its execution in a forked process.

### Example

Expand Down
20 changes: 19 additions & 1 deletion e2e/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {ExecaReturnValue, sync as spawnSync} from 'execa';
import makeDir = require('make-dir');
import rimraf = require('rimraf');
import dedent = require('dedent');
import which = require('which');

interface RunResult extends ExecaReturnValue {
status: number;
Expand Down Expand Up @@ -47,7 +48,7 @@ export const linkJestPackage = (packageName: string, cwd: Config.Path) => {
const destination = path.resolve(cwd, 'node_modules/', packageName);
makeDir.sync(destination);
rimraf.sync(destination);
fs.symlinkSync(packagePath, destination, 'dir');
fs.symlinkSync(packagePath, destination, 'junction');
};

export const makeTemplate = (
Expand Down Expand Up @@ -105,6 +106,7 @@ export const writeSymlinks = (
fs.symlinkSync(
path.resolve(directory, ...fileOrPath.split('/')),
path.resolve(directory, ...symLinkPath.split('/')),
'junction',
);
});
};
Expand Down Expand Up @@ -260,3 +262,19 @@ export const normalizeIcons = (str: string) => {
.replace(new RegExp('\u00D7', 'g'), '\u2715')
.replace(new RegExp('\u221A', 'g'), '\u2713');
};

// Certain environments (like CITGM and GH Actions) do not come with mercurial installed
let hgIsInstalled: boolean | null = null;

export const testIfHg = (...args: Parameters<typeof test>) => {
if (hgIsInstalled === null) {
hgIsInstalled = which.sync('hg', {nothrow: true}) !== null;
}

if (hgIsInstalled) {
test(...args);
} else {
console.warn('Mercurial (hg) is not installed - skipping some tests');
test.skip(...args);
}
};
20 changes: 15 additions & 5 deletions e2e/__tests__/__snapshots__/beforeAllFiltered.ts.snap
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Correct BeforeAll run ensures the BeforeAll of ignored suite is not run 1`] = `
console.log __tests__/beforeAllFiltered.test.js:10
console.log
beforeAll 1
console.log __tests__/beforeAllFiltered.test.js:13
at log (__tests__/beforeAllFiltered.test.js:10:13)
console.log
beforeEach 1
console.log __tests__/beforeAllFiltered.test.js:22
at log (__tests__/beforeAllFiltered.test.js:13:13)
console.log
It Foo
console.log __tests__/beforeAllFiltered.test.js:16
at log (__tests__/beforeAllFiltered.test.js:22:13)
console.log
afterEach 1
console.log __tests__/beforeAllFiltered.test.js:19
at log (__tests__/beforeAllFiltered.test.js:16:13)
console.log
afterAll 1
at log (__tests__/beforeAllFiltered.test.js:19:13)
`;
20 changes: 15 additions & 5 deletions e2e/__tests__/__snapshots__/beforeEachQueue.ts.snap
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Correct beforeEach order ensures the correct order for beforeEach 1`] = `
console.log __tests__/beforeEachQueue.test.js:10
console.log
BeforeEach
console.log __tests__/beforeEachQueue.test.js:14
at Object.log (__tests__/beforeEachQueue.test.js:10:13)
console.log
It Foo
console.log __tests__/beforeEachQueue.test.js:17
at Object.log (__tests__/beforeEachQueue.test.js:14:13)
console.log
BeforeEach Inline Foo
console.log __tests__/beforeEachQueue.test.js:10
at Object.log (__tests__/beforeEachQueue.test.js:17:15)
console.log
BeforeEach
console.log __tests__/beforeEachQueue.test.js:22
at Object.log (__tests__/beforeEachQueue.test.js:10:13)
console.log
It Bar
at Object.log (__tests__/beforeEachQueue.test.js:22:13)
`;
Loading

0 comments on commit 78edd86

Please sign in to comment.