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

Vitest runner reports TypeError: Cannot read properties of undefined (reading 'close') #4280

Closed
nicojs opened this issue Jun 8, 2023 · 4 comments · Fixed by #4284
Closed
Labels
🐛 Bug Something isn't working
Milestone

Comments

@nicojs
Copy link
Member

nicojs commented Jun 8, 2023

Summary

22:41:37 (29261) INFO HtmlReporter Your report can be found at: file:///home/nicojs/tmp/vue-project/reports/mutation/mutation.html
22:41:37 (29261) INFO MutationTestExecutor Done in 3 seconds.
22:41:37 (29261) WARN ChildProcessTestRunnerProxy An unexpected error occurred during test runner disposal. This might be worth looking into. Stryker will ignore this error. StrykerError: TypeError: Cannot read properties of undefined (reading 'close')

Stryker config

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "_comment": "This config was generated using 'stryker init'. Please take a look at: https://stryker-mutator.io/docs/stryker-js/configuration/ for more information.",
  "packageManager": "npm",
  "mutate": [
    "{src,lib}/**/!(*.+(s|S)pec|*.+(t|T)est).+(cjs|mjs|js|ts|jsx|tsx|html|vue)",
    "!{src,lib}/**/__tests__/**/*.+(cjs|mjs|js|ts|jsx|tsx|html|vue)"
  ],
  "reporters": [
    "html",
    "clear-text",
    "progress"
  ],
  "testRunner": "vitest"
}

Test runner config

import { fileURLToPath } from 'node:url'
import { mergeConfig } from 'vite'
import { configDefaults, defineConfig } from 'vitest/config'
import viteConfig from './vite.config'

export default mergeConfig(
  viteConfig,
  defineConfig({
    test: {
      environment: 'jsdom',
      exclude: [...configDefaults.exclude, 'e2e/*'],
      root: fileURLToPath(new URL('./', import.meta.url)),
      transformMode: {
        web: [/\.[jt]sx$/],
      },
    }
  })
)

Stryker environment

├── @stryker-mutator/core@7.0.2
├── @stryker-mutator/vitest-runner@7.0.2
├── vitest@0.31.4

Test runner environment

vitest

Add stryker.log
stryker.log

@nicojs nicojs added the 🐛 Bug Something isn't working label Jun 8, 2023
@nicojs nicojs added this to the 7.1 milestone Jun 8, 2023
@nicojs
Copy link
Member Author

nicojs commented Jun 9, 2023

The cause is that StrykerJS will call dispose even if init was never called. Let us try to fix this in StrykerJS's core: from a test-runners perspective, it doesn't make sense to dispose without init.

@islasjuanp
Copy link

Hi @nicojs 👋

Thanks for fixing this issue. I am integrating stryker-js in a small project with Vitest and I am facing this issue. Do you know when it will be available?

@nicojs
Copy link
Member Author

nicojs commented Jun 16, 2023

This will be released in a week or so, but this is purely cosmetics afaik, you can simply ignore this warning in the meantime 😉

@nicojs
Copy link
Member Author

nicojs commented Jun 24, 2023

Released in 7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants