Skip to content

Commit f54c615

Browse files
filipesilvadanielronnkvist
authored andcommitted
test: fix rebuild deps test
This test seems to not have been doing what it was supposed, code that wasn't supposed to have errors had one, and it was checking stdout instead of stderr for errors.
1 parent 1eb0c2f commit f54c615

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

tests/e2e/tests/build/rebuild-deps-type-check.ts

+13-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const doneRe =
1212
/webpack: bundle is now VALID|webpack: Compiled successfully.|webpack: Failed to compile./;
1313

1414

15-
1615
export default function() {
1716
if (process.platform.startsWith('win')) {
1817
return Promise.resolve();
@@ -22,7 +21,7 @@ export default function() {
2221
return Promise.resolve();
2322
}
2423

25-
return silentExecAndWaitForOutputToMatch('ng', ['serve'], doneRe)
24+
return Promise.resolve()
2625
// Create and import files.
2726
.then(() => writeFile('src/funky2.ts', `
2827
export function funky2(value: string): string {
@@ -33,24 +32,24 @@ export default function() {
3332
export * from './funky2';
3433
`))
3534
.then(() => prependToFile('src/main.ts', `
36-
import { funky } from './funky';
35+
import { funky2 } from './funky';
3736
`))
3837
.then(() => appendToFile('src/main.ts', `
39-
console.log(funky('town'));
38+
console.log(funky2('town'));
4039
`))
40+
.then(() => wait(2000))
4141
// Should trigger a rebuild, no error expected.
42-
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
42+
.then(() => silentExecAndWaitForOutputToMatch('ng', ['serve'], doneRe))
4343
// Make an invalid version of the file.
44-
.then(() => wait(2000))
4544
.then(() => writeFile('src/funky2.ts', `
46-
export function funky(value: number): number {
45+
export function funky2(value: number): number {
4746
return value + 1;
4847
}
4948
`))
5049
// Should trigger a rebuild, this time an error is expected.
5150
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
52-
.then(({ stdout }) => {
53-
if (!/ERROR in .*\/src\/main\.ts \(/.test(stdout)) {
51+
.then(({ stderr }) => {
52+
if (!/ERROR in .*\/src\/main\.ts \(/.test(stderr)) {
5453
throw new Error('Expected an error but none happened.');
5554
}
5655
})
@@ -61,20 +60,20 @@ export default function() {
6160
`))
6261
// Should trigger a rebuild, this time an error is expected.
6362
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
64-
.then(({ stdout }) => {
65-
if (!/ERROR in .*\/src\/main\.ts \(/.test(stdout)) {
63+
.then(({ stderr }) => {
64+
if (!/ERROR in .*\/src\/main\.ts \(/.test(stderr)) {
6665
throw new Error('Expected an error but none happened.');
6766
}
6867
})
6968
// Fix the error!
7069
.then(() => writeFile('src/funky2.ts', `
71-
export function funky(value: string): string {
70+
export function funky2(value: string): string {
7271
return value + 'hello';
7372
}
7473
`))
7574
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
76-
.then(({ stdout }) => {
77-
if (/ERROR in .*\/src\/main\.ts \(/.test(stdout)) {
75+
.then(({ stderr }) => {
76+
if (/ERROR in .*\/src\/main\.ts \(/.test(stderr)) {
7877
throw new Error('Expected no error but an error was shown.');
7978
}
8079
})

tests/e2e/utils/process.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let _processes: child_process.ChildProcess[] = [];
1515

1616
type ProcessOutput = {
1717
stdout: string;
18-
stdout: string;
18+
stderr: string;
1919
};
2020

2121

0 commit comments

Comments
 (0)