Skip to content

Commit 0e6a5a1

Browse files
committed
update test:integration to work with latest execa
1 parent 584d540 commit 0e6a5a1

File tree

3 files changed

+58
-60
lines changed

3 files changed

+58
-60
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"lint": "eslint . --cache",
2727
"release": "release-it",
2828
"test": "codemod-cli test --coverage",
29-
"test:integration": "node ./test/run-test.js",
29+
"test:integration": "node ./test/run-test.mjs",
3030
"test:notelemetry": " node ./test/run-test-without-telemetry.js"
3131
},
3232
"jest": {

test/run-test.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

test/run-test.mjs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* eslint-disable no-console */
2+
3+
import { spawn } from 'child_process';
4+
import { execa } from 'execa';
5+
import path from 'path';
6+
7+
// resolved from the root of the project
8+
const inputDir = path.resolve('./test/fixtures/input');
9+
const execOpts = { cwd: inputDir, stderr: 'inherit' };
10+
11+
12+
console.log('installing deps');
13+
14+
await execa('rm', ['-rf', 'node_modules'], execOpts);
15+
await execa('yarn', ['install'], execOpts);
16+
17+
console.log('starting serve');
18+
19+
// We use spawn for this one so we can kill it later without throwing an error
20+
const emberServe = spawn('yarn', ['start'], execOpts);
21+
emberServe.stderr.pipe(process.stderr);
22+
emberServe.stdout.pipe(process.stdout);
23+
24+
await new Promise((resolve) => {
25+
emberServe.stdout.on('data', (data) => {
26+
if (data.toString().includes('Build successful')) {
27+
resolve();
28+
}
29+
});
30+
});
31+
32+
console.log('running codemod');
33+
34+
const codemod = execa(
35+
'../../../bin/cli.js',
36+
['--telemetry', 'http://localhost:4200', 'app'],
37+
execOpts
38+
);
39+
codemod.stdout.pipe(process.stdout);
40+
await codemod;
41+
42+
console.log('codemod complete, ending serve');
43+
44+
emberServe.kill('SIGTERM');
45+
46+
console.log('comparing results');
47+
48+
try {
49+
await execa('diff', ['-rq', './app', '../output/app'], execOpts);
50+
} catch (e) {
51+
console.error('codemod did not run successfully');
52+
console.log(e);
53+
54+
process.exit(1);
55+
}
56+
57+
console.log('codemod ran successfully! 🎉');

0 commit comments

Comments
 (0)