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