-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Suggested improvements to Deno.test APIs #4166
Comments
I've been working with
👍 no comment, I agree on both points
Implementing that means changing signature of // exists
export interface RunTestsOptions {
exitOnFail?: boolean;
only?: string | RegExp;
skip?: string | RegExp;
silent?: boolean;
}
// exists, not exported
interface TestStats {
filtered: number;
ignored: number;
measured: number;
passed: number;
failed: number;
}
// exists in similar form, not exported
interface TestResult {
name: string;
fn: TestFunction;
success: boolean;
timeElapsed: number;
error?: Error;
}
// doesn't exist
interface RunTestsResult {
success: boolean;
tests: TestResult[];
stats: TestStats;
}
export function runTests(opts?: RunTestsOptions): Promise<RunTestsResult>; There is one problem with that approach; calling Then there's One more thing that was a PITA was that there's no way to get access to registered tests - there is In light of recent discussion in #4092 we should set some clear boundaries what do we want to get into Deno testing and what should be done by third-parties. Edit: Ref #4098 BTW, I got most of changes proposed in this issue working on a branch |
Where do you return the test results?
The display logic of tests should be seperate from the acquisition. In my opinion it should be refactored so that the results displayed by
By |
Ref #3865 (comment). I suggested that const results = Deno.runTests();
Deno.reportTestResults(results); Nice and modular. For the example use case of replacing -- On the other hand, my first suggestion was to make |
My bad, forgot to change return type; that should obviously be: export function runTests(opts?: RunTestsOptions): Promise<RunTestsResult>; Fixed in original comment.
I agree with that. I see another problem though: when you call
Yeah, I'm trying to refactor unit tests of
I think we're going into right direction - there's an issue for coverage reporting (#106). It's worth considering at this point . |
Sounds like something that should be added into rusty_v8... that one has been in the back of my mind for a long time (that and caching bytecode). |
was wondering what u think about having sth like RunTestsOptions {
...
timeFormat: "milli" | "micro" | "nano";
} exposed to the cli for indicating the desired timing output |
@chiefbiiko there's no way to guarantee better resolution. You'd have to run with Current test runner follows closely Rust test runner, which doesn't print duration at all... |
Update: after all of the PRs to update testing framework there's single item left to do from @kitsonk's original list:
Right now |
Last point addressed in #4451 |
I was just looking at all the APIs in
Deno
and noticed theDeno.test
andDeno.runTests
. I think there are a couple improvements we could make:RunTestOptions.disableLog
could be renamedRunTestOptions.silent
, it would be more consistent with other parts of Deno.runTests()
could return some sort of test results, where each test name and afail
flag could be provided, as well as anerror
field which would be a reference to whatever was thrown iffail
is true. This would allow people to implementsilent
plus do post processing on a test run.RunTestOptions.only
andRunTestOptions.skip
could take astring | RegExp
and if astring
we would dotestName.includes()
check. This makes it a bit more approachable filtering for simply containing checks, versus having to do a RegExp all the time.The text was updated successfully, but these errors were encountered: