Skip to content

Commit

Permalink
Merge branch 'master' into uglier-inline-snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Apr 12, 2020
2 parents 81f12a4 + f215902 commit dae5678
Show file tree
Hide file tree
Showing 81 changed files with 6,082 additions and 2,819 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines-steps.yml
Expand Up @@ -6,7 +6,7 @@ steps:
- checkout: self
path: jest

# Ensure Node.js 10 is active
# Ensure Node.js 12 is active
- task: NodeTool@0
inputs:
versionSpec: '12.x'
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -39,3 +39,8 @@ yarn-error.log*
junit.xml

*.tsbuildinfo

.pnp.js
.yarn/unplugged/
.yarn/build-state.yml
e2e/async-regenerator/.yarn/
47 changes: 34 additions & 13 deletions .yarn/releases/yarn-1.22.0.js → .yarn/releases/yarn-1.22.4.js
Expand Up @@ -34805,15 +34805,27 @@ function hasMergeConflicts(str) {
function parse(str, fileLoc) {
const parser = new Parser(str, fileLoc);
parser.next();
try {
return parser.parse();
} catch (error1) {

if (!fileLoc.endsWith(`.yml`)) {
try {
return safeLoad(str, {
schema: FAILSAFE_SCHEMA
});
} catch (error2) {
throw error1;
return parser.parse();
} catch (error1) {
try {
return safeLoad(str, {
schema: FAILSAFE_SCHEMA
});
} catch (error2) {
throw error1;
}
}
} else {
const result = safeLoad(str, {
schema: FAILSAFE_SCHEMA
});
if (typeof result === 'object') {
return result;
} else {
return {};
}
}
}
Expand Down Expand Up @@ -46666,7 +46678,7 @@ function mkdirfix (name, opts, cb) {
/* 194 */
/***/ (function(module, exports) {

module.exports = {"name":"yarn","installationMethod":"unknown","version":"1.22.0","license":"BSD-2-Clause","preferGlobal":true,"description":"📦🐈 Fast, reliable, and secure dependency management.","dependencies":{"@zkochan/cmd-shim":"^3.1.0","babel-runtime":"^6.26.0","bytes":"^3.0.0","camelcase":"^4.0.0","chalk":"^2.1.0","cli-table3":"^0.4.0","commander":"^2.9.0","death":"^1.0.0","debug":"^3.0.0","deep-equal":"^1.0.1","detect-indent":"^5.0.0","dnscache":"^1.0.1","glob":"^7.1.1","gunzip-maybe":"^1.4.0","hash-for-dep":"^1.2.3","imports-loader":"^0.8.0","ini":"^1.3.4","inquirer":"^6.2.0","invariant":"^2.2.0","is-builtin-module":"^2.0.0","is-ci":"^1.0.10","is-webpack-bundle":"^1.0.0","js-yaml":"^3.13.1","leven":"^2.0.0","loud-rejection":"^1.2.0","micromatch":"^2.3.11","mkdirp":"^0.5.1","node-emoji":"^1.6.1","normalize-url":"^2.0.0","npm-logical-tree":"^1.2.1","object-path":"^0.11.2","proper-lockfile":"^2.0.0","puka":"^1.0.0","read":"^1.0.7","request":"^2.87.0","request-capture-har":"^1.2.2","rimraf":"^2.5.0","semver":"^5.1.0","ssri":"^5.3.0","strip-ansi":"^4.0.0","strip-bom":"^3.0.0","tar-fs":"^1.16.0","tar-stream":"^1.6.1","uuid":"^3.0.1","v8-compile-cache":"^2.0.0","validate-npm-package-license":"^3.0.4","yn":"^2.0.0"},"devDependencies":{"babel-core":"^6.26.0","babel-eslint":"^7.2.3","babel-loader":"^6.2.5","babel-plugin-array-includes":"^2.0.3","babel-plugin-inline-import":"^3.0.0","babel-plugin-transform-builtin-extend":"^1.1.2","babel-plugin-transform-inline-imports-commonjs":"^1.0.0","babel-plugin-transform-runtime":"^6.4.3","babel-preset-env":"^1.6.0","babel-preset-flow":"^6.23.0","babel-preset-stage-0":"^6.0.0","babylon":"^6.5.0","commitizen":"^2.9.6","cz-conventional-changelog":"^2.0.0","eslint":"^4.3.0","eslint-config-fb-strict":"^22.0.0","eslint-plugin-babel":"^5.0.0","eslint-plugin-flowtype":"^2.35.0","eslint-plugin-jasmine":"^2.6.2","eslint-plugin-jest":"^21.0.0","eslint-plugin-jsx-a11y":"^6.0.2","eslint-plugin-prefer-object-spread":"^1.2.1","eslint-plugin-prettier":"^2.1.2","eslint-plugin-react":"^7.1.0","eslint-plugin-relay":"^0.0.28","eslint-plugin-yarn-internal":"file:scripts/eslint-rules","execa":"^0.11.0","fancy-log":"^1.3.2","flow-bin":"^0.66.0","git-release-notes":"^3.0.0","gulp":"^4.0.0","gulp-babel":"^7.0.0","gulp-if":"^2.0.1","gulp-newer":"^1.0.0","gulp-plumber":"^1.0.1","gulp-sourcemaps":"^2.2.0","jest":"^22.4.4","jsinspect":"^0.12.6","minimatch":"^3.0.4","mock-stdin":"^0.3.0","prettier":"^1.5.2","string-replace-loader":"^2.1.1","temp":"^0.8.3","webpack":"^2.1.0-beta.25","yargs":"^6.3.0"},"resolutions":{"sshpk":"^1.14.2"},"engines":{"node":">=4.0.0"},"repository":"yarnpkg/yarn","bin":{"yarn":"./bin/yarn.js","yarnpkg":"./bin/yarn.js"},"scripts":{"build":"gulp build","build-bundle":"node ./scripts/build-webpack.js","build-chocolatey":"powershell ./scripts/build-chocolatey.ps1","build-deb":"./scripts/build-deb.sh","build-dist":"bash ./scripts/build-dist.sh","build-win-installer":"scripts\\build-windows-installer.bat","changelog":"git-release-notes $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..$(git describe --tags --abbrev=0) scripts/changelog.md","dupe-check":"yarn jsinspect ./src","lint":"eslint . && flow check","pkg-tests":"yarn --cwd packages/pkg-tests jest yarn.test.js","prettier":"eslint src __tests__ --fix","release-branch":"./scripts/release-branch.sh","test":"yarn lint && yarn test-only","test-only":"node --max_old_space_size=4096 node_modules/jest/bin/jest.js --verbose","test-only-debug":"node --inspect-brk --max_old_space_size=4096 node_modules/jest/bin/jest.js --runInBand --verbose","test-coverage":"node --max_old_space_size=4096 node_modules/jest/bin/jest.js --coverage --verbose","watch":"gulp watch","commit":"git-cz"},"jest":{"collectCoverageFrom":["src/**/*.js"],"testEnvironment":"node","modulePathIgnorePatterns":["__tests__/fixtures/","packages/pkg-tests/pkg-tests-fixtures","dist/"],"testPathIgnorePatterns":["__tests__/(fixtures|__mocks__)/","updates/","_(temp|mock|install|init|helpers).js$","packages/pkg-tests"]},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}}}
module.exports = {"name":"yarn","installationMethod":"unknown","version":"1.22.4","license":"BSD-2-Clause","preferGlobal":true,"description":"📦🐈 Fast, reliable, and secure dependency management.","dependencies":{"@zkochan/cmd-shim":"^3.1.0","babel-runtime":"^6.26.0","bytes":"^3.0.0","camelcase":"^4.0.0","chalk":"^2.1.0","cli-table3":"^0.4.0","commander":"^2.9.0","death":"^1.0.0","debug":"^3.0.0","deep-equal":"^1.0.1","detect-indent":"^5.0.0","dnscache":"^1.0.1","glob":"^7.1.1","gunzip-maybe":"^1.4.0","hash-for-dep":"^1.2.3","imports-loader":"^0.8.0","ini":"^1.3.4","inquirer":"^6.2.0","invariant":"^2.2.0","is-builtin-module":"^2.0.0","is-ci":"^1.0.10","is-webpack-bundle":"^1.0.0","js-yaml":"^3.13.1","leven":"^2.0.0","loud-rejection":"^1.2.0","micromatch":"^2.3.11","mkdirp":"^0.5.1","node-emoji":"^1.6.1","normalize-url":"^2.0.0","npm-logical-tree":"^1.2.1","object-path":"^0.11.2","proper-lockfile":"^2.0.0","puka":"^1.0.0","read":"^1.0.7","request":"^2.87.0","request-capture-har":"^1.2.2","rimraf":"^2.5.0","semver":"^5.1.0","ssri":"^5.3.0","strip-ansi":"^4.0.0","strip-bom":"^3.0.0","tar-fs":"^1.16.0","tar-stream":"^1.6.1","uuid":"^3.0.1","v8-compile-cache":"^2.0.0","validate-npm-package-license":"^3.0.4","yn":"^2.0.0"},"devDependencies":{"babel-core":"^6.26.0","babel-eslint":"^7.2.3","babel-loader":"^6.2.5","babel-plugin-array-includes":"^2.0.3","babel-plugin-inline-import":"^3.0.0","babel-plugin-transform-builtin-extend":"^1.1.2","babel-plugin-transform-inline-imports-commonjs":"^1.0.0","babel-plugin-transform-runtime":"^6.4.3","babel-preset-env":"^1.6.0","babel-preset-flow":"^6.23.0","babel-preset-stage-0":"^6.0.0","babylon":"^6.5.0","commitizen":"^2.9.6","cz-conventional-changelog":"^2.0.0","eslint":"^4.3.0","eslint-config-fb-strict":"^22.0.0","eslint-plugin-babel":"^5.0.0","eslint-plugin-flowtype":"^2.35.0","eslint-plugin-jasmine":"^2.6.2","eslint-plugin-jest":"^21.0.0","eslint-plugin-jsx-a11y":"^6.0.2","eslint-plugin-prefer-object-spread":"^1.2.1","eslint-plugin-prettier":"^2.1.2","eslint-plugin-react":"^7.1.0","eslint-plugin-relay":"^0.0.28","eslint-plugin-yarn-internal":"file:scripts/eslint-rules","execa":"^0.11.0","fancy-log":"^1.3.2","flow-bin":"^0.66.0","git-release-notes":"^3.0.0","gulp":"^4.0.0","gulp-babel":"^7.0.0","gulp-if":"^2.0.1","gulp-newer":"^1.0.0","gulp-plumber":"^1.0.1","gulp-sourcemaps":"^2.2.0","jest":"^22.4.4","jsinspect":"^0.12.6","minimatch":"^3.0.4","mock-stdin":"^0.3.0","prettier":"^1.5.2","string-replace-loader":"^2.1.1","temp":"^0.8.3","webpack":"^2.1.0-beta.25","yargs":"^6.3.0"},"resolutions":{"sshpk":"^1.14.2"},"engines":{"node":">=4.0.0"},"repository":"yarnpkg/yarn","bin":{"yarn":"./bin/yarn.js","yarnpkg":"./bin/yarn.js"},"scripts":{"build":"gulp build","build-bundle":"node ./scripts/build-webpack.js","build-chocolatey":"powershell ./scripts/build-chocolatey.ps1","build-deb":"./scripts/build-deb.sh","build-dist":"bash ./scripts/build-dist.sh","build-win-installer":"scripts\\build-windows-installer.bat","changelog":"git-release-notes $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..$(git describe --tags --abbrev=0) scripts/changelog.md","dupe-check":"yarn jsinspect ./src","lint":"eslint . && flow check","pkg-tests":"yarn --cwd packages/pkg-tests jest yarn.test.js","prettier":"eslint src __tests__ --fix","release-branch":"./scripts/release-branch.sh","test":"yarn lint && yarn test-only","test-only":"node --max_old_space_size=4096 node_modules/jest/bin/jest.js --verbose","test-only-debug":"node --inspect-brk --max_old_space_size=4096 node_modules/jest/bin/jest.js --runInBand --verbose","test-coverage":"node --max_old_space_size=4096 node_modules/jest/bin/jest.js --coverage --verbose","watch":"gulp watch","commit":"git-cz"},"jest":{"collectCoverageFrom":["src/**/*.js"],"testEnvironment":"node","modulePathIgnorePatterns":["__tests__/fixtures/","packages/pkg-tests/pkg-tests-fixtures","dist/"],"testPathIgnorePatterns":["__tests__/(fixtures|__mocks__)/","updates/","_(temp|mock|install|init|helpers).js$","packages/pkg-tests"]},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}}}

/***/ }),
/* 195 */
Expand Down Expand Up @@ -69876,12 +69888,12 @@ function getRcConfigForFolder(cwd) {
}

function loadRcFile(fileText, filePath) {
var _parse = (0, (_lockfile || _load_lockfile()).parse)(fileText, 'yarnrc');
var _parse = (0, (_lockfile || _load_lockfile()).parse)(fileText, filePath);

let values = _parse.object;


if (filePath.match(/\.yml$/)) {
if (filePath.match(/\.yml$/) && typeof values.yarnPath === 'string') {
values = { 'yarn-path': values.yarnPath };
}

Expand Down Expand Up @@ -98338,7 +98350,7 @@ var _buildSubCommands = (0, (_buildSubCommands2 || _load_buildSubCommands()).def
const rcPath = `${config.lockfileFolder}/.yarnrc.yml`;
reporter.log(`Updating ${chalk.magenta(rcPath)}...`);

yield (_fs || _load_fs()).writeFilePreservingEol(rcPath, `yarnPath: ${JSON.stringify(yarnPath)}\n`);
yield (_fs || _load_fs()).writeFilePreservingEol(rcPath, `yarnPath: ${JSON.stringify(targetPath)}\n`);
} else {
const rcPath = `${config.lockfileFolder}/.yarnrc`;
reporter.log(`Updating ${chalk.magenta(rcPath)}...`);
Expand Down Expand Up @@ -100586,6 +100598,11 @@ let start = (() => {
const opts = { stdio: 'inherit', env: Object.assign({}, process.env, { YARN_IGNORE_PATH: 1 }) };
let exitCode = 0;

process.on(`SIGINT`, function () {
// We don't want SIGINT to kill our process; we want it to kill the
// innermost process, whose end will cause our own to exit.
});

try {
if (yarnPath.endsWith(`.js`)) {
exitCode = yield (0, (_child || _load_child()).spawnp)(process.execPath, [yarnPath, ...argv], opts);
Expand Down Expand Up @@ -107715,7 +107732,11 @@ function parseRcPaths(paths, parser) {
try {
return parser((0, (_fs || _load_fs()).readFileSync)(path).toString(), path);
} catch (error) {
return {};
if (error.code === 'ENOENT' || error.code === 'EISDIR') {
return {};
} else {
throw error;
}
}
}));
}
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc
Expand Up @@ -3,4 +3,4 @@


lastUpdateCheck 1576854265612
yarn-path ".yarn/releases/yarn-1.22.0.js"
yarn-path ".yarn/releases/yarn-1.22.4.js"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,10 +2,14 @@

### Features

- `[@jest/globals]` New package so Jest's globals can be explicitly imported ([#9801](https://github.com/facebook/jest/pull/9801))
- `[jest-snapshot]`: Make prettier optional for inline snapshots - fall back to string replacement ([#7792](https://github.com/facebook/jest/pull/7792))

### 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))

### Chore & Maintenance

### Performance
Expand Down
10 changes: 6 additions & 4 deletions docs/GlobalAPI.md
Expand Up @@ -3,7 +3,7 @@ id: api
title: Globals
---

In your test files, Jest puts each of these methods and objects into the global environment. You don't have to require or import anything to use them.
In your test files, Jest puts each of these methods and objects into the global environment. You don't have to require or import anything to use them. However, if you prefer explicit imports, you can do `import {describe, expect, it} from '@jest/globals'`.

## Methods

Expand Down Expand Up @@ -528,7 +528,7 @@ test.each`

### `test.only(name, fn, timeout)`

Also under the aliases: `it.only(name, fn, timeout)` or `fit(name, fn, timeout)`
Also under the aliases: `ftest(name, fn, timeout)`, `it.only(name, fn, timeout)`, and `fit(name, fn, timeout)`

When you are debugging a large test file, you will often only want to run a subset of tests. You can use `.only` to specify which tests are the only ones you want to run in that test file.

Expand All @@ -552,7 +552,7 @@ Usually you wouldn't check code using `test.only` into source control - you woul

### `test.only.each(table)(name, fn)`

Also under the aliases: `it.only.each(table)(name, fn)`, `fit.each(table)(name, fn)`, `` it.only.each`table`(name, fn) `` and `` fit.each`table`(name, fn) ``
Also under the aliases: `ftest.each(table)(name, fn)`, `it.only.each(table)(name, fn)`, `fit.each(table)(name, fn)`, `` ftest.each`table`(name, fn) ``, `` it.only.each`table`(name, fn) `` and `` fit.each`table`(name, fn) ``

Use `test.only.each` if you want to only run specific tests with different test data.

Expand Down Expand Up @@ -593,7 +593,7 @@ test('will not be ran', () => {

### `test.skip(name, fn)`

Also under the aliases: `it.skip(name, fn)` or `xit(name, fn)` or `xtest(name, fn)`
Also under the aliases: `it.skip(name, fn)`, `xit(name, fn)`, and `xtest(name, fn)`

When you are maintaining a large codebase, you may sometimes find a test that is temporarily broken for some reason. If you want to skip running this test, but you don't want to delete this code, you can use `test.skip` to specify some tests to skip.

Expand Down Expand Up @@ -656,6 +656,8 @@ test('will be ran', () => {

### `test.todo(name)`

Also under the alias: `it.todo(name)`

Use `test.todo` when you are planning on writing tests. These tests will be highlighted in the summary output at the end so you know how many tests you still need todo.

_Note_: If you supply a test callback function then the `test.todo` will throw an error. If you have already implemented the test and it is broken and you do not want it to run, then use `test.skip` instead.
Expand Down
2 changes: 1 addition & 1 deletion docs/JestObjectAPI.md
Expand Up @@ -3,7 +3,7 @@ id: jest-object
title: The Jest Object
---

The `jest` object is automatically in scope within every test file. The methods in the `jest` object help create mocks and let you control Jest's overall behavior.
The `jest` object is automatically in scope within every test file. The methods in the `jest` object help create mocks and let you control Jest's overall behavior. It can also be imported explicitly by via `import {jest} from '@jest/globals'`.

## Mock Modules

Expand Down
14 changes: 7 additions & 7 deletions e2e/Utils.ts
Expand Up @@ -11,7 +11,7 @@ import type {Config} from '@jest/types';

// eslint-disable-next-line import/named
import {ExecaReturnValue, sync as spawnSync} from 'execa';
import {createDirectory} from 'jest-util';
import makeDir = require('make-dir');
import rimraf = require('rimraf');
import dedent = require('dedent');

Expand Down Expand Up @@ -45,7 +45,7 @@ export const linkJestPackage = (packageName: string, cwd: Config.Path) => {
const packagesDir = path.resolve(__dirname, '../packages');
const packagePath = path.resolve(packagesDir, packageName);
const destination = path.resolve(cwd, 'node_modules/', packageName);
createDirectory(destination);
makeDir.sync(destination);
rimraf.sync(destination);
fs.symlinkSync(packagePath, destination, 'dir');
};
Expand Down Expand Up @@ -76,12 +76,12 @@ export const writeFiles = (
directory: string,
files: {[filename: string]: string},
) => {
createDirectory(directory);
makeDir.sync(directory);
Object.keys(files).forEach(fileOrPath => {
const dirname = path.dirname(fileOrPath);

if (dirname !== '/') {
createDirectory(path.join(directory, dirname));
makeDir.sync(path.join(directory, dirname));
}
fs.writeFileSync(
path.resolve(directory, ...fileOrPath.split('/')),
Expand All @@ -94,13 +94,13 @@ export const writeSymlinks = (
directory: string,
symlinks: {[existingFile: string]: string},
) => {
createDirectory(directory);
makeDir.sync(directory);
Object.keys(symlinks).forEach(fileOrPath => {
const symLinkPath = symlinks[fileOrPath];
const dirname = path.dirname(symLinkPath);

if (dirname !== '/') {
createDirectory(path.join(directory, dirname));
makeDir.sync(path.join(directory, dirname));
}
fs.symlinkSync(
path.resolve(directory, ...fileOrPath.split('/')),
Expand Down Expand Up @@ -163,7 +163,7 @@ export const createEmptyPackage = (
},
};

createDirectory(directory);
makeDir.sync(directory);
packageJson || (packageJson = DEFAULT_PACKAGE_JSON);
fs.writeFileSync(
path.resolve(directory, 'package.json'),
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/coverageHandlebars.test.ts.snap
@@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`code coverage for Handlebars 1`] = `
"-----------|---------|----------|---------|---------|-------------------
-----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------|---------|----------|---------|---------|-------------------
All files | 75 | 66.67 | 66.67 | 66.67 |
greet.hbs | 75 | 66.67 | 66.67 | 66.67 | 10
-----------|---------|----------|---------|---------|-------------------"
-----------|---------|----------|---------|---------|-------------------
`;
16 changes: 8 additions & 8 deletions e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`warns if describe returns a Promise 1`] = `
" console.log
console.log
● Test suite failed to run
Returning a Promise from \\"describe\\" is not supported. Tests must be defined synchronously.
Returning a value from \\"describe\\" will fail the test in a future version of Jest.
Returning a Promise from "describe" is not supported. Tests must be defined synchronously.
Returning a value from "describe" will fail the test in a future version of Jest.
9 | 'use strict';
10 |
Expand All @@ -17,15 +17,15 @@ exports[`warns if describe returns a Promise 1`] = `
at Object.describe (__tests__/describeReturnPromise.test.js:11:1)
"
`;

exports[`warns if describe returns something 1`] = `
" console.log
console.log
● Test suite failed to run
A \\"describe\\" callback must not return a value.
Returning a value from \\"describe\\" will fail the test in a future version of Jest.
A "describe" callback must not return a value.
Returning a value from "describe" will fail the test in a future version of Jest.
9 | 'use strict';
10 |
Expand All @@ -37,5 +37,5 @@ exports[`warns if describe returns something 1`] = `
at Object.describe (__tests__/describeReturnSomething.test.js:11:1)
"
`;
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/transform.test.ts.snap
Expand Up @@ -36,10 +36,10 @@ All files | 83.33 | 100 | 50 | 80 |
`;

exports[`transformer-config instruments only specific files and collects coverage 1`] = `
"------------|---------|----------|---------|---------|-------------------
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 83.33 | 100 | 50 | 80 |
Covered.js | 83.33 | 100 | 50 | 80 | 13
------------|---------|----------|---------|---------|-------------------"
------------|---------|----------|---------|---------|-------------------
`;

0 comments on commit dae5678

Please sign in to comment.