|
| 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 | +}); |
0 commit comments