question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve error message for differing output in RuleTester

See original GitHub issue

Right 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:closed
  • Created 7 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
vitorbalcommented, Apr 11, 2017

@kentcdodds Thanks for the update! Great job on that PR 😃

1reaction
kentcdoddscommented, Apr 11, 2017

This has been merged so the next version of Jest will support the assert module with much better messaging. This is fantastic 🎉

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found