Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2943ccf
feat(experimental): allow disabling the module runner
sheremet-va Dec 8, 2025
085be59
fix: throw an error in vmForks/vmThreads
sheremet-va Dec 8, 2025
c25402a
feat: implement nativeModuleRunner
sheremet-va Dec 8, 2025
318eb6b
chore: cleanup types
sheremet-va Dec 8, 2025
0611b57
fix: watcher respects non-client/ssr environments
sheremet-va Dec 8, 2025
3e4caa2
feat: support watch mode
sheremet-va Dec 8, 2025
4e5464b
fix: support module.register
sheremet-va Dec 8, 2025
3c40971
feat: support import.meta.vitest
sheremet-va Dec 8, 2025
c047490
chore: cli-config
sheremet-va Dec 8, 2025
b83f29c
chore: add sample project
sheremet-va Dec 9, 2025
3fd5618
chore: cleanup
sheremet-va Dec 9, 2025
e4b0d2e
chore: cleanup
sheremet-va Dec 9, 2025
fe86182
feat: support automock, autospy and redirect mock types
sheremet-va Dec 9, 2025
3f7e2b3
fix: show module as external in UI
sheremet-va Dec 9, 2025
2273518
fix: run setup file for every test, execute in-source tests as separa…
sheremet-va Dec 9, 2025
6c44609
feat: first implementation of factory mocking
sheremet-va Dec 10, 2025
4091d0d
chore: collect
sheremet-va Dec 12, 2025
0926f28
chore: refactor native module mocker
sheremet-va Dec 12, 2025
f76caa0
refactor: cleanup exports collection
sheremet-va Dec 12, 2025
d6f72bd
fix: support importActual and recursive factory
sheremet-va Dec 12, 2025
086c47c
fix: support vi.importMock
sheremet-va Dec 12, 2025
06a351e
fix: support mocking deps
sheremet-va Dec 12, 2025
8b4f29b
fix(mocker): support top level import if dependency is not circular
sheremet-va Dec 15, 2025
f50aa81
fix: allow `export *` when automocking
sheremet-va Dec 15, 2025
a4e603e
test: add more tests
sheremet-va Dec 15, 2025
d458c67
fix: update loading errors
sheremet-va Dec 15, 2025
34f1bb3
Merge branch 'main' of github.com:vitest-dev/vitest into 12-08-feat_e…
sheremet-va Dec 15, 2025
d3db1bf
chore: cleanup
sheremet-va Dec 15, 2025
b653ee3
chore: cleanup
sheremet-va Dec 15, 2025
0ab2dab
fix: override is false by default
sheremet-va Dec 16, 2025
69ca0d8
chore: cleanup
sheremet-va Dec 16, 2025
4786dd1
refactor: move the example to test/
sheremet-va Dec 16, 2025
5bb68aa
docs: cleanup
sheremet-va Dec 16, 2025
74a84c4
chore: add try/catch
sheremet-va Dec 17, 2025
c81d363
Merge branch 'main' of github.com:vitest-dev/vitest into 12-08-feat_e…
sheremet-va Dec 17, 2025
f7def15
fix: listen for unhandled errors in vm pool
sheremet-va Dec 17, 2025
3f96c63
fix(windows): support circular manual mock
sheremet-va Dec 17, 2025
f8ab6a5
chore: replace #test-loader with #nodejs-worker-loader
sheremet-va Dec 18, 2025
34350d6
chore: remove a warning hint
sheremet-va Dec 18, 2025
fda5d88
docs: mention it works only in forks/threads
sheremet-va Dec 18, 2025
fa80150
chore: nitpicks
sheremet-va Dec 18, 2025
f8c558d
test: add imports from basic.ts
sheremet-va Dec 18, 2025
3ded894
fix: move mock=actual resolution to worker loader
sheremet-va Dec 18, 2025
d99af1d
fix: load custom env with a regular import
sheremet-va Dec 18, 2025
f0c1ae2
chore: lint
sheremet-va Dec 18, 2025
861e0d1
fix: wrong default
sheremet-va Dec 18, 2025
a5dc591
fix: load automocked builtins properly
sheremet-va Dec 18, 2025
c48303e
chore: support import on windows
sheremet-va Dec 18, 2025
a097b32
Merge branch 'main' of github.com:vitest-dev/vitest into 12-08-feat_e…
sheremet-va Dec 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: move the example to test/
  • Loading branch information
sheremet-va committed Dec 16, 2025
commit 4786dd1c7ab91278cb49f08ff8669fd5e8445f5c
11 changes: 10 additions & 1 deletion packages/mocker/src/node/automock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ export function automockModule(
options: AutomockOptions = {},
): MagicString {
const globalThisAccessor = options.globalThisAccessor || '"__vitest_mocker__"'
const ast = parse(code) as Program
let ast: Program
try {
ast = parse(code) as Program
}
catch (cause) {
if (options.id) {
throw new Error(`failed to parse ${options.id}`, { cause })
}
throw cause
}

const m = new MagicString(code)

Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const external = [
'vitest/browser',
'vite/module-runner',
'@vitest/mocker',
'@vitest/mocker/node',
/@vitest\/mocker\/\w+/,
'@vitest/utils/diff',
'@vitest/utils/error',
'@vitest/utils/source-map',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ export class NativeModuleMocker extends BareModuleMocker {
if (mockedModule.type === 'automock' || mockedModule.type === 'autospy') {
return {
url: injectQuery(url, parentURL, `mock=${mockedModule.type}`),
format: 'module',
shortCircuit: true,
}
}
if (mockedModule.type === 'manual') {
return {
url: injectQuery(url, parentURL, 'mock=manual'),
format: 'module',
shortCircuit: true,
}
}
Expand Down
36 changes: 18 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
2 changes: 1 addition & 1 deletion examples/native/package.json → test/native/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@vitest/example-native",
"name": "@vitest/test-native",
"type": "module",
"private": true,
"license": "MIT",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/native/vite.config.ts → test/native/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
// the hardest to support
// TODO: ideally, this should run in a matrix
Comment on lines +5 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about running this test/native as fixture elsewhere with different options?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I am thinking too

isolate: false,
maxWorkers: 1,
setupFiles: [
Expand Down