-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Wrong line number shown for failing assert #1980
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
Comments
Updated with minimal reproduction |
Could you try configuring I suspect the double compilation may be causing trouble. Perhaps AVA loads its internal source map and the one from |
I followed the docs and tried to configure
Seems that the docs are wrong about how to configure |
Errors in the source file are still reported on the wrong line (a failing assert in the test file is correctly reported). I tried disabling sourceMaps in babel/register, but it still doesn't work. |
That may need a file extension.
Always!
OK. It may be a little while until I have time to look into this further. |
The workaround I've found is to disable AVA's builtin babel transpilation with require('@babel/register')({
ignore: [
/node_modules/,
/build\//,
/coverage\//,
],
inputSourceMap: true,
plugins: [
[
'istanbul',
{
all: true,
cache: true,
exclude: ['**/test_*.js', 'src/functional_tests/*'],
include: ['src/**/*.js'],
},
],
],
presets: ['@ava/transform-test-files'],
})
Now the reported line numbers of errors are correct both in test files and source files. |
Happening to me with this config: {
"ava": {
"require": [
"esm"
],
"babel": false,
"extensions": [
"mjs"
]
},
} |
The issue always reproduces when |
@IssueHunt has funded $60.00 to this issue.
|
Just add |
I think this is a source map problem. #2474 could be a solution. |
Uh oh!
There was an error while loading. Please reload this page.
Description
AVA reports the wrong line number on failing tests. It seems that sourcemaps aren't working, as the line number is greater than the size of the test file. When the line number falls within the source file, a snippet is displayed, but it does not correspond with the failing assertion.
Test Source
Error Message & Stack Trace
The test file is only 7 lines long, yet the line 40 is indicated in the message below:
Config
I am using ava.config.js:
.babelrc
Command-Line Arguments
Relevant Links
Minimal reproduction
parameter_convert.js
Environment
The text was updated successfully, but these errors were encountered: