diff --git a/e2e/nx-init/src/nx-init-react.test.ts b/e2e/nx-init/src/nx-init-react.test.ts index 51924506914e03..947427a72cbd1d 100644 --- a/e2e/nx-init/src/nx-init-react.test.ts +++ b/e2e/nx-init/src/nx-init-react.test.ts @@ -163,7 +163,6 @@ describe('nx init (for React - legacy)', () => { ); const packageJson = readJson('package.json'); - expect(packageJson.devDependencies['@nx/jest']).toBeUndefined(); expect(packageJson.dependencies['redux']).toBeDefined(); expect(packageJson.name).toEqual(appName); diff --git a/e2e/react/src/react-vite.test.ts b/e2e/react/src/react-vite.test.ts index 877bd91be65a34..51f133285566c3 100644 --- a/e2e/react/src/react-vite.test.ts +++ b/e2e/react/src/react-vite.test.ts @@ -151,4 +151,20 @@ describe('Build React applications and libraries with Vite', () => { `dist/libs/${nonBuildableLib}/index.mjs` ); }, 300_000); + + it('should support bundling with Vite and Jest', async () => { + const viteApp = uniq('viteapp'); + + runCLI( + `generate @nx/react:app ${viteApp} --bundler=vite --unitTestRunner=jest --no-interactive` + ); + + const appTestResults = await runCLIAsync(`test ${viteApp}`); + expect(appTestResults.combinedOutput).toContain( + 'Successfully ran target test' + ); + + await runCLIAsync(`build ${viteApp}`); + checkFilesExist(`dist/apps/${viteApp}/index.html`); + }, 300_000); }); diff --git a/packages/react/src/generators/application/__snapshots__/application.legacy.spec.ts.snap b/packages/react/src/generators/application/__snapshots__/application.legacy.spec.ts.snap index 874086306902c2..9e07d922b0b7a6 100644 --- a/packages/react/src/generators/application/__snapshots__/application.legacy.spec.ts.snap +++ b/packages/react/src/generators/application/__snapshots__/application.legacy.spec.ts.snap @@ -38,19 +38,6 @@ nxViteTsPaths()], }, - test: { - globals: true, - cache: { - dir: '../node_modules/.vitest/my-vite-app' - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - - reporters: ['default'], - coverage: { - reportsDirectory: '../coverage/my-vite-app', - provider: 'v8', - } - }, + });" `; diff --git a/packages/react/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/react/src/generators/application/__snapshots__/application.spec.ts.snap index 95ab50d4788385..d0b6a87cbb12dd 100644 --- a/packages/react/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/react/src/generators/application/__snapshots__/application.spec.ts.snap @@ -126,20 +126,7 @@ nxViteTsPaths()], }, - test: { - globals: true, - cache: { - dir: '../node_modules/.vitest/my-app' - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - - reporters: ['default'], - coverage: { - reportsDirectory: '../coverage/my-app', - provider: 'v8', - } - }, + });" `; @@ -217,20 +204,7 @@ nxViteTsPaths()], }, - test: { - globals: true, - cache: { - dir: '../node_modules/.vitest/my-app' - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - - reporters: ['default'], - coverage: { - reportsDirectory: '../coverage/my-app', - provider: 'v8', - } - }, + });" `; @@ -355,20 +329,7 @@ nxViteTsPaths()], }, - test: { - globals: true, - cache: { - dir: '../node_modules/.vitest/my-app' - }, - environment: 'jsdom', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - - reporters: ['default'], - coverage: { - reportsDirectory: '../coverage/my-app', - provider: 'v8', - } - }, + });" `; diff --git a/packages/react/src/generators/application/lib/normalize-options.ts b/packages/react/src/generators/application/lib/normalize-options.ts index 50fb57d440ff0b..136f50b820dd56 100644 --- a/packages/react/src/generators/application/lib/normalize-options.ts +++ b/packages/react/src/generators/application/lib/normalize-options.ts @@ -95,10 +95,6 @@ export async function normalizeOptions( assertValidStyle(options.style); - if (options.bundler === 'vite' && options.unitTestRunner !== 'none') { - options.unitTestRunner = 'vitest'; - } - const normalized = { ...options, name: names(options.name).fileName, diff --git a/packages/web/src/generators/application/application.ts b/packages/web/src/generators/application/application.ts index cac278d7705255..74884c63e3ebc5 100644 --- a/packages/web/src/generators/application/application.ts +++ b/packages/web/src/generators/application/application.ts @@ -522,10 +522,6 @@ async function normalizeOptions( ? options.tags.split(',').map((s) => s.trim()) : []; - if (options.bundler === 'vite' && options.unitTestRunner !== 'none') { - options.unitTestRunner = 'vitest'; - } - options.style = options.style || 'css'; options.linter = options.linter || ('eslint' as Linter.EsLint); options.unitTestRunner = options.unitTestRunner || 'jest';