@nx/vitest 23.2.0-beta.6 → 23.2.0-beta.8
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/dist/internal.d.ts +6 -0
- package/dist/internal.js +14 -0
- package/dist/src/generators/configuration/configuration.js +2 -0
- package/dist/src/generators/configuration/schema.d.ts +1 -0
- package/dist/src/generators/configuration/schema.json +6 -0
- package/dist/src/utils/generator-utils.d.ts +1 -0
- package/dist/src/utils/generator-utils.js +2 -0
- package/dist/src/utils/ignore-vitest-temp-files.d.ts +0 -1
- package/dist/src/utils/ignore-vitest-temp-files.js +4 -14
- package/package.json +13 -5
package/dist/internal.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Semi-private surface for first-party Nx packages.
|
|
3
|
+
//
|
|
4
|
+
// External plugins should NOT import from here — this entry is curated for
|
|
5
|
+
// internal consumers and may change without semver protection. Mirrors
|
|
6
|
+
// `@nx/devkit/internal`.
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.oxlintPlugins = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* The Oxlint plugins a Vitest-tested project needs. Declared here so the linter
|
|
11
|
+
* does not have to know what a test runner requires; `@nx/js`'s
|
|
12
|
+
* `addLintingToProject` reads it through `ensurePackage`.
|
|
13
|
+
*/
|
|
14
|
+
exports.oxlintPlugins = ['vitest'];
|
|
@@ -132,6 +132,7 @@ getTestBed().initTestEnvironment(
|
|
|
132
132
|
imports: [`import angular from '@analogjs/vite-plugin-angular'`],
|
|
133
133
|
plugins: ['angular()'],
|
|
134
134
|
setupFile: relativeTestSetupPath,
|
|
135
|
+
passWithNoTests: schema.passWithNoTests,
|
|
135
136
|
useEsmExtension: true,
|
|
136
137
|
}, true, { skipPackageJson: schema.skipPackageJson });
|
|
137
138
|
}
|
|
@@ -155,6 +156,7 @@ getTestBed().initTestEnvironment(
|
|
|
155
156
|
coverageProvider: schema.coverageProvider === 'none'
|
|
156
157
|
? undefined
|
|
157
158
|
: schema.coverageProvider,
|
|
159
|
+
passWithNoTests: schema.passWithNoTests,
|
|
158
160
|
useEsmExtension: true,
|
|
159
161
|
}, true, { skipPackageJson: schema.skipPackageJson });
|
|
160
162
|
}
|
|
@@ -11,6 +11,7 @@ export interface VitestGeneratorSchema {
|
|
|
11
11
|
addPlugin?: boolean;
|
|
12
12
|
runtimeTsconfigFileName?: string;
|
|
13
13
|
compiler?: 'babel' | 'swc'; // default: babel
|
|
14
|
+
passWithNoTests?: boolean;
|
|
14
15
|
// internal options
|
|
15
16
|
projectType?: 'application' | 'library';
|
|
16
17
|
viteVersion?: 5 | 6 | 7 | 8;
|
|
@@ -66,6 +66,12 @@
|
|
|
66
66
|
"description": "Do not add dependencies to `package.json`.",
|
|
67
67
|
"x-priority": "internal"
|
|
68
68
|
},
|
|
69
|
+
"passWithNoTests": {
|
|
70
|
+
"type": "boolean",
|
|
71
|
+
"default": false,
|
|
72
|
+
"description": "Exit with a zero status when the project has no test files.",
|
|
73
|
+
"x-priority": "internal"
|
|
74
|
+
},
|
|
69
75
|
"zoneless": {
|
|
70
76
|
"type": "boolean",
|
|
71
77
|
"description": "Whether the Angular project is zoneless. When not provided, it is auto-detected from the project configuration.",
|
|
@@ -119,6 +119,7 @@ function createOrEditViteConfig(tree, options, onlyVitest, extraOptions = {}) {
|
|
|
119
119
|
globals: true,
|
|
120
120
|
environment: '${options.testEnvironment ?? 'jsdom'}',
|
|
121
121
|
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
122
|
+
${options.passWithNoTests ? ` passWithNoTests: true,\n` : ''}\
|
|
122
123
|
${options.setupFile ? ` setupFiles: ['${options.setupFile}'],\n` : ''}\
|
|
123
124
|
${options.inSourceTests
|
|
124
125
|
? ` includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n`
|
|
@@ -229,6 +230,7 @@ function handleViteConfigFileExists(tree, viteConfigPath, options, buildOption,
|
|
|
229
230
|
globals: true,
|
|
230
231
|
environment: options.testEnvironment ?? 'jsdom',
|
|
231
232
|
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
233
|
+
...(options.passWithNoTests ? { passWithNoTests: true } : {}),
|
|
232
234
|
reporters: ['default'],
|
|
233
235
|
coverage: {
|
|
234
236
|
reportsDirectory: reportsDirectory,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
2
|
export declare function ignoreVitestTempFiles(tree: Tree, projectRoot?: string | undefined): Promise<void>;
|
|
3
3
|
export declare function addVitestTempFilesToGitIgnore(tree: Tree): void;
|
|
4
|
-
export declare function isEslintInstalled(tree: Tree): boolean;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ignoreVitestTempFiles = ignoreVitestTempFiles;
|
|
4
4
|
exports.addVitestTempFilesToGitIgnore = addVitestTempFilesToGitIgnore;
|
|
5
|
-
exports.isEslintInstalled = isEslintInstalled;
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const internal_1 = require("@nx/js/internal");
|
|
7
7
|
const versions_1 = require("./versions");
|
|
8
8
|
async function ignoreVitestTempFiles(tree, projectRoot) {
|
|
9
9
|
addVitestTempFilesToGitIgnore(tree);
|
|
@@ -20,7 +20,9 @@ function addVitestTempFilesToGitIgnore(tree) {
|
|
|
20
20
|
tree.write('.gitignore', gitIgnoreContents);
|
|
21
21
|
}
|
|
22
22
|
async function ignoreVitestTempFilesInEslintConfig(tree, projectRoot) {
|
|
23
|
-
|
|
23
|
+
// Checked before `ensurePackage` so an Oxlint workspace does not install
|
|
24
|
+
// `@nx/eslint` only for `isEslintConfigSupported` to send it straight back.
|
|
25
|
+
if (!(0, internal_1.detectLinters)(tree).includes('eslint')) {
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
26
28
|
(0, devkit_1.ensurePackage)('@nx/eslint', versions_1.nxVersion);
|
|
@@ -45,15 +47,3 @@ async function ignoreVitestTempFilesInEslintConfig(tree, projectRoot) {
|
|
|
45
47
|
const directory = isUsingFlatConfig ? '' : (projectRoot ?? '');
|
|
46
48
|
addIgnoresToLintConfig(tree, directory, ['**/vitest.config.*.timestamp*']);
|
|
47
49
|
}
|
|
48
|
-
function isEslintInstalled(tree) {
|
|
49
|
-
try {
|
|
50
|
-
require('eslint');
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
catch { }
|
|
54
|
-
// it might not be installed yet, but it might be in the tree pending install
|
|
55
|
-
const { devDependencies, dependencies } = tree.exists('package.json')
|
|
56
|
-
? (0, devkit_1.readJson)(tree, 'package.json')
|
|
57
|
-
: {};
|
|
58
|
-
return !!devDependencies?.['eslint'] || !!dependencies?.['eslint'];
|
|
59
|
-
}
|
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.2.0-beta.
|
|
4
|
+
"version": "23.2.0-beta.8",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"generators": [
|
|
38
38
|
"dist/generators.d.ts"
|
|
39
39
|
],
|
|
40
|
+
"internal": [
|
|
41
|
+
"dist/internal.d.ts"
|
|
42
|
+
],
|
|
40
43
|
"executors": [
|
|
41
44
|
"dist/executors.d.ts"
|
|
42
45
|
]
|
|
@@ -57,6 +60,11 @@
|
|
|
57
60
|
"types": "./dist/generators.d.ts",
|
|
58
61
|
"default": "./dist/generators.js"
|
|
59
62
|
},
|
|
63
|
+
"./internal": {
|
|
64
|
+
"@nx/nx-source": "./internal.ts",
|
|
65
|
+
"types": "./dist/internal.d.ts",
|
|
66
|
+
"default": "./dist/internal.js"
|
|
67
|
+
},
|
|
60
68
|
"./executors": {
|
|
61
69
|
"@nx/nx-source": "./executors.ts",
|
|
62
70
|
"types": "./dist/executors.d.ts",
|
|
@@ -73,13 +81,13 @@
|
|
|
73
81
|
"tslib": "^2.3.0",
|
|
74
82
|
"semver": "^7.6.3",
|
|
75
83
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
76
|
-
"@nx/devkit": "23.2.0-beta.
|
|
77
|
-
"@nx/js": "23.2.0-beta.
|
|
84
|
+
"@nx/devkit": "23.2.0-beta.8",
|
|
85
|
+
"@nx/js": "23.2.0-beta.8"
|
|
78
86
|
},
|
|
79
87
|
"peerDependencies": {
|
|
80
88
|
"vitest": "^3.0.0 || ^4.0.0",
|
|
81
89
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
82
|
-
"@nx/eslint": "23.2.0-beta.
|
|
90
|
+
"@nx/eslint": "23.2.0-beta.8"
|
|
83
91
|
},
|
|
84
92
|
"peerDependenciesMeta": {
|
|
85
93
|
"@nx/eslint": {
|
|
@@ -93,6 +101,6 @@
|
|
|
93
101
|
}
|
|
94
102
|
},
|
|
95
103
|
"devDependencies": {
|
|
96
|
-
"nx": "23.2.0-beta.
|
|
104
|
+
"nx": "23.2.0-beta.8"
|
|
97
105
|
}
|
|
98
106
|
}
|