FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: resolve vitest dependencies from latest-versions in e2e tests · angular-robot/angular-cli@de31cfc · GitHub

Commit de31cfc

Browse files
committed
test: resolve vitest dependencies from latest-versions in e2e tests
Refactor `applyVitestBuilder` to read dependency versions directly from `@schematics/angular/utility/latest-versions/package.json` and install them in a single batch using `installWorkspacePackages`. Update all Vitest E2E test suites to pass dependency options (`playwright`, `coverageV8`, `coverageIstanbul`, `webdriver`) directly to `applyVitestBuilder`, eliminating hardcoded major version installations and preventing version mismatches during major dependency upgrades.
1 parent 93c5bc8 commit de31cfc

17 files changed

Lines changed: 148 additions & 106 deletions

‎packages/angular/build/src/builders/unit-test/tests/behavior/runner-config-vitest_spec.ts‎

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
3232
it('should use custom reporters defined in runnerConfig file', async () => {
3333
harness.useTarget('test', {
3434
...BASE_OPTIONS,
35-
runnerConfig: 'vitest.config.ts',
35+
runnerConfig: 'vitest.config.mts',
3636
});
3737

38-
harness.writeFile('vitest.config.ts', VITEST_CONFIG_CONTENT);
38+
harness.writeFile('vitest.config.mts', VITEST_CONFIG_CONTENT);
3939

4040
const { result } = await harness.executeOnce();
4141
expect(result?.success).toBeTrue();
@@ -45,11 +45,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
4545
it('should use custom reporters and outputFile defined as an object in runnerConfig file', async () => {
4646
harness.useTarget('test', {
4747
...BASE_OPTIONS,
48-
runnerConfig: 'vitest.config.ts',
48+
runnerConfig: 'vitest.config.mts',
4949
});
5050

5151
harness.writeFile(
52-
'vitest.config.ts',
52+
'vitest.config.mts',
5353
`
5454
import { defineConfig } from 'vitest/config';
5555
export default defineConfig({
@@ -71,12 +71,12 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
7171
it('should preserve custom coverage options (e.g. clean: false) from runnerConfig file', async () => {
7272
harness.useTarget('test', {
7373
...BASE_OPTIONS,
74-
runnerConfig: 'vitest.config.ts',
74+
runnerConfig: 'vitest.config.mts',
7575
coverage: true,
7676
});
7777

7878
harness.writeFile(
79-
'vitest.config.ts',
79+
'vitest.config.mts',
8080
`
8181
import { defineConfig } from 'vitest/config';
8282
export default defineConfig({
@@ -102,11 +102,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
102102
it('should override reporters defined in runnerConfig file when CLI option is present', async () => {
103103
harness.useTarget('test', {
104104
...BASE_OPTIONS,
105-
runnerConfig: 'vitest.config.ts',
105+
runnerConfig: 'vitest.config.mts',
106106
reporters: ['default'],
107107
});
108108

109-
harness.writeFile('vitest.config.ts', VITEST_CONFIG_CONTENT);
109+
harness.writeFile('vitest.config.mts', VITEST_CONFIG_CONTENT);
110110

111111
const { result } = await harness.executeOnce();
112112
expect(result?.success).toBeTrue();
@@ -117,12 +117,12 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
117117
it('should use custom reportsDirectory defined in runnerConfig file', async () => {
118118
harness.useTarget('test', {
119119
...BASE_OPTIONS,
120-
runnerConfig: 'vitest.config.ts',
120+
runnerConfig: 'vitest.config.mts',
121121
coverage: true,
122122
});
123123

124124
harness.writeFile(
125-
'vitest.config.ts',
125+
'vitest.config.mts',
126126
`
127127
import { defineConfig } from 'vitest/config';
128128
export default defineConfig({
@@ -144,11 +144,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
144144
harness.useTarget('test', {
145145
...BASE_OPTIONS,
146146
coverage: true,
147-
runnerConfig: 'vitest.config.ts',
147+
runnerConfig: 'vitest.config.mts',
148148
});
149149

150150
harness.writeFile(
151-
'vitest.config.ts',
151+
'vitest.config.mts',
152152
`
153153
import { defineConfig } from 'vitest/config';
154154
export default defineConfig({
@@ -167,11 +167,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
167167
it('should enable coverage when set in runnerConfig file without builder option', async () => {
168168
harness.useTarget('test', {
169169
...BASE_OPTIONS,
170-
runnerConfig: 'vitest.config.ts',
170+
runnerConfig: 'vitest.config.mts',
171171
});
172172

173173
harness.writeFile(
174-
'vitest.config.ts',
174+
'vitest.config.mts',
175175
`
176176
import { defineConfig } from 'vitest/config';
177177
export default defineConfig({
@@ -192,11 +192,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
192192
it('should exclude test files based on runnerConfig file', async () => {
193193
harness.useTarget('test', {
194194
...BASE_OPTIONS,
195-
runnerConfig: 'vitest.config.ts',
195+
runnerConfig: 'vitest.config.mts',
196196
});
197197

198198
harness.writeFile(
199-
'vitest.config.ts',
199+
'vitest.config.mts',
200200
`
201201
import { defineConfig } from 'vitest/config';
202202
export default defineConfig({
@@ -240,12 +240,12 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
240240
harness.useTarget('test', {
241241
...BASE_OPTIONS,
242242
coverage: true,
243-
runnerConfig: 'vitest.config.ts',
243+
runnerConfig: 'vitest.config.mts',
244244
coverageExclude: ['src/app/cli-excluded.ts'],
245245
});
246246

247247
harness.writeFile(
248-
'vitest.config.ts',
248+
'vitest.config.mts',
249249
`
250250
import { defineConfig } from 'vitest/config';
251251
export default defineConfig({
@@ -292,11 +292,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
292292
it('should allow overriding globals to false via runnerConfig file', async () => {
293293
harness.useTarget('test', {
294294
...BASE_OPTIONS,
295-
runnerConfig: 'vitest.config.ts',
295+
runnerConfig: 'vitest.config.mts',
296296
});
297297

298298
harness.writeFile(
299-
'vitest.config.ts',
299+
'vitest.config.mts',
300300
`
301301
import { defineConfig } from 'vitest/config';
302302
export default defineConfig({
@@ -325,11 +325,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
325325
it('should initialize environment even when globals are disabled in runnerConfig file', async () => {
326326
harness.useTarget('test', {
327327
...BASE_OPTIONS,
328-
runnerConfig: 'vitest.config.ts',
328+
runnerConfig: 'vitest.config.mts',
329329
});
330330

331331
harness.writeFile(
332-
'vitest.config.ts',
332+
'vitest.config.mts',
333333
`
334334
import { defineConfig } from 'vitest/config';
335335
export default defineConfig({
@@ -357,11 +357,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
357357
it('should fail when a DOM-dependent test is run in a node environment', async () => {
358358
harness.useTarget('test', {
359359
...BASE_OPTIONS,
360-
runnerConfig: 'vitest.config.ts',
360+
runnerConfig: 'vitest.config.mts',
361361
});
362362

363363
harness.writeFile(
364-
'vitest.config.ts',
364+
'vitest.config.mts',
365365
`
366366
import { defineConfig } from 'vitest/config';
367367
export default defineConfig({
@@ -379,11 +379,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
379379
it('should warn and ignore "test.projects" option from runnerConfig file', async () => {
380380
harness.useTarget('test', {
381381
...BASE_OPTIONS,
382-
runnerConfig: 'vitest.config.ts',
382+
runnerConfig: 'vitest.config.mts',
383383
});
384384

385385
harness.writeFile(
386-
'vitest.config.ts',
386+
'vitest.config.mts',
387387
`
388388
import { defineConfig } from 'vitest/config';
389389
export default defineConfig({
@@ -411,11 +411,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
411411
it('should warn and ignore "test.include" option from runnerConfig file', async () => {
412412
harness.useTarget('test', {
413413
...BASE_OPTIONS,
414-
runnerConfig: 'vitest.config.ts',
414+
runnerConfig: 'vitest.config.mts',
415415
});
416416

417417
harness.writeFile(
418-
'vitest.config.ts',
418+
'vitest.config.mts',
419419
`
420420
import { defineConfig } from 'vitest/config';
421421
export default defineConfig({
@@ -444,11 +444,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
444444
harness.useTarget('test', {
445445
...BASE_OPTIONS,
446446
watch: false,
447-
runnerConfig: 'vitest.config.ts',
447+
runnerConfig: 'vitest.config.mts',
448448
});
449449

450450
harness.writeFile(
451-
'vitest.config.ts',
451+
'vitest.config.mts',
452452
`
453453
import { defineConfig } from 'vitest/config';
454454
export default defineConfig({
@@ -476,11 +476,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
476476
it('should warn about performance when "test.exclude" option is in runnerConfig file', async () => {
477477
harness.useTarget('test', {
478478
...BASE_OPTIONS,
479-
runnerConfig: 'vitest.config.ts',
479+
runnerConfig: 'vitest.config.mts',
480480
});
481481

482482
harness.writeFile(
483-
'vitest.config.ts',
483+
'vitest.config.mts',
484484
`
485485
import { defineConfig } from 'vitest/config';
486486
export default defineConfig({
@@ -508,11 +508,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
508508
it(`should append "test.setupFiles" (string) from runnerConfig to the CLI's setup`, async () => {
509509
harness.useTarget('test', {
510510
...BASE_OPTIONS,
511-
runnerConfig: 'vitest.config.ts',
511+
runnerConfig: 'vitest.config.mts',
512512
});
513513

514514
harness.writeFile(
515-
'vitest.config.ts',
515+
'vitest.config.mts',
516516
`
517517
import { defineConfig } from 'vitest/config';
518518
export default defineConfig({
@@ -542,11 +542,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
542542
it(`should append "test.setupFiles" (array) from runnerConfig to the CLI's setup`, async () => {
543543
harness.useTarget('test', {
544544
...BASE_OPTIONS,
545-
runnerConfig: 'vitest.config.ts',
545+
runnerConfig: 'vitest.config.mts',
546546
});
547547

548548
harness.writeFile(
549-
'vitest.config.ts',
549+
'vitest.config.mts',
550550
`
551551
import { defineConfig } from 'vitest/config';
552552
export default defineConfig({
@@ -578,11 +578,11 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
578578
it('should merge and apply custom Vite plugins from runnerConfig file', async () => {
579579
harness.useTarget('test', {
580580
...BASE_OPTIONS,
581-
runnerConfig: 'vitest.config.ts',
581+
runnerConfig: 'vitest.config.mts',
582582
});
583583

584584
harness.writeFile(
585-
'vitest.config.ts',
585+
'vitest.config.mts',
586586
`
587587
import { defineConfig } from 'vitest/config';
588588
export default defineConfig({

‎packages/angular/build/src/builders/unit-test/tests/options/runner-config_spec.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
3131

3232
describe('Vitest Runner', () => {
3333
it('should use a specified config file path', async () => {
34-
harness.writeFile('custom-vitest.config.ts', VITEST_CONFIG_CONTENT);
34+
harness.writeFile('custom-vitest.config.mts', VITEST_CONFIG_CONTENT);
3535
harness.useTarget('test', {
3636
...BASE_OPTIONS,
37-
runnerConfig: 'custom-vitest.config.ts',
37+
runnerConfig: 'custom-vitest.config.mts',
3838
});
3939

4040
const { result } = await harness.executeOnce();
@@ -96,7 +96,7 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
9696

9797
it('should find and use a `vitest-base.config.js` in the workspace root', async () => {
9898
// This file should be ignored because the new logic looks for `vitest-base.config.*`.
99-
harness.writeFile('vitest.config.ts', VITEST_CONFIG_CONTENT);
99+
harness.writeFile('vitest.config.mts', VITEST_CONFIG_CONTENT);
100100
// The workspace root is the directory containing the project root in the test harness.
101101
harness.writeFile('vitest-base.config.js', VITEST_CONFIG_CONTENT);
102102
harness.useTarget('test', {
@@ -113,7 +113,7 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => {
113113
it('should fallback to in-memory config when no base config is found', async () => {
114114
// This file should be ignored because the new logic looks for `vitest-base.config.*`
115115
// and when `runnerConfig` is true, it should not fall back to the default search.
116-
harness.writeFile('vitest.config.ts', VITEST_CONFIG_CONTENT);
116+
harness.writeFile('vitest.config.mts', VITEST_CONFIG_CONTENT);
117117
harness.useTarget('test', {
118118
...BASE_OPTIONS,
119119
runnerConfig: true,
File renamed without changes.
File renamed without changes.

‎tests/e2e/tests/vitest/browser-coverage-istanbul.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { ng } from '../../utils/process';
22
import { applyVitestBuilder } from '../../utils/vitest';
33
import assert from 'node:assert';
4-
import { installPackage } from '../../utils/packages';
54
import { expectFileToExist, readFile } from '../../utils/fs';
65
import { updateJsonFile } from '../../utils/project';
76

87
export default async function (): Promise<void> {
9-
await applyVitestBuilder();
10-
118
// Install ONLY Istanbul coverage package.
129
// This will trigger the auto-detection logic to use Istanbul even for Node tests.
13-
await installPackage('@vitest/coverage-istanbul@4');
10+
await applyVitestBuilder({
11+
coverageIstanbul: true,
12+
});
1413

1514
// Use the 'json' reporter to get a machine-readable output for assertions.
1615
await updateJsonFile('angular.json', (json) => {

‎tests/e2e/tests/vitest/browser-coverage-sourcemaps.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import assert from 'node:assert/strict';
22
import { applyVitestBuilder } from '../../utils/vitest';
33
import { ng } from '../../utils/process';
4-
import { installPackage } from '../../utils/packages';
54
import { expectFileToExist, readFile } from '../../utils/fs';
65

76
export default async function (): Promise<void> {
8-
await applyVitestBuilder();
9-
await installPackage('playwright@1');
10-
await installPackage('@vitest/browser-playwright@4');
11-
await installPackage('@vitest/coverage-v8@4');
7+
await applyVitestBuilder({
8+
playwright: true,
9+
coverageV8: true,
10+
});
1211

1312
// Run tests with coverage in browser mode.
1413
// We use the default passing tests generated for the project.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL