|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google LLC 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.dev/license |
| 7 | + */ |
| 8 | + |
| 9 | +import { execute } from '../../index'; |
| 10 | +import { |
| 11 | + BASE_OPTIONS, |
| 12 | + describeBuilder, |
| 13 | + UNIT_TEST_BUILDER_INFO, |
| 14 | + setupApplicationTarget, |
| 15 | +} from '../setup'; |
| 16 | + |
| 17 | +describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => { |
| 18 | + describe('Option: "update"', () => { |
| 19 | + beforeEach(() => { |
| 20 | + setupApplicationTarget(harness); |
| 21 | + }); |
| 22 | + |
| 23 | + describe('Vitest Runner', () => { |
| 24 | + it('should work with update flag enabled', async () => { |
| 25 | + harness.useTarget('test', { |
| 26 | + ...BASE_OPTIONS, |
| 27 | + update: true, |
| 28 | + }); |
| 29 | + |
| 30 | + const { result } = await harness.executeOnce(); |
| 31 | + |
| 32 | + expect(result?.success).toBeTrue(); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should work with update flag disabled', async () => { |
| 36 | + harness.useTarget('test', { |
| 37 | + ...BASE_OPTIONS, |
| 38 | + update: false, |
| 39 | + }); |
| 40 | + |
| 41 | + const { result } = await harness.executeOnce(); |
| 42 | + |
| 43 | + expect(result?.success).toBeTrue(); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should work without update flag (default)', async () => { |
| 47 | + harness.useTarget('test', { |
| 48 | + ...BASE_OPTIONS, |
| 49 | + }); |
| 50 | + |
| 51 | + const { result } = await harness.executeOnce(); |
| 52 | + |
| 53 | + expect(result?.success).toBeTrue(); |
| 54 | + }); |
| 55 | + }); |
| 56 | + |
| 57 | + describe('Karma Runner', () => { |
| 58 | + it('should throw an error when update is used with karma', async () => { |
| 59 | + harness.useTarget('test', { |
| 60 | + ...BASE_OPTIONS, |
| 61 | + runner: 'karma', |
| 62 | + update: true, |
| 63 | + }); |
| 64 | + |
| 65 | + const { result, error } = await harness.executeOnce({ outputLogsOnException: false }); |
| 66 | + |
| 67 | + expect(result).toBeUndefined(); |
| 68 | + expect(error?.message).toContain( |
| 69 | + 'The "update" option is only available for the "vitest" runner.', |
| 70 | + ); |
| 71 | + }); |
| 72 | + }); |
| 73 | + }); |
| 74 | +}); |
0 commit comments