ROX-33205: Upgrade vitest 4.1.0 by pedrottimark · Pull Request #19462 · stackrox/stackrox

Description

https://vitest.dev/blog/vitest-4

https://vitest.dev/guide/migration

Vitest 4.0 requires Vite >= 6.0.0 and Node.js >= 20.0.0.

https://vitest.dev/guide/migration.html#simplified-exclude

By default, Vitest now only excludes tests from node_modules and .git folders.

This means that Vitest no longer excludes:

  • dist and cypress folders
  • .idea, .cache, .output, .temp folders
  • config files like rollup.config.js, prettier.config.js, ava.config.js and so on

If you need to limit the directory where your tests files are located, use the test.dir option instead because it is more performant than excluding files

eslint-plugin-vitest

https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md

This rule aims to prevent false positive test results by highlighting conditional expect statements.

That is, if conditional is incorrect, I guess.

Add ESLint disable comment, because false positive does not seem like a risk.

plugin-react

TL;DR Upgrade to 5.2.0 because it supports, but does not require, vite 8.

https://github.com/vitejs/vite-plugin-react/releases/tag/plugin-react%406.0.0

Vite 7 and below are no longer supported. If you are using Vite 7, please upgrade to Vite 8.

https://github.com/vitejs/vite-plugin-react/releases/tag/plugin-react%405.2.0

This plugin is compatible with Vite 8.

https://github.com/vitejs/vite-plugin-react/releases/tag/plugin-react%405.0.0

This plugin now requires Node 20.19+ or 22.12+.

Procedure

  1. npm outdated in ui/apps/platform folder.

  2. Visit npmjs.com for outdated vitest and related dependencies

    • @testing-library/…
    • @vitest/…
  3. Click Repository link, and then read either of the following:

    • Releases
    • CHANGELOG.md

User-facing documentation

  • CHANGELOG.md update is not needed
  • documentation PR is not needed

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • edited unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  1. npm run tsc in ui/apps/platform folder.
  2. npm run lint:fast-dev in ui/apps/platform folder.
  3. npm run test in ui/apps/platform folder.

Same counts before and after upgrade:

 Test Files  122 passed (122)
      Tests  1316 passed | 2 skipped (1318)