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

error: "don't know how to turn this value into a node" when using code coverage #10089

Closed
samstickland opened this issue May 26, 2020 · 15 comments

Comments

@samstickland
Copy link

🐛 Bug Report

After upgrading babel I get the following errors on some of test suite when code coverage is enabled:

 FAIL  spec/javascript/general-stats/GeneralStats.spec.js
  ● Test suite failed to run

    /Users/samuelstickland/development/hubbado/hubbado_core/app/javascript/general-stats/views/GeneralStats.vue: don't know how to turn this value into a node

      at valueToNode (node_modules/@babel/types/lib/converters/valueToNode.js:87:9)
      at Object.valueToNode (node_modules/@babel/types/lib/converters/valueToNode.js:81:58)
      at Object.exit (node_modules/istanbul-lib-instrument/dist/visitor.js:641:30)
      at PluginPass.exit (node_modules/babel-plugin-istanbul/lib/index.js:158:38)
      at newFn (node_modules/@babel/traverse/lib/visitors.js:179:21)
      at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:55:20)
      at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:42:17)
      at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:99:8)
      at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:112:16)
      at TraversalContext.visitSingle (node_modules/@babel/traverse/lib/context.js:84:19)
      at TraversalContext.visit (node_modules/@babel/traverse/lib/context.js:140:19)
      at Function.traverse.node (node_modules/@babel/traverse/lib/index.js:84:17)
      at traverse (node_modules/@babel/traverse/lib/index.js:66:12)
      at transformFile (node_modules/@babel/core/lib/transformation/index.js:107:29)
          at transformFile.next (<anonymous>)
      at run (node_modules/@babel/core/lib/transformation/index.js:35:12)

To Reproduce

Enable code coverage in jest.config.json and run the test suite via yarn test

  "collectCoverage": true,
  "collectCoverageFrom": [
    "<rootDir>/app/javascript/**/*.{js,vue}",
    "!<rootDir>/app/javascript/packs/*"
  ]

Expected behavior

Test suite runs correctly and code coverage is collected.

Link to repl or repo (highly encouraged)

This is a private repo. If there isn't enough information in the stack trace I can try and make a cutdown version I can make public

envinfo

  System:
    OS: macOS 10.15.4
  Binaries:
    Node: 14.3.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
  npmPackages:
    @babel/core: >=7.0.0 => 7.9.6
    babel-jest: >=26.0.0 => 26.0.1
    babel-loader: >=8.0.6 => 8.1.0
    babel-preset: >=1.0.15 => 1.1.4
    jest: >=26.0.0 => 26.0.1```
@kjugi
Copy link

kjugi commented May 28, 2020

Looks like it's the same issue as babel/babel#11439 or this one: storybookjs/storybook#10477

Did you check it before?

@samstickland
Copy link
Author

Thanks for taking a look.

Yes, I did check before and I couldn't find any other similar issues. To be honest, I'm not sure how the two issues you linked are the same as this one?

I do have another issue open in babeljs. I was going to close that one by they said to keep it open: babel/babel#11614

FWIW, I've tried deleting node_modules, the yarn.lock and upgrading every package to the latest versions. Same issue when code code coverage is enabled.

This is my full jest.config.json:

{
  "verbose": true,
  "rootDir": "../..",
  "roots": ["<rootDir>/spec/javascript", "<rootDir>/app/javascript"],
  "setupFiles": [
    "given2/setup"
  ],
  "moduleFileExtensions": ["js", "vue"],
  "moduleDirectories": ["node_modules", "app/javascript"],
  "moduleNameMapper": {
    "^~/(.*)$": "<rootDir>/app/javascript/$1"
  },
  "transform": {
    ".*\\.vue$": "<rootDir>/node_modules/vue-jest",
    "^.+\\.js$": "<rootDir>/node_modules/babel-jest"
  },
  "testPathIgnorePatterns": [
    "<rootDir>/config/webpack/"
  ],
  "collectCoverage": false,
  "collectCoverageFrom": [
    "<rootDir>/app/javascript/**/*.{js,vue}",
    "!<rootDir>/app/javascript/packs/*"
  ]
}

Looks to me that when coverage is enabled that it's trying to apply JS transformations to the Vue files.

Let me know if you think this should be an issue in vue-test-utils instead.

@kjugi
Copy link

kjugi commented May 28, 2020

Posted this 2 issues because have the same error and together with it there was also a message about missing mentioned module - @babel/compat-data/corejs3-shipped-proposals.

I guess it can be a problem related to @babel/preset-env version but don't have any ready solution for it

@samstickland
Copy link
Author

@kjugi I'm confused. It looks to me like the error in the two issues you posted is Cannot find module '@babel/compat-data/corejs3-shipped-proposals' but mine is don't know how to turn this value into a node.

I must be being dense - can you explain where the simularity is?

@kjugi
Copy link

kjugi commented May 31, 2020

I'm saying that in my case this error which you reported don't know how to turn this value into a node also occurs with this one: Cannot find module '@babel/compat-data/corejs3-shipped-proposals when collecting code coverage.

That's why I posted them there due to possible relation.

As you may saw in issues there are some problems when using babel older versions with node v13/v14 that's why you need to upgrade @babel/preset-env to >=7.9.0. For now, jest itself is using 7.1.0 and it may be a case - but also I can be wrong.

There are a few possible ways to fix this problem but it highly depends on your setup:

  1. Downgrade to node v12 (lts) + delete node_modules and yarn.lock and reinstall modules
  2. There is a possible problem in yarn.lock file with versions. You can check their integrity by following the yarn docs. Then fix your file and reinstall modules.
  3. Maybe there is a conflict between the different version of modules in installed dependencies but don't know if it can be an issue (contributors needs to update their libs if required)

If no one of this possible solution helps probably need to wait for someone else response i.e. jest contributors cause they are more familiar with jest code itself. Maybe in this case change in jest will be required.

@samstickland
Copy link
Author

@kjugi I actually started with Node 12 and tried upgrading to 14 to see if it would fix. I've just downgraded to v12, deleted yarn.lock and node_modules and reinstalled all the modules. Unfortunately I still have the same issue.

@nogic1008
Copy link

Same error occurs when update @jest/transform from 25.4.0 to 25.5.0.
I guess 2e45410 is related to this issue

@aldarund
Copy link
Contributor

aldarund commented Jun 23, 2020

node 12 and babel/preset-env at 7.10.3 ( latest babel ) still produce this error with vue and coverage

   at valueToNode (node_modules/@babel/types/lib/converters/valueToNode.js:87:9)
      at Object.valueToNode (node_modules/@babel/types/lib/converters/valueToNode.js:81:58)
      at Object.exit (node_modules/istanbul-lib-instrument/dist/visitor.js:641:30)
      at PluginPass.exit (node_modules/babel-plugin-istanbul/lib/index.js:158:38)
      at newFn (node_modules/@babel/traverse/lib/visitors.js:179:21)
      at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:55:20)
      at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:42:17)
      at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:99:8)
      at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:112:16)
      at TraversalContext.visitSingle (node_modules/@babel/traverse/lib/context.js:84:19)
      at TraversalContext.visit (node_modules/@babel/traverse/lib/context.js:140:19)
      at Function.traverse.node (node_modules/@babel/traverse/lib/index.js:84:17)
      at traverse (node_modules/@babel/traverse/lib/index.js:66:12)
      at transformFile (node_modules/@babel/core/lib/transformation/index.js:107:29)
          at transformFile.next (<anonymous>)
      at run (node_modules/@babel/core/lib/transformation/index.js:35:12)

none of solutions in this thread worked

@akagire
Copy link

akagire commented Jul 15, 2020

@aldarund I'm using Nuxt.js and got same problem. I find out this problems solution is downgrade vue-jest 4 to 3. Also probably need to install babel-core.
Same issue here vuejs/vue-jest#241

@nogic1008
Copy link

I got it!

@jest/transform creates inline source-map since 25.5.0(#9811).
But vue-jest@v4.0.0-beta already adds it with process().
So reporter throws error due to duplicate source maps.

Fixed in vuejs/vue-jest#255

@nogic1008
Copy link

@samstickland
fixed in vue-jest@4.0.0-rc.0. Please try this one!

@samstickland
Copy link
Author

@nogic1008 Yup, works for me! Thanks!

@jaythomas
Copy link

@nogic1008 what version of jest are you on? With jest@26.4.2 and vue-jest@4.0.0-rc.0 I still get [vue-jest] Error: Vue template compilation failed.

@nogic1008
Copy link

@jaythomas
It is out of the topic anymore.
Could you create a new issue on vuejs/vue-jest?

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants