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

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

Closed
6 tasks done
MichaelBrandt4994 opened this issue Jan 29, 2024 · 8 comments · Fixed by #5132
Closed
6 tasks done

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

MichaelBrandt4994 opened this issue Jan 29, 2024 · 8 comments · Fixed by #5132

Comments

@MichaelBrandt4994
Copy link

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

@BenShelton
Copy link

Experiencing the same here after upgrading from 1.1.1 to 1.2.2. Ended up downgrading back to 1.1.1 again, not entirely sure at what point this was introduced.

Copy link

Hello @MichaelBrandt4994. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@MichaelBrandt4994
Copy link
Author

will try a reproduction until friday

@mahdibx
Copy link

mahdibx commented Feb 1, 2024

I have the same issue, I think the test is not tearing down correctly because there are unfinished promises.

I have a very simple react component with two simple tests, the only particularity is there is an image with a source svg supposed to be in the public folder : <img src="logo.svg" />

It's very hard to conclude what the exact issue is because the error occurs very rarely.

Also the error only happens when running with other test suits in parallel, and I'm using pool: 'forks' in the conf.

@axel7083
Copy link

axel7083 commented Feb 1, 2024

We are experiencing the same issue, makes our CI tests flaky, as we are not able to make a fully reproducible example

@MichaelBrandt4994
Copy link
Author

It seems for us it was a problem of how we were mocking the vue-router in some unit tests.

In some components we were using router-link and we were testing if the push function was called. We assumed that we mocked it correctly, but it seems we were not 😄. Currently we removed the test cases where we checked, if the push function was called and we are stubbing now the router-link from vue-router.

All tests are now successfull even after multiple retries.

What helped me, was setting the retry to 1, then i saw in our tests a warning related to the vue-router, which i didn't saw before. Maybe the warning was not printed out, because it failed directly.

In the end it seems to be a problem of how we were testing. But still, on the version 1.1.3 we never had problems.

@axel7083
Copy link

axel7083 commented Feb 2, 2024

It seems for us it was a problem of how we were mocking the vue-router in some unit tests.

In some components we were using router-link and we were testing if the push function was called. We assumed that we mocked it correctly, but it seems we were not 😄. Currently we removed the test cases where we checked, if the push function was called and we are stubbing now the router-link from vue-router.

All tests are now successfull even after multiple retries.

What helped me, was setting the retry to 1, then i saw in our tests a warning related to the vue-router, which i didn't saw before. Maybe the warning was not printed out, because it failed directly.

In the end it seems to be a problem of how we were testing. But still, on the version 1.1.3 we never had problems.

We are not using vue-router, so it is probably not specific to this library

@tdebooij
Copy link

Can confirm that I no longer have this issue after updating to 1.3.0 👍

@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants