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

Getting "don't know how to turn this value into a node" using @vue/vue2-jest@^27.0.0-alpha.4 and jest@^27.1.0 #450

Closed
Spronghi opened this issue Feb 16, 2022 · 2 comments

Comments

@Spronghi
Copy link

Hi everyone,
I am getting an error when trying to execute my unit tests using @vue/vue2-jest@^27.0.0-alpha.4 and jest@^27.1.0. As far as I know this should be solved with this PR, but upgrading from older version of jest to a new one using vue upgrade --next breaks it.

This is the error:

    /path/to/file.ts: don't know how to turn this value into a node

      at valueToNode (node_modules/@babel/types/lib/converters/valueToNode.js:98:9)
      at Object.valueToNode (node_modules/@babel/types/lib/converters/valueToNode.js:92:58)
      at Object.exit (node_modules/istanbul-lib-instrument/src/visitor.js:700:36)
      at PluginPass.exit (node_modules/babel-plugin-istanbul/lib/index.js:158:38)
      at newFn (node_modules/@babel/traverse/lib/visitors.js:177:21)
      at NodePath._call (node_modules/@babel/traverse/lib/path/context.js:53:20)
      at NodePath.call (node_modules/@babel/traverse/lib/path/context.js:40:17)
      at NodePath.visit (node_modules/@babel/traverse/lib/path/context.js:109:8)
      at TraversalContext.visitQueue (node_modules/@babel/traverse/lib/context.js:103:16)
      at TraversalContext.visitSingle (node_modules/@babel/traverse/lib/context.js:77:19)
      at TraversalContext.visit (node_modules/@babel/traverse/lib/context.js:131:19)
      at traverseNode (node_modules/@babel/traverse/lib/traverse-node.js:24:17)
      at traverse (node_modules/@babel/traverse/lib/index.js:62:34)
      at transformFile (node_modules/@babel/core/lib/transformation/index.js:108:29)
          at transformFile.next (<anonymous>)
      at run (node_modules/@babel/core/lib/transformation/index.js:35:12)

Here's my jest.config.js:

module.exports = {
  globals: {
    'ts-jest': {
      isolatedModules: true,
    },
  },
  preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
  testEnvironment: 'jest-environment-jsdom',
  testMatch: [
    '<rootDir>/(src/**/*.spec.(ts|tsx|js))',
    '**/tests/unit/**/*.spec.[jt]s?(x)',
    '**/__tests__/*.[jt]s?(x)',
  ],
  transformIgnorePatterns: ['<rootDir>/node_modules/(?!(lit-element)/)'],
  collectCoverage: true,
  coverageDirectory: 'tests/coverage',
  reporters: [
    'default',
    [
      './node_modules/jest-html-reporter',
      {
        outputPath: 'tests/report/test_report.html',
      },
    ],
  ],
  setupFilesAfterEnv: ['./tests/unit/jest.init.ts'],
  moduleFileExtensions: ['js', 'ts', 'json', 'vue'],
  transform: {
    '^.+\\.ts$': 'ts-jest',
    '^.+\\.js$': 'babel-jest',
    '^.+\\.vue$': '@vue/vue2-jest',
  },
};

Am I missing something or is the bug still not solved?

Thanks a lot

@Spronghi
Copy link
Author

Spronghi commented Feb 16, 2022

It works if you use the options coverageReporters: 'v8' on the jest.config.js from the Coverage Provider on official Jest documentation but I think it doesn't solve the issue.

thebanjomatic pushed a commit to thebanjomatic/babel that referenced this issue Feb 17, 2022
When the sourcemaps were switched to use "@ampproject/remapping", the type
of the inputSourceMap that gets passed around changed from being a plain js
object to a `class SourceMap` fromthe remapping package. This causes issues
with the @babel/types valueToNode function because that function is defined
to throw for objects that aren't plain-objects.

In practice I was seeing this error after upgrading babel when running code-
coverage, and I saw a similar error reported here: vuejs/vue-jest#450 before
deciding to try to track the error down myself.
thebanjomatic pushed a commit to thebanjomatic/babel that referenced this issue Feb 17, 2022
When the sourcemaps were switched to use "@ampproject/remapping", the type
of the inputSourceMap that gets passed around changed from being a plain js
object to a `class SourceMap` fromthe remapping package. This causes issues
with the @babel/types valueToNode function because that function is defined
to throw for objects that aren't plain-objects.

In practice I was seeing this error after upgrading babel when running code-
coverage, and I saw a similar error reported here: vuejs/vue-jest#450 before
deciding to try to track the error down myself.
thebanjomatic pushed a commit to thebanjomatic/babel that referenced this issue Feb 17, 2022
When the sourcemaps were switched to use "@ampproject/remapping", the type
of the inputSourceMap that gets passed around changed from being a plain js
object to a `class SourceMap` fromthe remapping package. This causes issues
with the @babel/types valueToNode function because that function is defined
to throw for objects that aren't plain-objects.

In practice I was seeing this error after upgrading babel when running code-
coverage, and I saw a similar error reported here: vuejs/vue-jest#450 before
deciding to try to track the error down myself.
thebanjomatic pushed a commit to thebanjomatic/babel that referenced this issue Feb 17, 2022
When the sourcemaps were switched to use "@ampproject/remapping", the type
of the inputSourceMap that gets passed around changed from being a plain js
object to a `class SourceMap` fromthe remapping package. This causes issues
with the @babel/types valueToNode function because that function is defined
to throw for objects that aren't plain-objects.

In practice I was seeing this error after upgrading babel when running code-
coverage, and I saw a similar error reported here: vuejs/vue-jest#450 before
deciding to try to track the error down myself.
@Spronghi
Copy link
Author

Spronghi commented May 5, 2022

Can I close this?

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