Skip to content

TypeError: Jest: a transform's process function must return a string, #42

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
ghost opened this issue Nov 2, 2017 · 7 comments
Closed

Comments

@ghost
Copy link

ghost commented Nov 2, 2017

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[x] support request

Current behavior

Fails with that errors:

$ npm test

> [email protected] test /home/r/w/webpack-test2
> jest

Failed to compile src with `tsc` at `vue-preprocessor`
 FAIL  tests/add.test.ts
  ● Test suite failed to run

    TypeError: Jest: a transform's `process` function must return a string, or an object with `code` key containing this string.
      
      at ScriptTransformer.transformSource (node_modules/jest-runtime/build/script_transformer.js:227:15)
      at Object.<anonymous> (tests/add.test.ts:6:15)

  console.info node_modules/vue/dist/vue.common.js:8248
    You are running Vue in development mode.
    Make sure to turn on production mode when deploying for production.
    See more tips at https://vuejs.org/guide/deployment.html

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.509s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

Expected behavior

Mormal completion of tests

Minimal reproduction of the problem with instructions
Minimal example here may be big) so I created minimal test example project.
Project contains vue app, and 2 type of tests. Testing .ts files and .vue componet.

https://gitlab.com/rokkerruslan/jest-ts-vue-test

What is the motivation / use case for changing the behavior?

I need testing as simple ts files and vue components files.

Please tell us about your environment:

npm 5.5.1

  • jest-vue-preprocessor: 1.1.X

1.3.1

Thanks for any asnwers!

@ghost ghost closed this as completed Nov 3, 2017
@khanharis87
Copy link

@rokkerruslan did you solve this issue?

@Michael-Gungaram
Copy link

Michael-Gungaram commented Dec 26, 2017

Any solution about this? Having the same issue.

@RehanSaeed
Copy link

Same here, any solutions?

@jeroenschieven
Copy link

jeroenschieven commented Mar 6, 2018

@khanharis87 @Michael-Gungaram @RehanSaeed Not sure if still relevant for you guys, but maybe it is for everyone else having this issue.

I had the same problem. Turned out that the problem only occurred when using Object spread syntax. The object spread syntax isn't supported by babel-core, so I had to install a plugin for that and add it to my .babelrc file. Check https://babeljs.io/docs/plugins/transform-object-rest-spread for more information about the plugin.

The problem could also occur with any other es7/es[future-releases] syntax your using in your files which is not supported by babel-core.

@samuelterra22
Copy link

thx @jeroenschieven ! I was having the same problem.

@Prior99
Copy link

Prior99 commented Jun 29, 2018

I am experiencing the same problem while using Typescript. Any solutions?

@MiguelSi6
Copy link

i had to add "jest-junit": "13.0.0", to package.json and the problem went away

This issue was closed.
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

7 participants