vitest-runner 1.0.0 → 1.0.1
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 +3 -8
- package/package.json +1 -1
- package/src/runner.mjs +4 -5
- package/types/src/runner.d.mts +2 -2
package/README.md
CHANGED
|
@@ -149,7 +149,6 @@ Runs the test suite and resolves with an exit code (`0` = all passed, `1` = any
|
|
|
149
149
|
import { run } from 'vitest-runner';
|
|
150
150
|
|
|
151
151
|
const code = await run({
|
|
152
|
-
cwd: process.cwd(),
|
|
153
152
|
testDir: 'src/tests',
|
|
154
153
|
});
|
|
155
154
|
|
|
@@ -160,7 +159,7 @@ process.exit(code);
|
|
|
160
159
|
|
|
161
160
|
| Option | Type | Default | Description |
|
|
162
161
|
|--------|------|---------|-------------|
|
|
163
|
-
| `cwd` | `string` |
|
|
162
|
+
| `cwd` | `string` | `process.cwd()` | Absolute project root directory |
|
|
164
163
|
| `testDir` | `string` | `cwd` | Directory (absolute or relative to `cwd`) to scan for `*.test.vitest.{js,mjs}` files |
|
|
165
164
|
| `vitestConfig` | `string` | auto-detect | Explicit vitest config path; when omitted the runner walks standard config names (`vitest.config.ts`, `vite.config.ts`, etc.) relative to `cwd` |
|
|
166
165
|
| `testPatterns` | `string[]` | `[]` | File / folder patterns to filter — empty means all files in `testDir` |
|
|
@@ -188,33 +187,29 @@ process.exit(code);
|
|
|
188
187
|
#### Examples
|
|
189
188
|
|
|
190
189
|
```js
|
|
191
|
-
// Run all tests under src/tests/
|
|
192
|
-
await run({
|
|
190
|
+
// Run all tests under src/tests/ (cwd defaults to process.cwd())
|
|
191
|
+
await run({ testDir: 'src/tests' });
|
|
193
192
|
|
|
194
193
|
// Run only the config and metadata suites
|
|
195
194
|
await run({
|
|
196
|
-
cwd: process.cwd(),
|
|
197
195
|
testDir: 'src/tests',
|
|
198
196
|
testPatterns: ['src/tests/config', 'src/tests/metadata'],
|
|
199
197
|
});
|
|
200
198
|
|
|
201
199
|
// Coverage run (OOM-safe blob + merge mode)
|
|
202
200
|
await run({
|
|
203
|
-
cwd: process.cwd(),
|
|
204
201
|
testDir: 'src/tests',
|
|
205
202
|
vitestArgs: ['--coverage'],
|
|
206
203
|
});
|
|
207
204
|
|
|
208
205
|
// Quiet coverage with live progress bar
|
|
209
206
|
await run({
|
|
210
|
-
cwd: process.cwd(),
|
|
211
207
|
testDir: 'src/tests',
|
|
212
208
|
coverageQuiet: true,
|
|
213
209
|
});
|
|
214
210
|
|
|
215
211
|
// Give heap-heavy files a larger ceiling while keeping the global limit lower
|
|
216
212
|
await run({
|
|
217
|
-
cwd: process.cwd(),
|
|
218
213
|
testDir: 'src/tests',
|
|
219
214
|
maxOldSpaceMb: 2048,
|
|
220
215
|
earlyRunPatterns: ['listener-cleanup/'],
|
package/package.json
CHANGED
package/src/runner.mjs
CHANGED
|
@@ -11,15 +11,14 @@
|
|
|
11
11
|
* are forwarded to child processes unchanged.
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
|
-
* // Run every test file found under src/tests/
|
|
14
|
+
* // Run every test file found under src/tests/ (cwd defaults to process.cwd())
|
|
15
15
|
* import { run } from 'vitest-runner';
|
|
16
|
-
* const code = await run({
|
|
16
|
+
* const code = await run({ testDir: 'src/tests' });
|
|
17
17
|
* process.exit(code);
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* // Run a subset with custom heap limit
|
|
21
21
|
* const code = await run({
|
|
22
|
-
* cwd: process.cwd(),
|
|
23
22
|
* testDir: 'src/tests',
|
|
24
23
|
* testPatterns: ['src/tests/config'],
|
|
25
24
|
* maxOldSpaceMb: 4096,
|
|
@@ -47,7 +46,7 @@ import { colourPct } from "./utils/ansi.mjs";
|
|
|
47
46
|
|
|
48
47
|
/**
|
|
49
48
|
* @typedef {Object} RunOptions
|
|
50
|
-
* @property {string} cwd - Absolute project root directory.
|
|
49
|
+
* @property {string} [cwd=process.cwd()] - Absolute project root directory (defaults to `process.cwd()`).
|
|
51
50
|
* @property {string} [testDir] - Directory to scan for test files (relative or absolute; defaults to `cwd`).
|
|
52
51
|
* @property {string} [vitestConfig] - Explicit vitest config path; auto-detected from `cwd` when omitted.
|
|
53
52
|
* @property {string[]} [testPatterns=[]] - File / folder patterns to filter (empty = all files in `testDir`).
|
|
@@ -101,7 +100,7 @@ function getHeapForFile(filePath, globalMaxMb, overrides) {
|
|
|
101
100
|
*/
|
|
102
101
|
export async function run(opts) {
|
|
103
102
|
const {
|
|
104
|
-
cwd,
|
|
103
|
+
cwd = process.cwd(),
|
|
105
104
|
testDir,
|
|
106
105
|
testPatterns = [],
|
|
107
106
|
testListFile,
|
package/types/src/runner.d.mts
CHANGED
|
@@ -20,9 +20,9 @@ export type PerFileHeapOverride = {
|
|
|
20
20
|
};
|
|
21
21
|
export type RunOptions = {
|
|
22
22
|
/**
|
|
23
|
-
* - Absolute project root directory.
|
|
23
|
+
* - Absolute project root directory (defaults to `process.cwd()`).
|
|
24
24
|
*/
|
|
25
|
-
cwd
|
|
25
|
+
cwd?: string;
|
|
26
26
|
/**
|
|
27
27
|
* - Directory to scan for test files (relative or absolute; defaults to `cwd`).
|
|
28
28
|
*/
|