@nx/vitest 23.0.0 → 23.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,13 +7,12 @@
7
7
 
8
8
  <div style="text-align: center;">
9
9
 
10
- [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
10
  [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
11
  [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
13
12
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
13
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
- [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
14
  [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
15
+ [![Nx Sandboxing](https://staging.nx.app/workspaces/62d013ea0852fe0a2df74438/sandbox-badge.svg)](https://nx.dev/docs/features/ci-features/sandboxing)
17
16
 
18
17
  </div>
19
18
 
@@ -20,8 +20,13 @@ async function getOptions(options, context, projectRoot) {
20
20
  You can read more here: https://nx.dev/nx-api/vitest/generators/configuration
21
21
  `);
22
22
  }
23
+ // Vitest derives the Vite config mode as `options.mode || runMode`, where
24
+ // runMode defaults to 'test' (or 'benchmark'). Resolve it once and reuse it
25
+ // for both this pre-load and the value forwarded to vitest below, so the
26
+ // config file resolves its mode-based branches identically on both loads.
27
+ const mode = options.mode ?? options.runMode ?? 'test';
23
28
  const resolved = await loadConfigFromFile({
24
- mode: options?.mode ?? 'test',
29
+ mode,
25
30
  command: 'serve',
26
31
  }, viteConfigPath);
27
32
  if (!resolved?.config?.['test']) {
@@ -54,6 +59,10 @@ async function getOptions(options, context, projectRoot) {
54
59
  // but leaving it here in case someone did not migrate correctly
55
60
  root: resolved?.config?.root ?? root,
56
61
  config: viteConfigPath,
62
+ // Forward the resolved mode so vitest reloads the config file with it;
63
+ // otherwise it falls back to its run-mode default and drops mode-based
64
+ // settings the pre-load above resolved (e.g. outputFile, coverage.reporter).
65
+ mode,
57
66
  // Vitest's resolveConfig processes reporters in two steps:
58
67
  // 1. options.reporters (plural) sets resolved.reporters
59
68
  // 2. resolved.reporter (singular, from config) overwrites resolved.reporters
@@ -191,19 +191,26 @@ getTestBed().initTestEnvironment(
191
191
  }
192
192
  return (0, devkit_1.runTasksInSerial)(...tasks);
193
193
  }
194
+ function addTypeIfMissing(json, type) {
195
+ if (json.compilerOptions?.types?.includes(type)) {
196
+ return;
197
+ }
198
+ if (json.compilerOptions?.types) {
199
+ json.compilerOptions.types.push(type);
200
+ }
201
+ else {
202
+ json.compilerOptions ??= {};
203
+ json.compilerOptions.types = [type];
204
+ }
205
+ }
194
206
  function updateTsConfig(tree, options, projectRoot, projectType) {
195
207
  const setupFile = tryFindSetupFile(tree, projectRoot);
196
208
  if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.spec.json'))) {
197
209
  (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.spec.json'), (json) => {
198
- if (!json.compilerOptions?.types?.includes('vitest')) {
199
- if (json.compilerOptions?.types) {
200
- json.compilerOptions.types.push('vitest');
201
- }
202
- else {
203
- json.compilerOptions ??= {};
204
- json.compilerOptions.types = ['vitest'];
205
- }
206
- }
210
+ // vite/client is correct for anything vitest runs through vite;
211
+ // guarded so it's a no-op when react/vue already set it.
212
+ addTypeIfMissing(json, 'vitest');
213
+ addTypeIfMissing(json, 'vite/client');
207
214
  if (setupFile) {
208
215
  json.files = [...(json.files ?? []), setupFile];
209
216
  }
@@ -221,15 +228,8 @@ function updateTsConfig(tree, options, projectRoot, projectType) {
221
228
  }
222
229
  else {
223
230
  (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.json'), (json) => {
224
- if (!json.compilerOptions?.types?.includes('vitest')) {
225
- if (json.compilerOptions?.types) {
226
- json.compilerOptions.types.push('vitest');
227
- }
228
- else {
229
- json.compilerOptions ??= {};
230
- json.compilerOptions.types = ['vitest'];
231
- }
232
- }
231
+ addTypeIfMissing(json, 'vitest');
232
+ addTypeIfMissing(json, 'vite/client');
233
233
  return json;
234
234
  });
235
235
  }
@@ -1,2 +1,2 @@
1
1
  export declare function loadViteDynamicImport(): Promise<any>;
2
- export declare function loadVitestDynamicImport(): Promise<typeof import("vitest/node")>;
2
+ export declare function loadVitestDynamicImport(): Promise<typeof import('vitest/node')>;
@@ -14,10 +14,10 @@ export declare const vitePluginReactSwcVersion = "^4.3.0";
14
14
  export declare const jsdomVersion = "^27.1.0";
15
15
  export declare const vitePluginDtsVersion = "~4.5.0";
16
16
  export declare const ajvVersion = "^8.0.0";
17
- export declare const happyDomVersion = "~9.20.3";
17
+ export declare const happyDomVersion = "^20.10.4";
18
18
  export declare const edgeRuntimeVmVersion = "~3.0.2";
19
19
  export declare const jitiVersion = "2.4.2";
20
- export declare const analogVitestAngular = "~2.1.2";
20
+ export declare const analogVitestAngular = "~2.6.0";
21
21
  type VitestVersions = {
22
22
  vitestVersion: string;
23
23
  vitestCoverageV8Version: string;
@@ -23,10 +23,10 @@ exports.vitePluginReactSwcVersion = '^4.3.0';
23
23
  exports.jsdomVersion = '^27.1.0';
24
24
  exports.vitePluginDtsVersion = '~4.5.0';
25
25
  exports.ajvVersion = '^8.0.0';
26
- exports.happyDomVersion = '~9.20.3';
26
+ exports.happyDomVersion = '^20.10.4';
27
27
  exports.edgeRuntimeVmVersion = '~3.0.2';
28
28
  exports.jitiVersion = '2.4.2';
29
- exports.analogVitestAngular = '~2.1.2';
29
+ exports.analogVitestAngular = '~2.6.0';
30
30
  const latestVersions = {
31
31
  vitestVersion: exports.vitestVersion,
32
32
  vitestCoverageV8Version: exports.vitestCoverageV8Version,
package/migrations.json CHANGED
@@ -109,6 +109,31 @@
109
109
  "alwaysAddToPackageJson": false
110
110
  }
111
111
  }
112
+ },
113
+ "23.0.1-happy-dom": {
114
+ "version": "23.0.1",
115
+ "requires": {
116
+ "happy-dom": "<=20.10.4"
117
+ },
118
+ "packages": {
119
+ "happy-dom": {
120
+ "version": "^20.10.4",
121
+ "alwaysAddToPackageJson": false
122
+ }
123
+ }
124
+ },
125
+ "23.1.0-analog": {
126
+ "version": "23.1.0-beta.0",
127
+ "packages": {
128
+ "@analogjs/vite-plugin-angular": {
129
+ "version": "~2.6.0",
130
+ "alwaysAddToPackageJson": false
131
+ },
132
+ "@analogjs/vitest-angular": {
133
+ "version": "~2.6.0",
134
+ "alwaysAddToPackageJson": false
135
+ }
136
+ }
112
137
  }
113
138
  }
114
139
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nx/vitest",
3
3
  "description": "The Nx Plugin for Vitest to enable fast unit testing with Vitest.",
4
- "version": "23.0.0",
4
+ "version": "23.1.0-beta.0",
5
5
  "type": "commonjs",
6
6
  "files": [
7
7
  "dist",
@@ -73,13 +73,13 @@
73
73
  "tslib": "^2.3.0",
74
74
  "semver": "^7.6.3",
75
75
  "@phenomnomnominal/tsquery": "~6.2.0",
76
- "@nx/devkit": "23.0.0",
77
- "@nx/js": "23.0.0"
76
+ "@nx/devkit": "23.1.0-beta.0",
77
+ "@nx/js": "23.1.0-beta.0"
78
78
  },
79
79
  "peerDependencies": {
80
80
  "vitest": "^3.0.0 || ^4.0.0",
81
81
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
82
- "@nx/eslint": "23.0.0"
82
+ "@nx/eslint": "23.1.0-beta.0"
83
83
  },
84
84
  "peerDependenciesMeta": {
85
85
  "@nx/eslint": {
@@ -93,6 +93,6 @@
93
93
  }
94
94
  },
95
95
  "devDependencies": {
96
- "nx": "23.0.0"
96
+ "nx": "23.1.0-beta.0"
97
97
  }
98
98
  }