-
Notifications
You must be signed in to change notification settings - Fork 184
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
JS-312 Create rule S1607 (no-skipped-tests
): Tests should not be skipped without providing a reason
#4797
Conversation
6290a29
to
e45eece
Compare
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.
*/ | ||
function hasExplanationComment(node: estree.Node): boolean { | ||
const comments = context.sourceCode.getCommentsBefore(node); | ||
return comments.some(comment => comment.loc!.end.line === node.loc!.start.line - 1); |
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.
Is a single character enough? Should there be a minimal length of explanation?
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.
What would you suggest as a minimal length?
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 wouldn't consider a single word to be a good enough reason. I'd say 20 characters could be fair, so that it can be a semblance of a valid sentence.
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.
That sounds fair, but I wonder how that would work with comments written in Asian languages such as Chinese or Japanese, which can be quite compact.
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 have been thinking, and I remember seeing quite a few times comments that just mention a Jira ticket number or a GitHub issue number.
return jestListener(); | ||
case dependencies.has('mocha'): | ||
return mochaListener(); | ||
case getPackageJsonsCount() > 0: |
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.
Why does this imply the nodejsListener?
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 assume that a Node.js project includes at least one package.json file so that the Node-specific listener is worth triggering. Do you think this assumption is nonsense?
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've only ever used jest, so I'm not sure how users normally setup the nodejs-tests. It's a foreign approximation for me.
* | ||
* Ignoring tests with Jasmine is done by using `xit`, `xdescribe`, or `xcontext`. | ||
*/ | ||
function jasmineListener(): Rule.RuleListener { |
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.
the jasmine, jest and mocha listeners follow the same convention. They only differ on the isIgnoredTest implementation. Could you merge them?
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 have mixed feelings about this because of past experiences. While it's true that the implementation is quite similar, I also feel that merging them may not be beneficial once we receive feedback from users and need to introduce framework-specific exceptions.
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.
Hm, well ok. I would say that's a premature separation, but I lack the experience here. Just a small fear, that there might also be improvements that will need to land in all 3 places.
e45eece
to
a19f8bf
Compare
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 answering the comments
}), | ||
create(context) { | ||
const dependencies = getDependencies(context.filename); | ||
switch (true) { |
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.
oh, that's also a new one for me as well. Interesting.
return jestListener(); | ||
case dependencies.has('mocha'): | ||
return mochaListener(); | ||
case getPackageJsonsCount() > 0: |
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've only ever used jest, so I'm not sure how users normally setup the nodejs-tests. It's a foreign approximation for me.
* | ||
* Ignoring tests with Jasmine is done by using `xit`, `xdescribe`, or `xcontext`. | ||
*/ | ||
function jasmineListener(): Rule.RuleListener { |
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.
Hm, well ok. I would say that's a premature separation, but I lack the experience here. Just a small fear, that there might also be improvements that will need to land in all 3 places.
@JavaScriptRule | ||
@TypeScriptRule | ||
@Rule(key = "S1607") | ||
public class NoSkippedTestsCheck extends Check { |
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.
Do we need tests for checks of rules without parameters?
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.
We never did that until now. Did something change recently?
Quality Gate passedIssues Measures |
no-skipped-tests
): Tests should not be skipped without providing a reason
RSPEC to review