diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-04-02 16:20:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 16:20:48 -0700 |
commit | 219a27dde51bf4c04af2d905f71d1cec021ee98e (patch) | |
tree | 80a889c2f97dc7f5aa991a169310bfa5ff0f5d22 /tests/node_compat/test.ts | |
parent | 8eb2b6c61f9fdac12f8bab23ad3e9ef71c7c59b1 (diff) |
fix(ext/node): Support returning tokens and option defaults in `node:util.parseArgs` (#23192)
Fixes #23179.
Fixes #22454.
Enables passing `{tokens: true}` to `parseArgs` and setting default
values for options.
With this PR, the observable framework works with deno out of the box
(no unstable flags needed).
The existing code was basically copied straight from node, so this PR
mostly just updates that (out of date) vendored code. Also fixes some
issues with error exports (before this PR, in certain error cases we
were attempting to construct error classes that weren't actually in
scope).
The last change (in the second commit) adds a small hack so that we
actually exercise the `test-parse-args.js` node_compat test, previously
it was reported as passing though it should have failed. That test now
passes.
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'tests/node_compat/test.ts')
-rw-r--r-- | tests/node_compat/test.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/node_compat/test.ts b/tests/node_compat/test.ts index 04a85f113..2f690e943 100644 --- a/tests/node_compat/test.ts +++ b/tests/node_compat/test.ts @@ -76,18 +76,24 @@ async function runTest(t: Deno.TestContext, path: string): Promise<void> { // contain actual JS objects, not strings :)). envVars["NODE_TEST_KNOWN_GLOBALS"] = "0"; } - + // TODO(nathanwhit): once we match node's behavior on executing + // `node:test` tests when we run a file, we can remove this + const usesNodeTest = testSource.includes("node:test"); const args = [ - "run", + usesNodeTest ? "test" : "run", "-A", "--quiet", //"--unsafely-ignore-certificate-errors", "--unstable-unsafe-proto", "--unstable-bare-node-builtins", "--v8-flags=" + v8Flags.join(), - "runner.ts", - testCase, ]; + if (usesNodeTest) { + // deno test typechecks by default + we want to pass script args + args.push("--no-check", "runner.ts", "--", testCase); + } else { + args.push("runner.ts", testCase); + } // Pipe stdout in order to output each test result as Deno.test output // That way the tests will respect the `--quiet` option when provided |