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

fix(test): make test runner work when global setTimeout is replaced (#20052)

This commit is contained in:
Yoshiya Hinosawa 2023-08-04 22:29:04 +09:00 committed by GitHub
parent 6405b5f454
commit 8a175a780a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 0 deletions

View file

@ -5,6 +5,7 @@ const ops = core.ops;
import { setExitHandler } from "ext:runtime/30_os.js";
import { Console } from "ext:deno_console/01_console.js";
import { serializePermissions } from "ext:runtime/10_permissions.js";
import { setTimeout } from "ext:deno_web/02_timers.js";
import { assert } from "ext:deno_web/00_infra.js";
const primordials = globalThis.__bootstrap.primordials;
const {

View file

@ -529,6 +529,11 @@ itest!(test_no_lock {
output: "lockfile/basic/test.nolock.out",
});
itest!(test_replace_timers {
args: "test test/replace_timers.js",
output: "test/replace_timers.js.out",
});
#[test]
fn test_with_glob_config() {
let context = TestContextBuilder::new().cwd("test").build();

View file

@ -0,0 +1,7 @@
Deno.test("foo", async (t) => {
globalThis.setTimeout = () => {};
globalThis.clearTimeout = () => {};
globalThis.setInterval = () => {};
globalThis.clearInterval = () => {};
await t.step("bar", () => {});
});

View file

@ -0,0 +1,7 @@
running 1 test from ./test/replace_timers.js
foo ...
bar ... ok ([WILDCARD])
foo ... ok ([WILDCARD])
ok | 1 passed (1 step) | 0 failed ([WILDCARD])