Skip to content

Vue 2 - Jest stack trace line numbers wrong with TypeScript and Babel for SFC components #1989

Closed
@truuman

Description

@truuman

Subject of the issue

When running unit tests for Vue 2 SFC components with jest via vue-test-utils (+babel +typescript) the reported stack trace error line numbers are wrong.

Steps to reproduce

  1. Create a new Vue CLI project: npx @vue/cli create repro-project
    Screenshot 2022-07-27 155245
  2. Edit HelloWorld.vue component by adding a mounted() {} lifecycle hook containing something like this:
    mounted() {
      this.iAmNotDefined = iAmNotDefineder
    }
  3. Run npm run test:unit

or pull my repro repo and run npm install && npm run test:unit

Expected behaviour

The correct line number is shown in the stack trace.

Actual behaviour

The opposite of the expected behaviour.

Possible Solution

My hunch says it's a transformation issue, but I've no idea if it's ts-jest, vue-jest, babel-js or the sfc compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions