Skip to content

Commit f634be0

Browse files
committed
test: add test for compilation errors in watch mode
Closes #12311
1 parent d820065 commit f634be0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

packages/angular_devkit/build_angular/test/browser/rebuild_spec_large.ts

+27
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,33 @@ describe('Browser Builder rebuilds', () => {
198198
).toPromise().then(done, done.fail);
199199
});
200200

201+
it('rebuilds shows error', (done) => {
202+
host.replaceInFile('./src/app/app.component.ts', 'AppComponent', 'AppComponentZ');
203+
204+
const overrides = { watch: true, aot: false };
205+
let buildCount = 1;
206+
const logger = new TestLogger('rebuild-errors');
207+
208+
runTargetSpec(host, browserTargetSpec, overrides, DefaultTimeout * 3, logger).pipe(
209+
tap((buildEvent) => {
210+
switch (buildCount) {
211+
case 1:
212+
expect(buildEvent.success).toBe(false);
213+
expect(logger.includes('AppComponent cannot be used as an entry component')).toBe(true);
214+
logger.clear();
215+
216+
host.replaceInFile('./src/app/app.component.ts', 'AppComponentZ', 'AppComponent');
217+
break;
218+
219+
default:
220+
expect(buildEvent.success).toBe(true);
221+
break;
222+
}
223+
buildCount ++;
224+
}),
225+
take(2),
226+
).toPromise().then(done, done.fail);
227+
});
201228

202229
it('rebuilds after errors in AOT', (done) => {
203230
// Save the original contents of `./src/app/app.component.ts`.

0 commit comments

Comments
 (0)