-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve metadata checks #980
Improve metadata checks #980
Conversation
Good work, @asafigan! Sorry for not taking a look sooner. Let's hear one more LGTM and merge it in. @sindresorhus @jamestalmage @novemberborn @sotojuan @jfmengels looks good to you? |
} | ||
|
||
if (metadata.failing) { | ||
return '`only` tests cannot be failing'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not well aware of how this works, but the message talks about only
tests, not skipped
tests. Are tests skipped due to the presence of an only marked as skipped, or is the message inconsistent with what is checked?
Not sure why failing tests should not be skipped/only-ed by the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just the message is wrong and should be fixed.
Not sure why failing tests should not be skipped/only-ed by the way.
I agree, failing
tests should be allowed to skip
and only
.
Thanks for the feed back guys. I'm going to be busy for awhile, but I will try to look into everything. |
Few nitpicks but overall LGTM. Should be merged by the next push! |
Hey @asafigan, any chance you have some free time to complete this? :) |
Sorry I have been so slow on this. I will do it this weekend. |
@asafigan No worries, thanks! |
…tadata-checks-issue-847 updating from upstream
@vdemedes unless there is any other feedback, I believe it ready to merge |
4bc021e
to
476c653
Compare
@asafigan Thanks for finishing this up! I'm a little busy now, I'll try to review ASAP, unless someone from the team beats me to it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for coming back to this @asafigan!
I wonder if the tests should be added to test/runner.js
instead. The examples are clearer that way and less coupled to how tests definitions are represented internally.
Also, @sindresorhus, do we have rules around when error messages end in a period? Looking at the deletions we haven't been consistent about this before, and perhaps we don't care, but wanted to raise it regardless.
|
@asafigan Any chance you would be able to address @novemberborn's feedback so this can be merged? |
ping @asafigan |
So, I need to rewrite the tests in |
Yes, so they're not tied to the internal implementation. Just make them like the existing ones you already have there: https://github.com/avajs/ava/pull/980/files#diff-a0b87ab613d07bba77930609ec360b3dR323
What you have now is fine. |
8610723
to
4acb78f
Compare
@asafigan how's it going? Wondering if you're still interested in completing this? Thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just updating PR status.)
I'm getting major issues when I try to test now. |
I pull from master and solved the merge conflicts but now there are a bunch of errors when I run npm test or npm run test-win |
I went to my master branch and pulled from upstream master and I get the same issues |
@@ -4,6 +4,7 @@ const Promise = require('bluebird'); | |||
const optionChain = require('option-chain'); | |||
const matcher = require('matcher'); | |||
const TestCollection = require('./test-collection'); | |||
const validateTest = require('./test-colection'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a typo. You're also importing the same thing twice.
oh yeah I noticed that |
the real issue was that I forgot to rerun npm install |
I had to fix some other things, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up again @asafigan. Nearly there! 😄
|
||
t.throws(() => { | ||
runner.beforeEach.only('', noop); | ||
}, {message: '`only` is only for tests and cannot be used with hooks'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better as:
t.throws(() => {
runner.beforeEach.only('', noop);
}, TypeError, '`only` is only for tests and cannot be used with hooks');
Same goes for the other tests. See http://www.node-tap.org/asserts/#tthrowsfn-expectederror-message-extrafor specifics.
Will do |
@@ -234,7 +234,7 @@ test('skip test', t => { | |||
|
|||
t.throws(() => { | |||
runner.skip('should be a todo'); | |||
}, {message: 'Expected an implementation. Use `test.todo()` for tests without an implementation.'}); | |||
}, TypeError, 'Expected an implementation. Use `test.todo()` for tests without an implementation.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect. You're no longer testing the error message. The third argument is just an assert failure message.
You could do:
t.throws(() => {
runner.todo('todo', () => {});
}, new TypeError('`todo` tests are not allowed to have an implementation. Use `test.skip()` for tests with an implementation.'));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for catching that
Thank you @asafigan. Excited to finally land this :) |
Fixes #847
validate-test.js checks the following:
always
should only be used withafter
orafterEach
todo
may not have an implementation, but must have a titletodo
should not be combined with any other modifiers. It's simply for documentation. So noskipped
, nofailing
, noafterEach
, etc.skip.only
should be a failurefailing
shouldn't be used with hooksfailing
shouldn't beskipped
only
shouldn't be used with hooksAll unit tests are in test/validate-test.js. Integration tests are in test/runner.js. Moved some tests from test/test-collection.js to test/runner.js.