Skip to content

Commit

Permalink
test: fix rebuild deps test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
filipesilva committed Jun 22, 2017
1 parent 9e8a442 commit da273a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions tests/e2e/tests/build/rebuild-deps-type-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const doneRe =
/webpack: bundle is now VALID|webpack: Compiled successfully.|webpack: Failed to compile./;



export default function() {
if (process.platform.startsWith('win')) {
return Promise.resolve();
Expand All @@ -22,7 +21,7 @@ export default function() {
return Promise.resolve();
}

return silentExecAndWaitForOutputToMatch('ng', ['serve'], doneRe)
return Promise.resolve()
// Create and import files.
.then(() => writeFile('src/funky2.ts', `
export function funky2(value: string): string {
Expand All @@ -33,24 +32,24 @@ export default function() {
export * from './funky2';
`))
.then(() => prependToFile('src/main.ts', `
import { funky } from './funky';
import { funky2 } from './funky';
`))
.then(() => appendToFile('src/main.ts', `
console.log(funky('town'));
console.log(funky2('town'));
`))
.then(() => wait(2000))
// Should trigger a rebuild, no error expected.
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
.then(() => silentExecAndWaitForOutputToMatch('ng', ['serve'], doneRe))
// Make an invalid version of the file.
.then(() => wait(2000))
.then(() => writeFile('src/funky2.ts', `
export function funky(value: number): number {
export function funky2(value: number): number {
return value + 1;
}
`))
// Should trigger a rebuild, this time an error is expected.
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
.then(({ stdout }) => {
if (!/ERROR in .*\/src\/main\.ts \(/.test(stdout)) {
.then(({ stderr }) => {
if (!/ERROR in .*\/src\/main\.ts \(/.test(stderr)) {
throw new Error('Expected an error but none happened.');
}
})
Expand All @@ -61,20 +60,20 @@ export default function() {
`))
// Should trigger a rebuild, this time an error is expected.
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
.then(({ stdout }) => {
if (!/ERROR in .*\/src\/main\.ts \(/.test(stdout)) {
.then(({ stderr }) => {
if (!/ERROR in .*\/src\/main\.ts \(/.test(stderr)) {
throw new Error('Expected an error but none happened.');
}
})
// Fix the error!
.then(() => writeFile('src/funky2.ts', `
export function funky(value: string): string {
export function funky2(value: string): string {
return value + 'hello';
}
`))
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
.then(({ stdout }) => {
if (/ERROR in .*\/src\/main\.ts \(/.test(stdout)) {
.then(({ stderr }) => {
if (/ERROR in .*\/src\/main\.ts \(/.test(stderr)) {
throw new Error('Expected no error but an error was shown.');
}
})
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let _processes: child_process.ChildProcess[] = [];

type ProcessOutput = {
stdout: string;
stdout: string;
stderr: string;
};


Expand Down

0 comments on commit da273a8

Please sign in to comment.