Skip to content

Commit

Permalink
feat(vite): set watch:false in test config by default (#26267)
Browse files Browse the repository at this point in the history
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->
Currently, running vitest with inference will result in a process that
waits for the user to end it as vitest defaults to running in watch
mode.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
We should set watch:false to allow users to specifically choose watch
mode by passing `--watch`

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
  • Loading branch information
Coly010 authored May 30, 2024
1 parent e647719 commit fb04300
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default defineConfig({
// },
test: {
watch: false,
globals: true,
cache: {
dir: '../node_modules/.vitest/my-app',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ nxViteTsPaths(),
test: {
'globals': true,
'watch': false,
'globals': true,
'cache': {"dir":"../node_modules/.vitest/my-lib"},
'environment': "jsdom",
'include': ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
Expand Down Expand Up @@ -83,6 +84,7 @@ dts({ entryRoot: 'src', tsconfigPath: path.join(__dirname, 'tsconfig.lib.json')
},
test: {
watch: false,
globals: true,
cache: {
dir: '../node_modules/.vitest/my-lib'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export default defineConfig({
test: {
setupFiles: ['test-setup.ts'],
watch: false,
globals: true,
cache: {
dir: '../node_modules/.vitest/test',
Expand Down Expand Up @@ -897,6 +898,7 @@ export default defineConfig({
test: {
setupFiles: ['test-setup.ts'],
watch: false,
globals: true,
cache: {
dir: '../../node_modules/.vitest/apps/test',
Expand Down Expand Up @@ -1217,6 +1219,7 @@ export default defineConfig({
test: {
setupFiles: ['test-setup.ts'],
watch: false,
globals: true,
cache: {
dir: './node_modules/.vitest/test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default defineConfig({
test: {
setupFiles: ['./src/test-setup.ts'],
watch: false,
globals: true,
cache: { dir: '../node_modules/.vitest/test' },
environment: 'jsdom',
Expand Down Expand Up @@ -119,6 +120,7 @@ export default defineConfig({
test: {
setupFiles: ['./src/test-setup.ts'],
watch: false,
globals: true,
cache: { dir: '../../node_modules/.vitest/libs/test' },
environment: 'jsdom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default defineConfig({
test: {
setupFiles: ['./src/test-setup.ts'],
watch: false,
globals: true,
cache: { dir: '../../node_modules/.vitest/libs/storybook-test' },
environment: 'jsdom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: '../node_modules/.vitest/my-lib',
Expand Down Expand Up @@ -267,6 +268,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: '../../node_modules/.vitest/libs/react-lib-nonb-jest',
Expand Down Expand Up @@ -493,6 +495,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: '../../node_modules/.vitest/apps/my-test-react-app',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default defineConfig({
'import.meta.vitest': undefined,
},
test: {
watch: false,
globals: true,
cache: {
dir: '../../node_modules/.vitest/apps/my-test-react-app',
Expand Down Expand Up @@ -61,6 +62,7 @@ export default defineConfig({
// },
test: {
watch: false,
globals: true,
cache: {
dir: '../../node_modules/.vitest/apps/my-test-react-app',
Expand Down Expand Up @@ -96,6 +98,7 @@ export default defineConfig({
// },
test: {
watch: false,
globals: true,
cache: {
dir: '../../node_modules/.vitest/libs/react-lib-nonb-jest',
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/utils/generator-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ export function createOrEditViteConfig(

const testOption = options.includeVitest
? `test: {
watch: false,
globals: true,
cache: {
dir: '${normalizedJoinPaths(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: '../node_modules/.vitest/test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: '../node_modules/.vitest/my-lib',
Expand Down Expand Up @@ -147,6 +148,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: '../node_modules/.vitest/my-lib',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: './node_modules/.vitest/proj',
Expand Down Expand Up @@ -194,6 +195,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: '../../node_modules/.vitest/apps/proj',
Expand Down Expand Up @@ -248,6 +250,7 @@ export default defineConfig({
},
test: {
watch: false,
globals: true,
cache: {
dir: './node_modules/.vitest/proj',
Expand Down

0 comments on commit fb04300

Please sign in to comment.