Skip to content

Commit 420f4f2

Browse files
clydinfilipesilva
authored andcommitted
test(@angular-devkit/build-angular): add dev-server builder verbose option tests
This change adds expanded unit tests for the dev-server builder's `verbose` option using the builder test harness.
1 parent c9bdfc7 commit 420f4f2

File tree

2 files changed

+60
-12
lines changed

2 files changed

+60
-12
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import { serveWebpackBrowser } from '../../index';
9+
import { BASE_OPTIONS, DEV_SERVER_BUILDER_INFO, describeBuilder, setupBrowserTarget } from '../setup';
10+
11+
const VERBOSE_LOG_TEXT = 'Built at';
12+
13+
describeBuilder(serveWebpackBrowser, DEV_SERVER_BUILDER_INFO, (harness) => {
14+
describe('Option: "verbose"', () => {
15+
beforeEach(() => {
16+
setupBrowserTarget(harness);
17+
});
18+
19+
it('shows verbose logs in console when true', async () => {
20+
harness.useTarget('serve', {
21+
...BASE_OPTIONS,
22+
verbose: true,
23+
});
24+
25+
const { result, logs } = await harness.executeOnce();
26+
27+
expect(result?.success).toBe(true);
28+
expect(logs).toContain(
29+
jasmine.objectContaining({ message: jasmine.stringMatching(VERBOSE_LOG_TEXT) }),
30+
);
31+
});
32+
33+
it('does not show verbose logs in console when false', async () => {
34+
harness.useTarget('serve', {
35+
...BASE_OPTIONS,
36+
verbose: false,
37+
});
38+
39+
const { result, logs } = await harness.executeOnce();
40+
41+
expect(result?.success).toBe(true);
42+
expect(logs).not.toContain(
43+
jasmine.objectContaining({ message: jasmine.stringMatching(VERBOSE_LOG_TEXT) }),
44+
);
45+
});
46+
47+
it('does not show verbose logs in console when not present', async () => {
48+
harness.useTarget('serve', {
49+
...BASE_OPTIONS,
50+
});
51+
52+
const { result, logs } = await harness.executeOnce();
53+
54+
expect(result?.success).toBe(true);
55+
expect(logs).not.toContain(
56+
jasmine.objectContaining({ message: jasmine.stringMatching(VERBOSE_LOG_TEXT) }),
57+
);
58+
});
59+
});
60+
});

packages/angular_devkit/build_angular/src/dev-server/works_spec.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ describe('Dev Server Builder', () => {
3838
expect(await response.text()).toContain('<title>HelloWorldApp</title>');
3939
}, 30000);
4040

41-
it('works with verbose', async () => {
42-
const logger = new logging.Logger('verbose-serve');
43-
let logs = '';
44-
logger.subscribe(event => logs += event.message);
45-
46-
const run = await architect.scheduleTarget(target, { verbose: true }, { logger });
47-
runs.push(run);
48-
const output = await run.result as DevServerBuilderOutput;
49-
expect(output.success).toBe(true);
50-
expect(logs).toContain('Built at');
51-
}, 30000);
52-
5341
it(`doesn't serve files on the cwd directly`, async () => {
5442
const run = await architect.scheduleTarget(target);
5543
runs.push(run);

0 commit comments

Comments
 (0)