Failed test doesn't show diff
sanfilippopablo opened this issue · 6 comments
babel-plugin-tester
version: 5.4.0node
version: 9.8.0npm
(oryarn
) version: 5.6.0
Relevant code or config
const pluginTester = require('babel-plugin-tester')
const myPlugin = require('./plugin')
pluginTester({
plugin: myPlugin,
filename: __filename,
tests: [{
fixture: '__fixtures__/1/from.js',
outputFixture: '__fixtures__/1/to.js'
}],
babelOptions: {
babelrc: true
}
})
What you did:
I ran jest using jest test.js and the test failed, like it should, but I was expecting the usual diff showing what it got and what it expected, but only the following output appeared. Am I doing something wrong or does it only show that message?
What happened:
FAIL ./test.js
ast-transform
✕ 1. ast-transform (57ms)
● ast-transform › 1. ast-transform
AssertionError [ERR_ASSERTION]: Output is incorrect.
at tester (node_modules/babel-plugin-tester/dist/index.js:206:28)
at Object.<anonymous> (node_modules/babel-plugin-tester/dist/index.js:114:13)
at step (node_modules/babel-plugin-tester/dist/index.js:43:191)
at node_modules/babel-plugin-tester/dist/index.js:43:361
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 1.49s
Ran all test suites matching /test.js/i.
Hi @sanfilippopablo!
I'm pretty sure this is a bug in jest. It should show the assert actual and expected values. Could make a simple reproduction (doesn't need to use babel-plugin-tester) that uses assert
rather than expect
and file an issue in Jest?
I don't think we should make changes to this project.
I tried like that but I couldn't reproduce, it shows the diff just fine. The problem is when I use babel-plugin-tester. I created a minimal repo with two tests, one using pluginTester and other using assert directly. The first doesn't show a diff, but the other one does.
Interesting! Thanks for making that! Would you be willing to dig a little bit to figure out what's wrong?
Yes! On it. Let's see what I can find.
Found the issue. It's most definitely a bug in jest, not in this project. The problem is when using assert on a test whose function returns a promise.
const assert = require('assert')
// It shows the diff
test('it shows diff', () => {
assert.equal('hello\ngoodbye', 'hello', 'hmmm')
})
// It doesn't show the diff
test('it shows diff async', async () => {
assert.equal('hello\ngoodbye', 'hello', 'hmmm')
})
Closing this one.
Awesome! Thanks for looking into it! I hope it can be fixed!