-
Notifications
You must be signed in to change notification settings - Fork 7
/
test.flow.js
59 lines (53 loc) · 1.43 KB
/
test.flow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env node
// @flow
const { spawn } = require('child_process');
const path = require('path');
process.exitCode = 0;
process.on('exit', code => {
console.log('---------');
console.log('');
if (code === 0) {
console.log(
'\x1b[36m%s\x1b[0m',
'Successful! The bad case tests work as expected!'
);
// console.log();
} else {
console.log('\x1b[31m', 'Failed! The bad case tests get broken!');
}
console.log('');
});
const runTest = filePath => {
const pipe = spawn(
'yarn',
[
'flow',
'check-contents',
`< ${path.join(process.cwd(), '__test__/bad-type/', filePath)}`,
],
{
shell: true,
}
);
pipe.stdout.pipe(process.stdout);
pipe.stderr.pipe(process.stdout);
pipe.on('close', code => {
if (code === 0) {
console.log('!!!===!!!');
console.log('Error, close with failed cases as Unexpected exitCode: ', code);
process.exitCode += 1;
} else {
console.log('***===***');
console.log('Close as Expected exitCode: ', code);
}
});
pipe.on('error', err => {
console.log('Error Found: ', err);
});
};
const badCases = [
'bad-props.flow.js',
'bad-static-props.flow.js',
'bad-props-stateless-component.flow.js',
];
badCases.forEach(filePath => runTest(filePath));