Skip to content

Commit

Permalink
fix(react): respect unitTestRunner passed to the generator
Browse files Browse the repository at this point in the history
closes: #22276
  • Loading branch information
ndcunningham committed May 15, 2024
1 parent 1acbc7e commit 9f3c329
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 60 deletions.
16 changes: 16 additions & 0 deletions e2e/react/src/react-vite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
},
});"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
},
});"
`;

Expand Down Expand Up @@ -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',
}
},
});"
`;

Expand Down Expand Up @@ -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',
}
},
});"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ export async function normalizeOptions<T extends Schema = Schema>(

assertValidStyle(options.style);

if (options.bundler === 'vite' && options.unitTestRunner !== 'none') {
options.unitTestRunner = 'vitest';
}

const normalized = {
...options,
name: names(options.name).fileName,
Expand Down

0 comments on commit 9f3c329

Please sign in to comment.