mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(test): make test runner work when global setTimeout is replaced (#20052)
This commit is contained in:
parent
6405b5f454
commit
8a175a780a
4 changed files with 20 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
7
cli/tests/testdata/test/replace_timers.js
vendored
Normal file
7
cli/tests/testdata/test/replace_timers.js
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
Deno.test("foo", async (t) => {
|
||||
globalThis.setTimeout = () => {};
|
||||
globalThis.clearTimeout = () => {};
|
||||
globalThis.setInterval = () => {};
|
||||
globalThis.clearInterval = () => {};
|
||||
await t.step("bar", () => {});
|
||||
});
|
7
cli/tests/testdata/test/replace_timers.js.out
vendored
Normal file
7
cli/tests/testdata/test/replace_timers.js.out
vendored
Normal 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])
|
||||
|
Loading…
Reference in a new issue