Skip to content

Stacktrace for syntax errors incorrectly points to the test file #308

@ecowden

Description

@ecowden

If I have a function under test with a syntax error like:

// demo.js
module.exports = function () { // missing closing brace

...and a test like:

// demoTest.js
const test = require('ava')
const demo = require('./demo')

test(async function (t) {
  t.ok(true)
})

Then the syntax error is reported pointing to the require statement in the test file instead of the file with the error:

Uncaught Exception:  /Users/cowdene/src/avaIssue/demoTest.js
  SyntaxError: Unexpected token )
    at Object.<anonymous> (/Users/cowdene/src/avaIssue/demoTest.js:2:14)

This is pretty confusing and is especially tricky for newer Node developers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcurrent functionality does not work as desired

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions