Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Print file path of a test file that fails outside any running tests. #14312

Closed
jespertheend opened this issue Apr 18, 2022 · 2 comments
Closed
Labels
bug Something isn't working correctly testing related to deno test and coverage

Comments

@jespertheend
Copy link
Contributor

For example:

const e = new Error("oh no!");
e.stack = "stack is gone";
throw e;

Deno.test({
    name: "fails outside the test",
    fn() {},
});

prints the following:

image

Which makes it hard to figure out the error originated from c.test.js.

Admittedly I cheated a little here by removing the stack trace of the error, which would have shown c.test.js in the stack trace, so a more real world use case would be:

import {Importer} from "https://deno.land/x/[email protected]/mod.js";

const importer = new Importer(import.meta.url);
await importer.import("does/not/exist.js");

Deno.test({
    name: "fails outside the test",
    fn() {},
});

image

The rejected promise is created in a file other than the running test, causing the stack trace to never mention c.test.js.

At the moment the only way to figure out where the error originated is to gradually reduce the scope of the tests you're running, which could take pretty long depending on how many tests you have.

@bartlomieju bartlomieju added bug Something isn't working correctly testing related to deno test and coverage labels Apr 18, 2022
@bartlomieju
Copy link
Member

Thanks for opening this issue. I discussed it last week with @dsherret that it's very unhelpful. I have an idea how to fix this, but that requires making test runner "more rusty", by moving some of the logic from JavaScript to Rust. It will be a bigger refactor, but we should tackle it.

@nayeemrmn
Copy link
Collaborator

Fixed in #14513.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly testing related to deno test and coverage
Projects
None yet
Development

No branches or pull requests

3 participants