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

"deno test" should run all the functions named test* in current directory #20

Closed
ry opened this issue May 30, 2018 · 12 comments
Closed

Comments

@ry
Copy link
Member

ry commented May 30, 2018

And only in files that end in _test.ts.

Example:

// foo_test.ts
function testBar() {
  if (1 != 2) {
    throw Error("Test failed.");
  }
}
@ry ry changed the title "deno test" should run all the functions named Test* in current directory "deno test" should run all the functions named test* in current directory May 30, 2018
@jsommr
Copy link

jsommr commented Jun 8, 2018

Can't it be up to the community to create something that runs all files ending with _test.js? This seems a bit unnecessary...

@ry
Copy link
Member Author

ry commented Jun 8, 2018

I think it’s better to have these thing prescribed - it’s very arbitrary and better if everyone just uses the same system

@kitsonk
Copy link
Contributor

kitsonk commented Jun 8, 2018

It also wouldn't preclude someone from running some other test harness or some other pattern, they simply wouldn't execute deno test.

@yoavmmn
Copy link

yoavmmn commented Jun 18, 2018

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/*.

@robbym
Copy link
Contributor

robbym commented Jul 10, 2018

Attempting to implement this: robbym@d4b66fb

How does one get stuff, like all the function names in a file, from the C API?
Functionality not there yet?

@ry
Copy link
Member Author

ry commented Jul 10, 2018

@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.

@ry ry added this to the future milestone Aug 7, 2018
@hayd
Copy link
Contributor

hayd commented Jan 5, 2019

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.

@bartlomieju
Copy link
Member

@ry close in favor of testing module in standard library?

@hayd
Copy link
Contributor

hayd commented Feb 12, 2019

Once import() is working I will add this to std testing similar to --fmt.

@ry
Copy link
Member Author

ry commented Feb 12, 2019

This is still desired. @hayd looking forward to it.

@bartlomieju
Copy link
Member

Resolved in #2783!

CC @ry

@ry
Copy link
Member Author

ry commented Aug 21, 2019

Nice work :D

@ry ry closed this as completed Aug 21, 2019
piscisaureus pushed a commit to piscisaureus/deno that referenced this issue Oct 7, 2019
hardfist pushed a commit to hardfist/deno that referenced this issue Aug 7, 2024
Supports #[serde] parameters in argument and return position.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants