1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 07:44:48 -05:00

fix(ext/node): use primordials in ext/node/polyfills/testing.ts (#24310)

Towards #24236
This commit is contained in:
Asher Gomez 2024-06-24 15:49:32 +10:00 committed by GitHub
parent 973d186e8f
commit 1c7ae83ca1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 = {