test: setup workerd isolate tests - #311
Merged
Merged
Conversation
pi0
commented
Sep 19, 2024
pi0
commented
Sep 19, 2024
| import assert from "node:assert"; | ||
| import process from "node:process"; | ||
|
|
||
| globalThis.process = process; |
Member
Author
There was a problem hiding this comment.
Without this, workerd fail:
workerd/io/worker.c++:1950: info: uncaught exception; source = Uncaught (in promise); stack = ReferenceError: process is not defined
at unenv/runtime/node/crypto:387:21
workerd/io/io-context.c++:348: info: uncaught exception; exception = workerd/jsg/_virtual_includes/jsg/workerd/jsg/value.h:1367: failed: jsg.ReferenceError: process is not defined
(process is used for process.getBuiltinModule("node:crypto")...)
pi0
marked this pull request as ready for review
September 19, 2024 17:42
pi0
commented
Sep 19, 2024
pi0
commented
Sep 19, 2024
| }, | ||
| }; | ||
|
|
||
| // ---- node:url ---- |
Member
Author
There was a problem hiding this comment.
We have all Node.js upstream tests for url, in test/node/* now. But since this entry is inlined in capnp config, I'm not sure how to dynamically bring them. If we can, we can reuse same impl.
Member
Author
|
merging to iterate.. |
This was referenced Oct 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds isolated tests via workerd.
This setup uses a small Node.js wrapper that starts a module fallback server (based on cloudflare/workerd#1423) and then spawns
workerd testto run tests.The fallback server, maps
unenv/runtime/*requests to source code (transpiled with esbuild to allow HMR). esbuild config usesenv(nodeless, cloudflare)aliases to match the expected bundler behavior when resolving internalnode:aliases.As sample, two tests for
crypto.getRandomValuesandurl.parse(fail behavior) are added. We shall iterate and add more coverage for runtime safety as we introduce new features.Usage:
pnpm test:workerdpnpm test:workerd --watch(watch mode)DUMP_MODULES=1 pnpm test:workerd(dump server modules totest/workerd/.tmpfor inspection)