summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/testing.ts
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-06-24 15:49:32 +1000
committerGitHub <noreply@github.com>2024-06-24 15:49:32 +1000
commit1c7ae83ca1e73da36cda92416cb730531b7a454b (patch)
treec47fddf9022a4d5ceba6256f8072cc1988cc5c80 /ext/node/polyfills/testing.ts
parent973d186e8f655e96dc7fb214e130fec81a78f550 (diff)
fix(ext/node): use primordials in `ext/node/polyfills/testing.ts` (#24310)
Towards #24236
Diffstat (limited to 'ext/node/polyfills/testing.ts')
-rw-r--r--ext/node/polyfills/testing.ts32
1 files changed, 18 insertions, 14 deletions
diff --git a/ext/node/polyfills/testing.ts b/ext/node/polyfills/testing.ts
index b6733f118..92900e632 100644
--- a/ext/node/polyfills/testing.ts
+++ b/ext/node/polyfills/testing.ts
@@ -1,8 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-// TODO(petamoriken): enable prefer-primordials for node polyfills
-// deno-lint-ignore-file prefer-primordials
-
+import { primordials } from "ext:core/mod.js";
+const { PromisePrototypeThen } = primordials;
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
export function run() {
@@ -54,17 +53,20 @@ class NodeTestContext {
test(name, options, fn) {
const prepared = prepareOptions(name, options, fn, {});
- return this.#denoContext.step({
- name: prepared.name,
- fn: async (denoTestContext) => {
- const newNodeTextContext = new NodeTestContext(denoTestContext);
- await prepared.fn(newNodeTextContext);
- },
- ignore: prepared.options.todo || prepared.options.skip,
- sanitizeExit: false,
- sanitizeOps: false,
- sanitizeResources: false,
- }).then(() => undefined);
+ return PromisePrototypeThen(
+ this.#denoContext.step({
+ name: prepared.name,
+ fn: async (denoTestContext) => {
+ const newNodeTextContext = new NodeTestContext(denoTestContext);
+ await prepared.fn(newNodeTextContext);
+ },
+ ignore: prepared.options.todo || prepared.options.skip,
+ sanitizeExit: false,
+ sanitizeOps: false,
+ sanitizeResources: false,
+ }),
+ () => undefined,
+ );
}
before(_fn, _options) {
@@ -127,6 +129,8 @@ function wrapTestFn(fn, resolve) {
function prepareDenoTest(name, options, fn, overrides) {
const prepared = prepareOptions(name, options, fn, overrides);
+ // TODO(iuioiua): Update once there's a primordial for `Promise.withResolvers()`.
+ // deno-lint-ignore prefer-primordials
const { promise, resolve } = Promise.withResolvers();
const denoTestOptions = {