ava icon indicating copy to clipboard operation
ava copied to clipboard

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

Open jamestalmage opened this issue 9 years ago • 8 comments

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.

jamestalmage avatar Apr 01 '16 21:04 jamestalmage

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.

sindresorhus avatar Apr 02 '16 14:04 sindresorhus

#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?

novemberborn avatar Apr 02 '16 17:04 novemberborn

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.

jamestalmage avatar Apr 02 '16 23:04 jamestalmage

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

You probably won't notice it though.

novemberborn avatar Apr 03 '16 10:04 novemberborn

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

jamestalmage avatar Apr 03 '16 16:04 jamestalmage

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

Fair enough.

novemberborn avatar Apr 04 '16 09:04 novemberborn

This will be easiest to implement once https://github.com/avajs/ava/pull/2217 lands.

novemberborn avatar Apr 22 '18 17:04 novemberborn

@issuehunt has funded $40.00 to this issue.


IssueHuntBot avatar May 15 '19 05:05 IssueHuntBot