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

Report bad test() usage as a test failure, rather than a runtime error #698

Open
jamestalmage opened this issue Apr 1, 2016 · 8 comments
Labels

Comments

@jamestalmage
Copy link
Contributor

jamestalmage commented Apr 1, 2016

Issuehunt badges

Sometimes you get sloppy / distracted and end up with a half completed test:

// you have some good tests:

test('foo', t => {
  // this will never be executed because of the mistakes below
});

// This throws - saying it should be a todo test:
test('fooo');

// Ooops - did you get distracted?:
test();

// Todo should not have an implementation, it is intended to document future tests/features.
test.todo('foo', t => {});

Instead of throwing when someone misuses the API, I think the misuse should just be reported as a failure. It should still execute the correctly written tests.

There is a $40.00 open bounty on this issue. Add more on Issuehunt.

@sindresorhus
Copy link
Member

I like the idea of being as graceful a possible. One concern though. Look at it the other way around. What if you have a lot of tests and you use one of them incorrectly. Now it will run all the tests before letting you know you have an issue and then you'll have to rerun the whole test file again. Just a thought.

@novemberborn
Copy link
Member

#78 will likely force our hand here. We're doing #696 so we can correctly run exclusive test but I doubt we'll try and suss out these issues statically. If we don't then we'll end up in situations where we're already running a whole bunch of tests before the fault is encountered. Then why not run to completion?

@jamestalmage
Copy link
Contributor Author

Now it will run all the tests before letting you know you have an issue and then you'll have to rerun the whole test file again. Just a thought.

No reason we can't report it as an error as soon as it's encountered.

@novemberborn
Copy link
Member

No reason we can't report it as an error as soon as it's encountered.

You probably won't notice it though.

@jamestalmage
Copy link
Contributor Author

Why not? If it increases the error count, that's noticeable immediately.

@novemberborn
Copy link
Member

Why not? If it increases the error count, that's noticeable immediately.

Fair enough.

@novemberborn novemberborn changed the title gracefully handle bad usages of test method Report bad test() usage as a test failure, rather than a runtime error Aug 20, 2017
@novemberborn
Copy link
Member

novemberborn commented Apr 22, 2018

This will be easiest to implement once #2217 lands.

@novemberborn novemberborn added the blocked waiting on something else to be resolved first label Apr 22, 2018
@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 15, 2019
@IssueHuntBot
Copy link

@IssueHunt has funded $40.00 to this issue.


@novemberborn novemberborn removed the blocked waiting on something else to be resolved first label May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants