Skip to content
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

Not using tsconfig #8

Closed
eddyerburgh opened this issue Oct 1, 2017 · 6 comments
Closed

Not using tsconfig #8

eddyerburgh opened this issue Oct 1, 2017 · 6 comments

Comments

@eddyerburgh
Copy link
Member

Typescript was not using a tsconfig

Original issue - vuejs/vue-test-utils#47

This should be fixed in jest-vue 0.6.0.

@rndmerle
Copy link

rndmerle commented Oct 5, 2017

Thanks for taking the time to stab the issue.
I tried on the reproduction repo with jest-vue 0.6.0 (and then 0.7.0) and all other packages updated to latest version, and npm test -- --no-cache coughed this:

 TypeError: unknown: Cannot create property 'mappings' on string '{"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":"AAKA,OAAO,GAAG,MAAM,WAAW,CAAC;AAE5B,eAAe;IACX,IAAI,EAAE,WAAW;IACjB,UAAU,EAAE;QACR,GAAG,KAAA;KACN;CACJ,CAAA"}'

      at File.mergeSourceMap (node_modules/babel-core/lib/transformation/file/index.js:481:25)
      at File.generate (node_modules/babel-core/lib/transformation/file/index.js:719:25)
      at File.transform (node_modules/babel-core/lib/transformation/file/index.js:554:17)
      at node_modules/babel-core/lib/transformation/pipeline.js:50:19
      at File.wrap (node_modules/babel-core/lib/transformation/file/index.js:564:16)
      at Pipeline.transform (node_modules/babel-core/lib/transformation/pipeline.js:47:17)
      at compileBabel (node_modules/jest-vue/lib/compilers/babel-compiler.js:36:21)
      at compileTypescript (node_modules/jest-vue/lib/compilers/typescript-compiler.js:44:10)
      at processScript (node_modules/jest-vue/lib/process.js:14:12)
      at Object.module.exports [as process] (node_modules/jest-vue/lib/process.js:27:18)


[jest-vue] Info: no .babelrc found, defaulting to default babel options

Not sure why it's calling babel.
I updated the reproduction repository with latest versions.

@cgodley
Copy link

cgodley commented Oct 6, 2017

I had a similar problem and was able to fix it by editing typescript-compiler.js to pass the inputSourceMap to compileBabel as an object rather than a string:

- return compileBabel(res.outputText, res.sourceMapText)
+ return compileBabel(res.outputText, JSON.parse(res.sourceMapText))

@eddyerburgh
Copy link
Member Author

eddyerburgh commented Oct 6, 2017

Are you able to make a PR @cgodley?

I'm working on a fix

I added your fix @cgodley. The only way I can get TS compilation working is by passing it through babel before returning it.

I'm not a TS user, so I'm not sure if this is common or not.

If anyone would like to have a go at getting TS compilation working without babel, please do. There are tests to make sure children are compiled correctly.

@rndmerle
Copy link

I'm really lacking time currently to dig anything deeper.
But on our real project we've a weird behavior.

Using vue-test-utils@1.0.0-beta.2, if I upgrade jest-vue from 0.5.6 to 0.8.1 it kills the component stubbing of vue-test-utils's mount().
We're mounting components but still manually stubbing some sub-components. It works nicely with 0.5.6, but, when upgrading, all sub-components are mounting despite the stubbing.
I wish I had the time to put a reproduction up, but not right now sorry.

@blake-newman
Copy link
Member

This should be fixed with vuejs/vue-test-utils#115

I have also noticed that there is some issues with newer versions of jest where things where auto mocked.

Here is my configuration for further reference...

"jest": {
    "moduleFileExtensions": ["js", "json", "ts", "tsx", "vue"],
    "testRegex": "(/__tests__/.*|(\\.|/)test)\\.(tsx?)$",
    "modulePaths": ["<rootDir>/src/"],
    "moduleDirectories": ["node_modules", "<rootDir>/src/"],
    "transform": {
      "^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js",
      "^.+\\.vue?$": "<rootDir>/node_modules/jest-vue"
    },
    "verbose": true,
    "mapCoverage": true
}

@rndmerle
Copy link

I took the time to update and test. It seems to be working fine for me.
Thanks!

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

4 participants