-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
bugSomething isn't working correctlySomething isn't working correctlytestingrelated to deno test and coveragerelated to deno test and coverage
Description
With this test.mjs module:
import puppeteer from "https://deno.land/x/puppeteer@14.1.1/mod.ts";
Deno.test("A", async (t) => {
const browser = await puppeteer.launch();
try {
await t.step("B", async () => {});
} finally {
await browser.close();
}
});With this command:
deno test --allow-all
The tests fail with an error:
running 1 test from ./test.mjs
A ...
B ... FAILED (2ms)
error: AssertionError: Test case is leaking async ops.
- 1 async operation to sleep for a duration was started before this test, but was completed during the test. Async operations should not complete in a test if they were not started in that test.
This is often caused by not cancelling a `setTimeout` or `setInterval` call.
To get more details where ops were leaked, run again with --trace-ops flag.
await t.step("B", async () => {});
^
at assert (deno:ext/web/00_infra.js:294:13)
at asyncOpSanitizer (deno:runtime/js/40_testing.js:223:13)
at async resourceSanitizer (deno:runtime/js/40_testing.js:368:7)
at async exitSanitizer (deno:runtime/js/40_testing.js:425:9)
at async TestContext.step (deno:runtime/js/40_testing.js:1328:13)
at async file://[redacted]/test.mjs:7:5
A ... FAILED (341ms)
ERRORS
A => ./test.mjs:3:6
error: Error: 1 test step failed.
at runTest (deno:runtime/js/40_testing.js:835:11)
at async Object.runTests (deno:runtime/js/40_testing.js:1084:22)
FAILURES
A => ./test.mjs:3:6
FAILED | 0 passed | 1 failed (1 step) (397ms)
error: Test failed
With the test step commented out:
import puppeteer from "https://deno.land/x/puppeteer@14.1.1/mod.ts";
Deno.test("A", async (t) => {
const browser = await puppeteer.launch();
try {
// await t.step("B", async () => {});
} finally {
await browser.close();
}
});The tests pass without error:
running 1 test from ./test.mjs
A ... ok (307ms)
ok | 1 passed | 0 failed (366ms)
lambdalisue, HenryNguyen5 and oles
Metadata
Metadata
Assignees
Labels
bugSomething isn't working correctlySomething isn't working correctlytestingrelated to deno test and coveragerelated to deno test and coverage