Improve error message for differing output in RuleTester
See original GitHub issueRight now the assertion looks like this
assert.equal(fixResult.output, item.output, "Output is incorrect.");
Which results in not very helpful output in test runs:
FAIL templates/01_eslint-simple-demo.test.js
● no-blockless-if › invalid › if (foo) foo()
AssertionError: Output is incorrect.
It would be much more helpful if the output were more like:
FAIL templates/01_eslint-simple-demo.test.js
● no-blockless-if › invalid › if (foo) foo()
AssertionError: Output is incorrect.
Expected value to be:
"if (foo) {
foo()
}"
Received:
"if (foo) foo()"
This is similar to what Jest’s output is. And perhaps @cpojer can give us a little direction on how to make that kind of output using one of Jest’s modules.
I’m happy to contribute this fix. I expect it to be relatively low-risk + high-impact
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
[Tests] Improve "Output is incorrect." for fixes assert message
Currently when an output condition is not matching the applied fix the assert message does not contain the expected and actual values: ...
Read more >Working with Rules - ESLint - Pluggable JavaScript Linter
"suggestion" means the rule is identifying something that could be done in a better way but no errors will occur if the code...
Read more >Observe constraint violations or severe errors
When you run a Ruletest in Studio, it might produce error messages. Error messages are distinct from Post messages you specified in Rulesheet...
Read more >Write eslint Rules That Meet Needs - Alibaba Cloud Community
This article discusses the general framework of eslint rule writing.
Read more >Creating a Custom ESLint Rule with TDD - DEV Community
For testing the rule I'm going to use the RuleTester which is a utility for writing tests for ESLint rules, and quite a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kentcdodds Thanks for the update! Great job on that PR 😃
This has been merged so the next version of Jest will support the assert module with much better messaging. This is fantastic 🎉