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

Fix AVA hanging when test is used incorrectly #600

Closed
wants to merge 6 commits into from
Closed

Fix AVA hanging when test is used incorrectly #600

wants to merge 6 commits into from

Conversation

sotojuan
Copy link
Contributor

@sotojuan sotojuan commented Mar 4, 2016

Fixes #574.

This is just what works now, I am sure there's a better way. Stack trace is ugly but it's better than hanging. I also had to update some TestCollection test stuff so those could still pass.

Just wanted to share my approach!

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @Carnubak and @BarryThePenguin to be potential reviewers

if (typeof test.fn === 'undefined') {
throw new Error('Test must be specified');
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this check would be better suited in lib/runner.js#L52-L77

@sotojuan
Copy link
Contributor Author

sotojuan commented Mar 4, 2016

Just tried it, also works, and I wouldn't have to mess with TestCollection tests. I'll wait for someone from the core team to confirm though.

@novemberborn
Copy link
Member

@sotojuan yes, please add the guards in the runner.

@novemberborn
Copy link
Member

Please make sure to rebase on master to fix a linting issue and run the latest XO configuration against your PR. Thanks!

@sotojuan
Copy link
Contributor Author

sotojuan commented Mar 5, 2016

Um, don't think I did anything to cause the failing in 0.12. When I test with 0.12 in my computer, everything passes.

@sindresorhus
Copy link
Member

LGTM

@@ -65,6 +65,10 @@ optionChain(chainableMethods, function (opts, title, fn) {
throw new TypeError('Expected a function. Use `test.todo()` for tests without a function.');
}

if (typeof fn === 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe typeof fn !== 'function'?

@@ -65,6 +65,10 @@ optionChain(chainableMethods, function (opts, title, fn) {
throw new TypeError('Expected a function. Use `test.todo()` for tests without a function.');
}

if (typeof fn !== 'function') {
throw new TypeError('Expected a function. Use `test.todo()` for tests without a function.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You now have the exact same error defined twice. Put it in a variable and reuse it.

@novemberborn
Copy link
Member

@sotojuan could you please add a comment when you push changes? There are no notifications for pushes.

@@ -65,6 +65,10 @@ optionChain(chainableMethods, function (opts, title, fn) {
throw new TypeError('Expected a function. Use `test.todo()` for tests without a function.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a new error message, why don't we just remove opts.skipped && from here? Unless I'm missing something? // @novemberborn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea that should be fine.

Would be good to have a test for this new behavior as well.

@sotojuan
Copy link
Contributor Author

sotojuan commented Mar 6, 2016

@novemberborn Sorry about that, I always forget! I'll make the changes and add the tests later today :-)

@sotojuan
Copy link
Contributor Author

sotojuan commented Mar 6, 2016

@novemberborn ping 🐤

@sindresorhus
Copy link
Member

Thanks @sotojuan :)

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

Successfully merging this pull request may close these issues.

5 participants