Skip to content

Commit 13f63eb

Browse files
authored
fix(vite): set name property for test to project name #32163 (#32308)
## Current Behavior The `name` property is not set for vitest configs. Vitest will therefore infer the name for the test suite based off the directory name. In a monorepo this can cause issues as the directory name may be repeated but for different contexts. ## Expected Behavior Set the project name as the name in the test config ## Related Issue(s) Fixes #32163
1 parent 94c7b7e commit 13f63eb

16 files changed

Lines changed: 39 additions & 10 deletions

File tree

packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`app generated files content - as-provided - my-app general application should add nuxt entries in .gitignore 1`] = `
44
"# Nuxt dev/build outputs
@@ -173,6 +173,7 @@ export default defineConfig(() => ({
173173
// plugins: [ nxViteTsPaths() ],
174174
// },
175175
test: {
176+
name: 'my-app',
176177
watch: false,
177178
globals: true,
178179
environment: 'jsdom',
@@ -566,6 +567,7 @@ export default defineConfig(() => ({
566567
// plugins: [ nxViteTsPaths() ],
567568
// },
568569
test: {
570+
name: 'myApp',
569571
watch: false,
570572
globals: true,
571573
environment: 'jsdom',

packages/react/src/generators/application/__snapshots__/application.spec.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`app --bundler=rsbuild should generate valid rsbuild config files for @emotion/styled 1`] = `
44
"import styled from '@emotion/styled';
@@ -445,6 +445,7 @@ export default defineConfig(() => ({
445445
},
446446
},
447447
test: {
448+
name: 'my-app',
448449
watch: false,
449450
globals: true,
450451
environment: 'jsdom',
@@ -508,6 +509,7 @@ export default defineConfig(() => ({
508509
},
509510
},
510511
test: {
512+
name: 'my-app',
511513
watch: false,
512514
globals: true,
513515
environment: 'jsdom',

packages/react/src/generators/application/application.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ describe('app', () => {
11151115
},
11161116
},
11171117
test: {
1118+
name: 'my-app',
11181119
watch: false,
11191120
globals: true,
11201121
environment: 'jsdom',

packages/react/src/generators/library/__snapshots__/library.spec.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`lib --bundler none, unit test runner vitest should configure vite 1`] = `
44
"
@@ -16,6 +16,7 @@ export default defineConfig(() => ({
1616
// plugins: [ nxViteTsPaths() ],
1717
// },
1818
test: {
19+
'name': 'my-lib',
1920
'watch': false,
2021
'globals': true,
2122
'environment': "jsdom",
@@ -135,6 +136,7 @@ export default defineConfig(() => ({
135136
},
136137
},
137138
test: {
139+
name: 'my-lib',
138140
watch: false,
139141
globals: true,
140142
environment: 'jsdom',

packages/react/src/generators/library/library.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ module.exports = withNx(
10171017
},
10181018
},
10191019
test: {
1020+
name: '@proj/mylib',
10201021
watch: false,
10211022
globals: true,
10221023
environment: 'jsdom',

packages/remix/src/generators/application/__snapshots__/application.impl.spec.ts.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Remix Application Integrated Repo --directory should create the application correctly 1`] = `
44
"import {
@@ -262,6 +262,7 @@ export default defineConfig(() => ({
262262
// },
263263
test: {
264264
setupFiles: ['test-setup.ts'],
265+
name: 'test',
265266
watch: false,
266267
globals: true,
267268
environment: 'jsdom',
@@ -465,6 +466,7 @@ export default defineConfig(() => ({
465466
// },
466467
test: {
467468
setupFiles: ['test-setup.ts'],
469+
name: 'test',
468470
watch: false,
469471
globals: true,
470472
environment: 'jsdom',

packages/remix/src/generators/library/__snapshots__/library.impl.spec.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Remix Library Generator --unitTestRunner should create the correct config files for testing with jest 1`] = `
44
"export default {
@@ -38,6 +38,7 @@ export default defineConfig(() => ({
3838
// },
3939
test: {
4040
setupFiles: ['./src/test-setup.ts'],
41+
name: 'test',
4142
watch: false,
4243
globals: true,
4344
environment: 'jsdom',

packages/remix/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`Storybook Configuration it should create a storybook configuration and use react-vite framework with testing framework jest 1`] = `
44
"/// <reference types="vitest" />
@@ -102,6 +102,7 @@ export default defineConfig(() => ({
102102
// },
103103
test: {
104104
setupFiles: ['./src/test-setup.ts'],
105+
name: 'storybook-test',
105106
watch: false,
106107
globals: true,
107108
environment: 'jsdom',

packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`@nx/vite:configuration js library with --bundler=vite should add build and test targets with vite and vitest 1`] = `
44
"/// <reference types='vitest' />
@@ -48,6 +48,7 @@ export default defineConfig(() => ({
4848
},
4949
},
5050
test: {
51+
name: 'my-lib',
5152
watch: false,
5253
globals: true,
5354
environment: 'jsdom',
@@ -273,6 +274,7 @@ export default defineConfig(() => ({
273274
},
274275
},
275276
test: {
277+
name: 'react-lib-nonb-jest',
276278
watch: false,
277279
globals: true,
278280
environment: 'jsdom',
@@ -484,6 +486,7 @@ export default defineConfig(() => ({
484486
},
485487
},
486488
test: {
489+
name: 'my-test-react-app',
487490
watch: false,
488491
globals: true,
489492
environment: 'jsdom',

packages/vite/src/generators/vitest/__snapshots__/vitest.spec.ts.snap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`vitest generator angular should generate src/test-setup.ts 1`] = `
44
"import '@angular/compiler';
@@ -33,6 +33,7 @@ export default defineConfig(() => ({
3333
// plugins: [ nxViteTsPaths() ],
3434
// },
3535
test: {
36+
name: 'my-test-angular-app',
3637
watch: false,
3738
globals: true,
3839
environment: 'jsdom',
@@ -67,6 +68,7 @@ export default defineConfig(() => ({
6768
'import.meta.vitest': undefined,
6869
},
6970
test: {
71+
name: 'my-test-react-app',
7072
watch: false,
7173
globals: true,
7274
environment: 'jsdom',
@@ -106,6 +108,7 @@ export default defineConfig(() => ({
106108
// plugins: [ nxViteTsPaths() ],
107109
// },
108110
test: {
111+
name: 'react-lib-nonb-jest',
109112
watch: false,
110113
globals: true,
111114
environment: 'jsdom',
@@ -136,6 +139,7 @@ export default defineConfig(() => ({
136139
// plugins: [ nxViteTsPaths() ],
137140
// },
138141
test: {
142+
name: 'my-test-react-app',
139143
watch: false,
140144
globals: true,
141145
environment: 'jsdom',

0 commit comments

Comments
 (0)