And only in files that end in _test.ts.
Example:
// foo_test.ts
function testBar() {
if (1 != 2) {
throw Error("Test failed.");
}
}
Can't it be up to the community to create something that runs all files ending with _test.js? This seems a bit unnecessary...
I think it鈥檚 better to have these thing prescribed - it鈥檚 very arbitrary and better if everyone just uses the same system
It also wouldn't preclude someone from running some other test harness or some other pattern, they simply wouldn't execute deno test.
I think it's good if everyone uses the same system, but we shouldn't force the use of the test* pattern. Maybe it should be the default, but it will be better allowing custom patterns like deno test tests/*.
Attempting to implement this: https://github.com/robbym/deno/commit/d4b66fb9a8e0ce1ddd8b5c14f60a2b34c9bda1f8
How does one get stuff, like all the function names in a file, from the C API?
Functionality not there yet?
@robbym Yeah functionality is not there yet. Hold off on this for a bit... We've got one more sprint and then we'll be up and running on the prototype's runtime. It'll make more sense to talk about it once we've got that working.
So, you can do this if the function is exported:
// foo_test.ts
export function testFoo() {
console.log("foo");
}
// test.ts
(async () => {
const name = "foo_test.ts";
const t = await import(name);
t.testFoo();
})();
Is there a way to access these if the function is not exported?
Edit: One possible solution is to support users grouping their test function in a class that's Test prefixed e.g. TestFoo. https://stackoverflow.com/a/32071275/1240268 :/
Edit2: I think there's a nice way to do this with the current test(... api actually.
@ry close in favor of testing module in standard library?
Once import() is working I will add this to std testing similar to --fmt.
This is still desired. @hayd looking forward to it.
Resolved in #2783!
CC @ry
Nice work :D
Most helpful comment
I think it鈥檚 better to have these thing prescribed - it鈥檚 very arbitrary and better if everyone just uses the same system