Skip to content

Commit

Permalink
fix(test): make test runner work when global setTimeout is replaced (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed Aug 4, 2023
1 parent 6405b5f commit 8a175a7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/js/40_testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions cli/tests/integration/test_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions cli/tests/testdata/test/replace_timers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Deno.test("foo", async (t) => {
globalThis.setTimeout = () => {};
globalThis.clearTimeout = () => {};
globalThis.setInterval = () => {};
globalThis.clearInterval = () => {};
await t.step("bar", () => {});
});
7 changes: 7 additions & 0 deletions cli/tests/testdata/test/replace_timers.js.out
Original file line number Diff line number Diff line change
@@ -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])

0 comments on commit 8a175a7

Please sign in to comment.