Skip to content

Commit

Permalink
Merge branch 'master' into feat/use-transform-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jan 18, 2019
2 parents 64acf9e + 44054af commit 45e525a
Show file tree
Hide file tree
Showing 97 changed files with 611 additions and 437 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- `[jest-haste-map]` [**BREAKING**] Remove name from hash in `HasteMap.getCacheFilePath` ([#7218](https://github.com/facebook/jest/pull/7218))
- `[babel-preset-jest]` [**BREAKING**] Export a function instead of an object for Babel 7 compatibility ([#7203](https://github.com/facebook/jest/pull/7203))
- `[jest-haste-map]` [**BREAKING**] Expose relative paths when getting the file iterator ([#7321](https://github.com/facebook/jest/pull/7321))
- `[jest-cli]` [**BREAKING**] Run code transforms over `global{Setup,Teardown}` ([#7562](https://github.com/facebook/jest/pull/7562))
- `[jest-haste-map]` Add `hasteFS.getSize(path)` ([#7580](https://github.com/facebook/jest/pull/7580))
- `[jest-cli]` Print version ending in `-dev` when running a local Jest clone ([#7582](https://github.com/facebook/jest/pull/7582))
- `[jest-cli]` Add Support for `globalSetup` and `globalTeardown` in projects ([#6865](https://github.com/facebook/jest/pull/6865))
Expand Down Expand Up @@ -52,6 +53,7 @@

### Fixes

- `[jest-config]` Ensure `existsSync` is only called with a string parameter ([#7607](https://github.com/facebook/jest/pull/7607))
- `[expect]` `toStrictEqual` considers sparseness of arrays. ([#7591](https://github.com/facebook/jest/pull/7591))
- `[jest-cli]` Fix empty coverage data for untested files ([#7388](https://github.com/facebook/jest/pull/7388))
- `[jest-cli]` [**BREAKING**] Do not use `text-summary` coverage reporter by default if other reporters are configured ([#7058](https://github.com/facebook/jest/pull/7058))
Expand Down Expand Up @@ -113,11 +115,13 @@
- `[jest-snapshot]` Write and read snapshots from disk even if `fs` is mocked ([#7080](https://github.com/facebook/jest/pull/7080))
- `[jest-config]` Normalize `config.cwd` and `config.rootDir` using `realpath ([#7598](https://github.com/facebook/jest/pull/7598))
- `[jest-environment-node]` Fix buffer property is not ArrayBuffer issue. ([#7626](https://github.com/facebook/jest/pull/7626))
- `[babel-plugin-jest-hoist]` Ignore TS type annotations when looking for out-of-scope references ([#7641](https://github.com/facebook/jest/pull/7641))

### Chore & Maintenance

- `[*]` [**BREAKING**] Require Node.js 6+ for all packages ([#7258](https://github.com/facebook/jest/pull/7258))
- `[jest-util]` [**BREAKING**] Remove long-deprecated globals for fake timers ([#7285](https://github.com/facebook/jest/pull/7285))
- `[*]` [**BREAKING**] Upgrade to Micromatch 3 ([#6650](https://github.com/facebook/jest/pull/6650))
- `[*]` [**BREAKING**] Remove regenerator-runtime injection ([#7595](https://github.com/facebook/jest/pull/7595))
- `[docs]` Fix message property in custom matcher example to return a function instead of a constant. ([#7426](https://github.com/facebook/jest/pull/7426))
- `[jest-circus]` Standardize file naming in `jest-circus` ([#7301](https://github.com/facebook/jest/pull/7301))
Expand Down
2 changes: 1 addition & 1 deletion docs/JestPlatform.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ console.log(result);

## jest-docblock

Tool for extracting and parsing the comments at the top of a JavaScript file. Exports various function to manipulate the data inside the comment block.
Tool for extracting and parsing the comments at the top of a JavaScript file. Exports various functions to manipulate the data inside the comment block.

### Example

Expand Down
10 changes: 5 additions & 5 deletions e2e/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {Path} from 'types/Config';
import {sync as spawnSync} from 'execa';
import fs from 'fs';
import path from 'path';
import mkdirp from 'mkdirp';
import {createDirectory} from 'jest-util';
import rimraf from 'rimraf';

export const run = (cmd: string, cwd?: Path) => {
Expand Down Expand Up @@ -43,7 +43,7 @@ export const linkJestPackage = (packageName: string, cwd: Path) => {
const packagesDir = path.resolve(__dirname, '../packages');
const packagePath = path.resolve(packagesDir, packageName);
const destination = path.resolve(cwd, 'node_modules/', packageName);
mkdirp.sync(destination);
createDirectory(destination);
rimraf.sync(destination);
fs.symlinkSync(packagePath, destination, 'dir');
};
Expand Down Expand Up @@ -74,13 +74,13 @@ export const writeFiles = (
directory: string,
files: {[filename: string]: string},
) => {
mkdirp.sync(directory);
createDirectory(directory);
Object.keys(files).forEach(fileOrPath => {
const filePath = fileOrPath.split('/'); // ['tmp', 'a.js']
const filename = filePath.pop(); // filepath becomes dirPath (no filename)

if (filePath.length) {
mkdirp.sync(path.join.apply(path, [directory].concat(filePath)));
createDirectory(path.join.apply(path, [directory].concat(filePath)));
}
fs.writeFileSync(
path.resolve.apply(path, [directory].concat(filePath, [filename])),
Expand Down Expand Up @@ -128,7 +128,7 @@ export const createEmptyPackage = (
},
};

mkdirp.sync(directory);
createDirectory(directory);
packageJson || (packageJson = DEFAULT_PACKAGE_JSON);
fs.writeFileSync(
path.resolve(directory, 'package.json'),
Expand Down
58 changes: 29 additions & 29 deletions e2e/__tests__/__snapshots__/failures.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -187,39 +187,39 @@ exports[`not throwing Error objects 5`] = `
22 |
> 23 | test('Object thrown during test', () => {
| ^
24 | // eslint-disable-next-line no-throw-literal
25 | throw deepObject;
26 | });
24 | throw deepObject;
25 | });
26 |
at Object.test (__tests__/duringTests.test.js:23:1)
● Error during test
ReferenceError: doesNotExist is not defined
28 | test('Error during test', () => {
29 | // eslint-disable-next-line no-undef
> 30 | doesNotExist.alsoThisNot;
27 | test('Error during test', () => {
28 | // eslint-disable-next-line no-undef
> 29 | doesNotExist.alsoThisNot;
| ^
31 | });
32 |
33 | test('done(Error)', done => {
30 | });
31 |
32 | test('done(Error)', done => {
at Object.doesNotExist (__tests__/duringTests.test.js:30:3)
at Object.doesNotExist (__tests__/duringTests.test.js:29:3)
done(Error)
this is an error
32 |
33 | test('done(Error)', done => {
> 34 | done(new Error('this is an error'));
31 |
32 | test('done(Error)', done => {
> 33 | done(new Error('this is an error'));
| ^
35 | });
36 |
37 | test('done(non-error)', done => {
34 | });
35 |
36 | test('done(non-error)', done => {
at Object.<anonymous>.done (__tests__/duringTests.test.js:34:8)
at Object.<anonymous>.done (__tests__/duringTests.test.js:33:8)
● done(non-error)
Expand All @@ -232,15 +232,15 @@ exports[`not throwing Error objects 5`] = `
],
}
36 |
37 | test('done(non-error)', done => {
> 38 | done(deepObject);
35 |
36 | test('done(non-error)', done => {
> 37 | done(deepObject);
| ^
39 | });
40 |
41 | test('returned promise rejection', () => Promise.reject(deepObject));
38 | });
39 |
40 | test('returned promise rejection', () => Promise.reject(deepObject));
at Object.done (__tests__/duringTests.test.js:38:3)
at Object.done (__tests__/duringTests.test.js:37:3)
● returned promise rejection
Expand All @@ -253,13 +253,13 @@ exports[`not throwing Error objects 5`] = `
],
}
39 | });
40 |
> 41 | test('returned promise rejection', () => Promise.reject(deepObject));
38 | });
39 |
> 40 | test('returned promise rejection', () => Promise.reject(deepObject));
| ^
42 |
41 |
at Object.test (__tests__/duringTests.test.js:41:1)
at Object.test (__tests__/duringTests.test.js:40:1)
"
`;
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/babelPluginJestHoist.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ beforeEach(() => {
it('sucessfully runs the tests inside `babel-plugin-jest-hoist/`', () => {
const {json} = runWithJson(DIR, ['--no-cache', '--coverage']);
expect(json.success).toBe(true);
expect(json.numTotalTestSuites).toBe(2);
expect(json.numTotalTestSuites).toBe(3);
});
4 changes: 2 additions & 2 deletions e2e/__tests__/globalTeardown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'use strict';

import fs from 'fs';
import mkdirp from 'mkdirp';
import {createDirectory} from 'jest-util';
import os from 'os';
import path from 'path';
import runJest, {json as runWithJson} from '../runJest';
Expand All @@ -30,7 +30,7 @@ afterAll(() => {
});

test('globalTeardown is triggered once after all test suites', () => {
mkdirp.sync(DIR);
createDirectory(DIR);
const teardownPath = path.resolve(
__dirname,
'../global-teardown/teardown.js',
Expand Down
24 changes: 24 additions & 0 deletions e2e/babel-plugin-jest-hoist/__tests__/typescript.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+jsinfra
*/

/* eslint-disable import/no-unresolved */

import {Color} from '../types';
import {color} from '../entry';

jest.mock('../entry', () => {
const color: Color = 'blue';
return {color};
});

describe('babel-plugin-jest-hoist', () => {
it('works even with type imports', () => {
expect(color).toBe('blue');
});
});
12 changes: 11 additions & 1 deletion e2e/babel-plugin-jest-hoist/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

module.exports = {
overrides: [
{
presets: ['@babel/preset-flow'],
test: '**/*.js',
},
{
presets: ['@babel/preset-typescript'],
test: '**/*.ts',
},
],
plugins: ['jest-hoist'],
presets: ['@babel/preset-env', '@babel/preset-flow'],
presets: ['@babel/preset-env'],
};
11 changes: 11 additions & 0 deletions e2e/babel-plugin-jest-hoist/entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// eslint-disable-next-line import/no-unresolved
import {Color} from './types';

export const color: Color = 'red';
5 changes: 3 additions & 2 deletions e2e/babel-plugin-jest-hoist/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"dependencies": {
"@babel/preset-env": "7.0.0",
"@babel/preset-flow": "7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"react": "*"
},
"jest": {
Expand Down
8 changes: 8 additions & 0 deletions e2e/babel-plugin-jest-hoist/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export type Color = 'red' | 'blue';
Loading

0 comments on commit 45e525a

Please sign in to comment.