Skip to content

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

Description

@Spronghi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions