Skip to content

TypeError: Cannot read properties of null (reading 'transformMode') #5071

@MichaelBrandt4994

Description

@MichaelBrandt4994

Describe the bug

When executing vitest we receive the following error

⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯
TypeError: Cannot read properties of null (reading 'transformMode')
 ❯ getTransformMode node_modules/vitest/dist/vendor/execute.edwByI27.js:405:31
 ❯ Object.fetchModule node_modules/vitest/dist/vendor/execute.edwByI27.js:421:30
 ❯ VitestExecutor.directRequest node_modules/vite-node/dist/client.mjs:250:65
 ❯ VitestExecutor.cachedRequest node_modules/vite-node/dist/client.mjs:187:28
 ❯ VitestExecutor.dependencyRequest node_modules/vite-node/dist/client.mjs:233:23
 ❯ VitestExecutor.dependencyRequest node_modules/vitest/dist/vendor/execute.edwByI27.js:576:18

Sometimes the error doesn't show up and our tests are passing.

Here is our vitest.config.ts

import { fileURLToPath, URL } from "node:url"

import vue from "@vitejs/plugin-vue"
import vueJsx from "@vitejs/plugin-vue-jsx"
import VueMacros from "unplugin-vue-macros"
import { defineConfig } from "vitest/config"

export default defineConfig({
  appType: "spa",
  plugins: [VueMacros.vite({ plugins: { vue: vue(), vueJsx: vueJsx() } })],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      "./runtimeConfig": "./runtimeConfig.browser",
    },
  },
  envPrefix: "VUE_",
  test: {
    environment: "jsdom",
    transformMode: {
      web: [/.[tj]sx$/],
    },
  },
})

Reproduction

System Info

System:
    OS: Linux 6.5 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
    Memory: 16.05 GB / 30.97 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 21.6.0 - ~/.nvm/versions/node/v21.6.0/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v21.6.0/bin/npm
  npmPackages:
    @vitejs/plugin-vue: ^5.0.3 => 5.0.3 
    @vitejs/plugin-vue-jsx: ^3.1.0 => 3.1.0 
    @vitest/coverage-v8: ^1.2.1 => 1.2.1 
    vite: ^5.0.12 => 5.0.12 
    vitest: ^1.2.1 => 1.2.1

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions