-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supporting vitest
tracking issue
#23882
Comments
With the standard example it appear to still (deno 1.44.4+bc8a0e6) hang at: ➜ deno task test
Task test vitest
DEV v1.6.0 Both w/o DENO_FUTURE=1 |
Fixes #24756. Fixes #24796. This also gets vitest working when using [`--pool=forks`](https://vitest.dev/guide/improving-performance#pool) (which is the default as of vitest 2.0). Ref #23882. --- This PR resolves a handful of issues with child_process IPC. In particular: - We didn't support sending typed array views over IPC - Opening an IPC channel resulted in the event loop never exiting - Sending a `null` over IPC would terminate the channel - There was some UB in the read implementation (transmuting an `&[u8]` to `&mut [u8]`) - The `send` method wasn't returning anything, so there was no way to signal backpressure (this also resulted in the benchmark `child_process_ipc.mjs` being misleading, as it tried to respect backpressure. That gave node much worse results at larger message sizes, and gave us much worse results at smaller message sizes). - We weren't setting up the `channel` property on the `process` global (or on the `ChildProcess` object), and also didn't have a way to ref/unref the channel - Calling `kill` multiple times (or disconnecting the channel, then calling kill) would throw an error - Node couldn't spawn a deno subprocess and communicate with it over IPC
Fixes #24756. Fixes #24796. This also gets vitest working when using [`--pool=forks`](https://vitest.dev/guide/improving-performance#pool) (which is the default as of vitest 2.0). Ref #23882. --- This PR resolves a handful of issues with child_process IPC. In particular: - We didn't support sending typed array views over IPC - Opening an IPC channel resulted in the event loop never exiting - Sending a `null` over IPC would terminate the channel - There was some UB in the read implementation (transmuting an `&[u8]` to `&mut [u8]`) - The `send` method wasn't returning anything, so there was no way to signal backpressure (this also resulted in the benchmark `child_process_ipc.mjs` being misleading, as it tried to respect backpressure. That gave node much worse results at larger message sizes, and gave us much worse results at smaller message sizes). - We weren't setting up the `channel` property on the `process` global (or on the `ChildProcess` object), and also didn't have a way to ref/unref the channel - Calling `kill` multiple times (or disconnecting the channel, then calling kill) would throw an error - Node couldn't spawn a deno subprocess and communicate with it over IPC (cherry picked from commit cd59fc5)
After this PR ( #24763 ) I tried this again with deno 1.45.5, and these scenarios does indeed appear to work now:
Scenarios that doesn't work out-of-the-box, but which will resolve over time / has workarounds:
|
Alright, so I'm on Vitest 2 (it defaults to pool: forks) and Deno 2 (deno 2.0.0-rc.1+7bfcb4d) now. deno.json {
"nodeModulesDir": "auto",
"tasks": {
"test": "vitest"
},
"imports": { "jsdom": "npm:jsdom@^25.0.0", "vitest": "npm:vitest@^2.0.5" }
} sum.test.ts import { expect, test } from "vitest";
export function sum(a, b) {
return a + b
}
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3)
}) vitest.config.ts import {defineConfig} from "vitest/config";
export default defineConfig({
test: {
environment: 'jsdom'
}
}) Run
Error: DEV v2.0.5 /Users/admin/repos/deno-kitchensink/vitest-demo
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: Cannot redefine property: location
❯ populateGlobal node_modules/.deno/vitest@2.0.5/node_modules/vitest/dist/chunks/index.lVXYBqEP.js:374:12
❯ Object.setup node_modules/.deno/vitest@2.0.5/node_modules/vitest/dist/chunks/index.lVXYBqEP.js:526:33
❯ withEnv node_modules/.deno/vitest@2.0.5/node_modules/vitest/dist/chunks/runBaseTests.CyvqmuC9.js:92:15
❯ run node_modules/.deno/vitest@2.0.5/node_modules/vitest/dist/chunks/runBaseTests.CyvqmuC9.js:116:3
❯ runBaseTests node_modules/.deno/vitest@2.0.5/node_modules/vitest/dist/chunks/base.CC5R_kgU.js:31:3
❯ ForksBaseWorker.executeTests node_modules/.deno/vitest@2.0.5/node_modules/vitest/dist/workers/forks.js:25:7
❯ execute node_modules/.deno/vitest@2.0.5/node_modules/vitest/dist/worker.js:115:5
❯ onMessage node_modules/.deno/tinypool@1.0.1/node_modules/tinypool/dist/entry/process.js:55:20
⎯⎯⎯⎯⎯⎯⎯⎯ If I remove DEV v2.0.5 /Users/admin/repos/deno-kitchensink/vitest-demo
✓ sum.test.ts (1)
✓ adds 1 + 2 to equal 3
Test Files 1 passed (1)
Tests 1 passed (1)
Start at 23:47:08
Duration 170ms (transform 15ms, setup 0ms, collect 15ms, tests 1ms, environment 0ms, prepare 46ms) |
This is an issue to track the progress on getting the
vitest
test runner to work. I'm currently using the test suite from urql to check our progress.WebMessagePort
not converted to worker_threadMessagePort
Bug:port.addListener
is not a function #23828vm.runInThisConext
Bug: Nodevm
doesn't have Node'sglobal
global #23852signal-exit
is used under the hood. It's likely that this issue causes CTRL+C to not work: Listeners for SIGINT (and other) signals are not registered in EventEmitter #22892The text was updated successfully, but these errors were encountered: