Skip to content

Commit d589d3f

Browse files
authored
Integrated with Yarn workspaces (jestjs#3906)
* enabled workspaces * updated lerna to 2.0.0 with workspaces support
1 parent 740dd69 commit d589d3f

37 files changed

Lines changed: 388 additions & 5449 deletions

File tree

.yarnrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
workspaces-experimental true

appveyor.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ environment:
55
install:
66
- ps: Install-Product node $env:nodejs_version x64
77
- node --version
8-
- yarn --version
9-
- yarn install
8+
- curl -fsSL -o yarn.js https://github.com/yarnpkg/yarn/releases/download/v0.27.5/yarn-0.27.5.js
9+
- node ./yarn.js --version
10+
- node ./yarn.js install
11+
- node ./yarn.js run build
1012

1113
cache:
1214
- node_modules
1315
- .eslintcache
1416

1517
test_script:
16-
- yarn run jest -- --color
18+
- node ./yarn.js run jest -- --color
1719

1820
# Don't actually build.
1921
build: off

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
machine:
22
environment:
3-
YARN_VERSION: 0.20.3
3+
YARN_VERSION: 0.27.5
44
PATH: "${PATH}:${HOME}/.yarn/bin:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
55
node:
66
version: 8

integration_tests/__tests__/__snapshots__/show_config.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ exports[`jest --showConfig outputs config info and exits 1`] = `
3737
"/mocked/root/path/jest/node_modules/regenerator-runtime/runtime.js"
3838
],
3939
"snapshotSerializers": [],
40-
"testEnvironment": "/mocked/root/path/jest/packages/jest-environment-node/build/index.js",
40+
"testEnvironment": "/mocked/root/path/jest/node_modules/jest-environment-node/build/index.js",
4141
"testMatch": [
4242
"**/__tests__/**/*.js?(x)",
4343
"**/?(*.)(spec|test).js?(x)"
@@ -52,7 +52,7 @@ exports[`jest --showConfig outputs config info and exits 1`] = `
5252
"transform": [
5353
[
5454
"^.+\\\\.jsx?$",
55-
"/mocked/root/path/jest/integration_tests/verbose_reporter/node_modules/babel-jest/build/index.js"
55+
"/mocked/root/path/jest/node_modules/babel-jest/build/index.js"
5656
]
5757
],
5858
"transformIgnorePatterns": [

integration_tests/__tests__/babel_plugin_jest_hoist.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
const path = require('path');
1313
const skipOnWindows = require('skipOnWindows');
14-
const {linkJestPackage, run} = require('../utils');
14+
const {run} = require('../utils');
1515
const runJest = require('../runJest');
1616

1717
const DIR = path.resolve(__dirname, '..', 'babel-plugin-jest-hoist');
@@ -21,8 +21,6 @@ skipOnWindows.suite();
2121
if (process.platform !== 'win32') {
2222
beforeEach(() => {
2323
run('yarn', DIR);
24-
linkJestPackage('babel-plugin-jest-hoist', DIR);
25-
linkJestPackage('babel-jest', DIR);
2624
});
2725
}
2826

integration_tests/__tests__/coverage_report.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,11 @@
1212
const fs = require('fs');
1313
const path = require('path');
1414
const skipOnWindows = require('skipOnWindows');
15-
const {extractSummary, linkJestPackage} = require('../utils');
15+
const {extractSummary} = require('../utils');
1616
const runJest = require('../runJest');
1717

1818
const DIR = path.resolve(__dirname, '../coverage_report');
1919

20-
if (process.platform !== 'win32') {
21-
beforeEach(() => linkJestPackage('babel-jest', DIR));
22-
}
23-
2420
skipOnWindows.suite();
2521

2622
test('outputs coverage report', () => {

integration_tests/__tests__/debug.test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@
88

99
const path = require('path');
1010
const skipOnWindows = require('skipOnWindows');
11-
const {linkJestPackage} = require('../utils');
1211
const runJest = require('../runJest');
1312

1413
describe('jest --debug', () => {
1514
skipOnWindows.suite();
1615

1716
const dir = path.resolve(__dirname, '..', 'verbose_reporter');
1817

19-
beforeEach(() => {
20-
if (process.platform !== 'win32') {
21-
linkJestPackage('babel-jest', dir);
22-
}
23-
});
24-
2518
it('outputs debugging info before running the test', () => {
2619
const {stdout} = runJest(dir, ['--debug', '--no-cache']);
2720
expect(stdout).toMatch('"version": "');

integration_tests/__tests__/native_async_mock.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
const path = require('path');
1212
const skipOnWindows = require('skipOnWindows');
13-
const {linkJestPackage, run, extractSummary} = require('../utils');
13+
const {run, extractSummary} = require('../utils');
1414
const runJest = require('../runJest');
1515

1616
skipOnWindows.suite();
@@ -22,7 +22,6 @@ test('mocks async functions', () => {
2222
}
2323
if (process.platform !== 'win32') {
2424
run('yarn', dir);
25-
linkJestPackage('babel-jest', dir);
2625
}
2726
// --no-cache because babel can cache stuff and result in false green
2827
const {stderr} = runJest(dir, ['--no-cache']);

integration_tests/__tests__/show_config.test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,13 @@
1010

1111
const path = require('path');
1212
const skipOnWindows = require('skipOnWindows');
13-
const {linkJestPackage} = require('../utils');
1413
const runJest = require('../runJest');
1514

1615
describe('jest --showConfig', () => {
1716
skipOnWindows.suite();
1817

1918
const dir = path.resolve(__dirname, '..', 'verbose_reporter');
2019

21-
beforeEach(() => {
22-
if (process.platform !== 'win32') {
23-
linkJestPackage('babel-jest', dir);
24-
}
25-
});
26-
2720
it('outputs config info and exits', () => {
2821
const root = path.join(__dirname, '..', '..', '..');
2922
expect.addSnapshotSerializer({

integration_tests/__tests__/transform.test.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88

99
const path = require('path');
1010
const skipOnWindows = require('skipOnWindows');
11-
const {linkJestPackage, run} = require('../utils');
11+
const {
12+
run,
13+
cleanup,
14+
createEmptyPackage,
15+
linkJestPackage,
16+
copyDir,
17+
} = require('../utils');
1218
const runJest = require('../runJest');
19+
const os = require('os');
1320

1421
describe('babel-jest', () => {
1522
skipOnWindows.suite();
@@ -18,7 +25,6 @@ describe('babel-jest', () => {
1825
beforeEach(() => {
1926
if (process.platform !== 'win32') {
2027
run('yarn', dir);
21-
linkJestPackage('babel-jest', dir);
2228
}
2329
});
2430

@@ -39,17 +45,32 @@ describe('babel-jest', () => {
3945
});
4046
});
4147

48+
// babel-jest is automatically linked at the root because it is a workspace now
49+
// a way to test this in isolation is to move the test suite into a temp folder
4250
describe('no babel-jest', () => {
4351
const dir = path.resolve(__dirname, '..', 'transform/no-babel-jest');
52+
// doing test in a temp directory because we don't want jest node_modules affect it
53+
const tempDir = path.resolve(os.tmpdir(), 'transform-no-babel-jest');
54+
55+
beforeEach(() => {
56+
cleanup(tempDir);
57+
createEmptyPackage(tempDir);
58+
copyDir(dir, tempDir);
59+
linkJestPackage('babel-jest', tempDir);
60+
});
4461

4562
it('fails with syntax error on flow types', () => {
46-
const {stderr} = runJest(dir, ['--no-cache']);
63+
const {stderr} = runJest(tempDir, ['--no-cache', '--no-watchman']);
4764
expect(stderr).toMatch(/FAIL.*fails_with_syntax_error/);
48-
expect(stderr).toMatch('SyntaxError: Unexpected token :');
65+
expect(stderr).toMatch('Unexpected token');
4966
});
5067

5168
test('instrumentation with no babel-jest', () => {
52-
const {stdout} = runJest(dir, ['--no-cache', '--coverage']);
69+
const {stdout} = runJest(tempDir, [
70+
'--no-cache',
71+
'--coverage',
72+
'--no-watchman',
73+
]);
5374
expect(stdout).toMatch('covered.js');
5475
expect(stdout).not.toMatch('excluded_from_coverage.js');
5576
// coverage result should not change
@@ -87,7 +108,6 @@ describe('multiple-transformers', () => {
87108
beforeEach(() => {
88109
if (process.platform !== 'win32') {
89110
run('yarn', dir);
90-
linkJestPackage('babel-jest', dir);
91111
}
92112
});
93113

0 commit comments

Comments
 (0)