Open birkskyum opened 1 year ago
It seems like the console.ts
/ console.js
that contains:
export default console
Might also have to export the named Console in order to be node compatible.
Console issue you are seeing is https://github.com/oven-sh/bun/issues/3625. It's a constructor that returns a console object that has stdout/stderr redirected
Any workarounds?
might also be worth to know that Vitest itself also have a PR, in draft, to support Bun by using ShadowRealm with this description
Currently, all jsdom tests are failing because bun doesn't seem to correctly support VM module.
console.console is implemented in the next release that might fix vitest
It's progress, but I get this:
vitest on main [!?]
➜ bun --bun x vitest
DEV v0.34.4 /Users/admin/repos/vitest
[bun] Warning: worker_threads.Worker option "argv" is not implemented.
[bun] Warning: worker_threads.Worker option "execArgv" is not implemented.
[bun] Warning: worker_threads.Worker option "resourceLimits" is not implemented.
Those warning can be ignored, see https://github.com/tinylibs/tinypool/pull/70/files#diff-478191b8d0c43c3d24bfda206ff15909923b8b5a89eec9c967376feded4edfa7R9
have the same:
[bun] Warning: worker_threads.Worker option "argv" is not implemented.
[bun] Warning: worker_threads.Worker option "execArgv" is not implemented.
[bun] Warning: worker_threads.Worker option "resourceLimits" is not implemented.
and cant ignore tests doesnt finish
and get this if i want cancel need to do it 1000 times before exit:
RangeError: exitCode must be between 0 and 127
at /Users/nyxb/projects/github_packages/eslint-config/node_modules/vitest/dist/vendor-node.81dd929c.js:17951:8
at _keypressHandler (/Users/nyxb/projects/github_packages/eslint-config/node_modules/vitest/dist/vendor-node.81dd929c.js:17946:34)
at /Users/nyxb/projects/github_packages/eslint-config/node_modules/vitest/dist/vendor-node.81dd929c.js:17990:10
at keypressHandler (/Users/nyxb/projects/github_packages/eslint-config/node_modules/vitest/dist/vendor-node.81dd929c.js:17989:33)
at node:readline:114:54
at onData (node:readline:476:34)
at addChunk (node:stream:1940:42)
at readableAddChunk (node:stream:1894:58)
Cancelling test run. Press CTRL+c again to exit forcefully.
17946 | async function _keypressHandler(str, key) {
17947 | if (str === "" || str === "\x1B" || key && key.ctrl && key.name === "c") {
17948 | if (!ctx.isCancelling) {
17949 | ctx.logger.logUpdate.clear();
17950 | ctx.logger.log(c.red("Cancelling test run. Press CTRL+c again to exit forcefully.\n"));
17951 | process.exitCode = 130;
^
RangeError: exitCode must be between 0 and 127
at /Users/nyxb/projects/github_packages/eslint-config/node_modules/vitest/dist/vendor-node.81dd929c.js:17951:8
at _keypressHandler (/Users/nyxb/projects/github_packages/eslint-config/node_modules/vitest/dist/vendor-node.81dd929c.js:17946:34)
at /Users/nyxb/projects/github_packages/eslint-config/node_modules/vitest/dist/vendor-node.81dd929c.js:17990:10
at keypressHandler (/Users/nyxb/projects/github_packages/eslint-config/node_modules/vitest/dist/vendor-node.81dd929c.js:17989:33)
at node:readline:114:54
at onData (node:readline:476:34)
at addChunk (node:stream:1940:42)
at readableAddChunk (node:stream:1894:58)
Same here - error: "vitest" exited with code 9 (SIGKILL)
I have same problem
Hmm... if I now make a small test file like this , and run, it seems to just freeze:
➜ bun --bun x vitest
DEV v1.1.1 /Users/admin/repos/histoire-vue3-starter
The argument implementation warning was removed in version 1.0.22, but vitest still doesn't work. It turns out that we need to wait for the implementation of bun's virtualization or the integration of shadowrealm api in vitest
Getting this error while running bun x -b vitest run
.
OS: Darwin 23.1.0 arm64 arm
Bun v1.0.35, Vitest v1.4.0
> bun x -b vitest run
82 | `You can download it from ${msvcDownloadLink}`,
83 | { cause: error }
84 | );
85 | }
86 |
87 | throw new Error(
^
error: Cannot find module @rollup/rollup-darwin-arm64. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.
cause: {
"name": "ResolveMessage",
"position": null,
"message": "Cannot find module \"@rollup/rollup-darwin-arm64\" from \"***/rollup/dist/native.js\"",
"level": "error",
"specifier": "@rollup/rollup-darwin-arm64",
"importKind": "require-call",
"referrer": "***/rollup/dist/native.js"
}
at requireWithFriendlyError (***/node_modules/rollup/dist/native.js:87:9)
at ***/node_modules/rollup/dist/native.js:96:48
Maybe interesting fact:
if you take the node:20 docker image and install bun there, then our
bun run vitest --coverage --run --watch false
completes without problems.
if we use the oven:bun image it just hangs. Hope this fact maybe helps someone as a workaround if possible...
With the node one, does it pass with the '--bun' flag?
Sadly
bun run --bun vitest --coverage --run
does not finish.
Also does not work on my local dev machine (ubuntu24lts), just hangs
I know bun has a competing bun test
, but as of writing vitest is quickly becoming a staple, so it would be great if bun could support it as well. If people can adopt bun in their projects, and then consider swapping the test runner, that would give a much nicer migration story towards bun.
Still issue with vitest 2.x / bun 1.1.22-canary.85+cacbaba52
➜ bun --bun x vitest
DEV v2.0.5
+1
+1
Tried with latest stabe bun 1.1.27 - it hangs, and also makes these weird symbols instead of interrupting why I try to escape it
Vitest - website - github
What version of Bun is running?
0.8.1
What platform is your computer?
Darwin 22.5.0 arm64 arm
What steps can reproduce the bug?
bun --bun x vitest
What is the expected behavior?
No error
What do you see instead?
SyntaxError: Import named 'Console' not found in module 'node:console'.
Additional information
Related to:
3746
11268