Skip to content

Commit 3a71de0

Browse files
thymikeejessecarfb
authored andcommitted
Use cross-spawn for running Yarn in integration tests (jestjs#5550)
* Use cross-spawn for running Yarn in integration tests * Unlock more windows tests * Moar windows * Use node api instead of spawning commands to link babel-jest * Skip windows for coverage_remapping.test.js
1 parent bf1518c commit 3a71de0

5 files changed

Lines changed: 13 additions & 28 deletions

File tree

integration-tests/__tests__/babel_plugin_jest_hoist.test.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@
99
'use strict';
1010

1111
const path = require('path');
12-
const SkipOnWindows = require('../../scripts/SkipOnWindows');
1312
const {run} = require('../utils');
1413
const runJest = require('../runJest');
1514

1615
const DIR = path.resolve(__dirname, '..', 'babel-plugin-jest-hoist');
1716

18-
SkipOnWindows.suite();
19-
20-
if (process.platform !== 'win32') {
21-
beforeEach(() => {
22-
run('yarn', DIR);
23-
});
24-
}
17+
beforeEach(() => {
18+
run('yarn', DIR);
19+
});
2520

2621
it('sucessfully runs the tests inside `babel-plugin-jest-hoist/`', () => {
2722
const {json} = runJest.json(DIR, ['--no-cache', '--coverage']);

integration-tests/__tests__/native_async_mock.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,18 @@
1010
'use strict';
1111

1212
const path = require('path');
13-
const SkipOnWindows = require('../../scripts/SkipOnWindows');
1413
const {run, extractSummary} = require('../utils');
1514
const runJest = require('../runJest');
1615

17-
SkipOnWindows.suite();
1816
const dir = path.resolve(__dirname, '..', 'native-async-mock');
1917

2018
test('mocks async functions', () => {
2119
if (process.versions.node < '7.6.0') {
2220
return;
2321
}
24-
if (process.platform !== 'win32') {
25-
run('yarn', dir);
26-
}
22+
23+
run('yarn', dir);
24+
2725
// --no-cache because babel can cache stuff and result in false green
2826
const {stderr} = runJest(dir, ['--no-cache']);
2927
expect(extractSummary(stderr).summary).toMatch(

integration-tests/__tests__/transform.test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
const path = require('path');
11-
const SkipOnWindows = require('../../scripts/SkipOnWindows');
1211
const {
1312
run,
1413
cleanup,
@@ -20,13 +19,10 @@ const runJest = require('../runJest');
2019
const os = require('os');
2120

2221
describe('babel-jest', () => {
23-
SkipOnWindows.suite();
2422
const dir = path.resolve(__dirname, '..', 'transform/babel-jest');
2523

2624
beforeEach(() => {
27-
if (process.platform !== 'win32') {
28-
run('yarn', dir);
29-
}
25+
run('yarn', dir);
3026
});
3127

3228
it('runs transpiled code', () => {
@@ -60,7 +56,7 @@ describe('no babel-jest', () => {
6056
linkJestPackage('babel-jest', tempDir);
6157
});
6258

63-
it('fails with syntax error on flow types', () => {
59+
test('fails with syntax error on flow types', () => {
6460
const {stderr} = runJest(tempDir, ['--no-cache', '--no-watchman']);
6561
expect(stderr).toMatch(/FAIL.*fails_with_syntax_error/);
6662
expect(stderr).toMatch('Unexpected token');
@@ -107,9 +103,7 @@ describe('multiple-transformers', () => {
107103
const dir = path.resolve(__dirname, '..', 'transform/multiple-transformers');
108104

109105
beforeEach(() => {
110-
if (process.platform !== 'win32') {
111-
run('yarn', dir);
112-
}
106+
run('yarn', dir);
113107
});
114108

115109
it('transforms dependencies using specific transformers', () => {

integration-tests/__tests__/typescript_coverage.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
*/
99

1010
const path = require('path');
11-
const SkipOnWindows = require('../../scripts/SkipOnWindows');
1211
const {run} = require('../utils');
1312
const runJest = require('../runJest');
1413

15-
SkipOnWindows.suite();
16-
1714
it('instruments and collects coverage for typescript files', () => {
1815
const dir = path.resolve(__dirname, '../typescript-coverage');
1916
run('yarn', dir);

integration-tests/utils.js

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

1212
import type {Path} from 'types/Config';
1313

14-
const {spawnSync} = require('child_process');
14+
const {sync: spawnSync} = require('cross-spawn');
1515
const fs = require('fs');
1616
const path = require('path');
1717
const mkdirp = require('mkdirp');
@@ -43,8 +43,9 @@ const linkJestPackage = (packageName: string, cwd: Path) => {
4343
const packagesDir = path.resolve(__dirname, '../packages');
4444
const packagePath = path.resolve(packagesDir, packageName);
4545
const destination = path.resolve(cwd, 'node_modules/');
46-
run(`mkdir -p ${destination}`);
47-
return run(`ln -sf ${packagePath} ${destination}`);
46+
mkdirp.sync(destination);
47+
rimraf.sync(destination);
48+
fs.symlinkSync(packagePath, destination, 'dir');
4849
};
4950

5051
const fileExists = (filePath: Path) => {

0 commit comments

Comments
 (0)