Skip to content

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

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

Closed
truuman opened this issue Jul 27, 2022 · 1 comment

Comments

@truuman
Copy link

truuman commented Jul 27, 2022

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.

@lmiller1990
Copy link
Member

Almost certainly a Vue Jest issue!

@truuman truuman closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants