Skip to content

Migrate to vite#933

Open
mshriver wants to merge 1 commit into
ibutsu:mainfrom
mshriver:vite-migration
Open

Migrate to vite#933
mshriver wants to merge 1 commit into
ibutsu:mainfrom
mshriver:vite-migration

Conversation

@mshriver

@mshriver mshriver commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Migrate the frontend from create-react-app/Jest tooling to a Vite + Vitest stack, updating build and test scripts, configs, and dependencies while cleaning up legacy CRA artifacts and aligning project metadata with Ibutsu.

New Features:

  • Introduce Vite-based dev server and build pipeline for the frontend
  • Add Vitest-based test runner and coverage reporting for unit tests

Enhancements:

  • Simplify version file generation script to use Node fs instead of fs-extra
  • Update frontend entrypoint HTML and manifest to reflect Ibutsu branding
  • Modernize ESLint configuration using @eslint-react and Vitest globals

Build:

  • Replace create-react-app react-scripts tooling with Vite configuration and scripts
  • Update Cypress component testing configuration to use Vite as the bundler
  • Remove legacy CRA-specific settings, service worker wiring, and Docker nginx entrypoint

Documentation:

  • Update web manifest metadata (app name and short name) to match Ibutsu application

Tests:

  • Migrate Jest-based tests and utilities to Vitest globals and environment
  • Align coverage configuration with Vitest v8 provider and inline PatternFly/testing-library deps

Chores:

  • Clean up unused Babel, CRA, and Jest-related dependencies and polyfills from package.json and project files

@sourcery-ai

sourcery-ai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Migrate the frontend from Create React App/Jest to a Vite/Vitest-based toolchain, updating build/test scripts, lint configuration, and test code to use Vitest while removing obsolete CRA artifacts.

File-Level Changes

Change Details Files
Replace CRA/react-scripts and Jest-based tooling with Vite/Vitest in the frontend build and test pipeline.
  • Update package.json dependencies to remove react-scripts, Babel/Jest-specific packages and add vite, vitest, @vitejs/plugin-react, @vitest/coverage-v8, jsdom and updated lint plugins.
  • Change npm scripts to use vite for dev/build/preview and vitest for test and coverage commands, preserving write-version-file.cjs in the flow.
  • Remove Jest configuration, browserslist, and bin section from package.json as they are no longer needed with Vite/Vitest.
  • Simplify .yarnrc.yml by removing react-scripts-related log filter and TypeScript from preapproved packages.
frontend/package.json
frontend/.yarnrc.yml
frontend/yarn.lock
Introduce Vite configuration and HTML entry point to replace CRA’s webpack and HTML shell.
  • Add vite.config.js with React plugin, custom jsx-in-js transform, build output configuration, dev server options, and Vitest test/coverage configuration mimicking previous Jest settings.
  • Add top-level index.html for Vite including root div, settings.js script, manifest link, and module script pointing to src/index.js.
  • Remove CRA-specific HTML, service worker files, polyfills, Docker nginx/entrypoint used for CRA static bundle, and other unused assets like logo.svg and recover.json.
frontend/vite.config.js
frontend/index.html
frontend/public/index.html
frontend/src/pages/service-worker.js
frontend/jest.polyfills.cjs
frontend/docker/Dockerfile.frontend
frontend/docker/docker-entrypoint.sh
frontend/docker/nginx.conf
frontend/src/logo.svg
frontend/recover.json
Adjust application bootstrap and ancillary scripts to align with Vite and remove service worker/Babel-specific utilities.
  • Update src/index.js to drop service worker import/usage while keeping React root rendering and theme initialization.
  • Refactor bin/write-version-file.cjs to use Node’s fs module instead of fs-extra and to read/write JSON with explicit encoding.
frontend/src/index.js
frontend/bin/write-version-file.cjs
Reconfigure ESLint to work with the new stack and add React-specific rules via @eslint-react/eslint-plugin and Vitest globals.
  • Replace eslint-plugin-react flat configs with @eslint-react/eslint-plugin recommended config for React source files.
  • Remove Babel ESLint parser and preset-based parserOptions, relying on standard ECMAScript parser options compatible with Vite.
  • Drop eslint-plugin-jsx-a11y from the active config with a TODO comment about re-enabling when ESLint 10 is supported.
  • Add globals for Vitest (vi, describe, it, expect, lifecycle hooks) in test and test utility files configuration.
  • Tighten React-related lint rules by enabling @eslint-react rules around component hooks and nested definitions while continuing to use react-hooks plugin.
frontend/eslint.config.mjs
Migrate unit and integration tests from Jest APIs to Vitest APIs and adjust mocks/globals accordingly.
  • Replace jest.mock/jest.fn/jest.spyOn/jest.useFakeTimers and related calls with Vitest’s vi.mock/vi.fn/vi.spyOn/vi.useFakeTimers/vi.clearAllMocks across component, page, widget, utility, and modal tests.
  • Update tests that relied on Jest globals (matchMedia, ResizeObserver, fetch, Storage) to use vi.fn/vi.spyOn for mocking and spying.
  • Remove import of jest.polyfills.cjs from setupTests.js, keeping only @testing-library/jest-dom and test-utils reset configuration.
  • Ensure tests reference Vitest globals via ESLint configuration rather than Jest-specific globals.
frontend/src/setupTests.js
frontend/src/components/ibutsu-header.test.js
frontend/src/components/classify-failures.test.js
frontend/src/components/test-history.test.js
frontend/src/pages/result-list.test.js
frontend/src/pages/run-list.test.js
frontend/src/widgets/result-summary-apex.test.js
frontend/src/views/jenkins-job-analysis.test.js
frontend/src/widgets/run-aggregate-apex.test.js
frontend/src/pages/dashboard.test.js
frontend/src/pages/login.test.js
frontend/src/views/jenkins-job.test.js
frontend/src/widgets/result-aggregate-apex.test.js
frontend/src/widgets/filter-heatmap.test.js
frontend/src/widgets/generic-bar.test.js
frontend/src/pages/admin/project-list.test.js
frontend/src/pages/admin/user-list.test.js
frontend/src/components/result-view.test.js
frontend/src/components/filtering/result-filter.test.js
frontend/src/widgets/generic-area.test.js
frontend/src/widgets/importance-component.test.js
frontend/src/pages/run.test.js
frontend/src/components/filtering/run-filter.test.js
frontend/src/components/modals/new-widget-wizard.test.js
frontend/src/pages/admin/project-edit.test.js
frontend/src/utilities/auth.test.js
frontend/src/components/modals/edit-widget-modal.test.js
frontend/src/components/filtering/admin-filter.test.js
frontend/src/components/filtering/filtered-table-card.test.js
frontend/src/views/compare-runs.test.js
frontend/src/utilities/http.test.js
frontend/src/utilities/utilities.test.js
frontend/src/components/filtering/active-filters.test.js
frontend/src/components/modals/delete-modal.test.js
frontend/src/components/modals/add-token-modal.test.js
frontend/src/components/modals/new-dashboard-modal.test.js
frontend/src/test-utils/test-helpers.js
Update Cypress component testing configuration to use Vite as the dev server bundler.
  • Change Cypress config component.devServer to framework "react" and bundler "vite" instead of CRA/webpack.
  • Keep spec patterns and excludes unchanged to preserve existing test discovery.
frontend/cypress.config.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

Fixed security issues:

  • lodash.template (link) · Dashboard

  • nth-check (link) · Dashboard

  • serialize-javascript (link) · Dashboard

  • shelljs (link) · Dashboard

  • underscore (link) · Dashboard

  • undici (link) · Dashboard

  • The ESLint config now imports eslint-plugin-cypress from 'eslint-plugin-cypress' but still uses pluginCypress.configs.recommended, which is only exposed by the /flat entry point; consider switching back to eslint-plugin-cypress/flat or updating the config usage to match the non-flat plugin API.

  • In vite.config.js, the jsxInJs plugin matches files via /src\/.*\.js$/, which will not work on Windows paths and may miss files when Vite uses absolute paths; consider using a more robust check like id.endsWith('.js') && id.includes('/src/') or path.sep-aware logic.

Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The ESLint config now imports `eslint-plugin-cypress` from `'eslint-plugin-cypress'` but still uses `pluginCypress.configs.recommended`, which is only exposed by the `/flat` entry point; consider switching back to `eslint-plugin-cypress/flat` or updating the config usage to match the non-flat plugin API.
- In `vite.config.js`, the `jsxInJs` plugin matches files via `/src\/.*\.js$/`, which will not work on Windows paths and may miss files when Vite uses absolute paths; consider using a more robust check like `id.endsWith('.js') && id.includes('/src/')` or `path.sep`-aware logic.

## Individual Comments

### Comment 1
<location path="frontend/vite.config.js" line_range="1-2" />
<code_context>
+import { defineConfig } from 'vitest/config';
+import { transformWithOxc } from 'vite';
+import react from '@vitejs/plugin-react';
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Vite does not export `transformWithOxc`; this plugin will likely fail at runtime.

The `jsxInJs` plugin imports `transformWithOxc` from `vite`, but this symbol is not part of Vite’s public API, so the import will fail and prevent the dev server/build from starting. To handle `.js` files with JSX, use Vite’s `transformWithEsbuild` or rely on the React plugin’s JSX support (e.g., via appropriate `esbuild` options) instead of a non-existent helper.
</issue_to_address>

### Comment 2
<location path="frontend/vite.config.js" line_range="5-12" />
<code_context>
+  name: 'jsx-in-js',
+  enforce: 'pre',
+  async transform(code, id) {
+    if (!/src\/.*\.js$/.test(id)) return null;
+    return transformWithOxc(code, id, { lang: 'jsx' });
+  },
</code_context>
<issue_to_address>
**suggestion (bug_risk):** The JSX-in-JS filter assumes POSIX paths and may skip files on non-Unix environments.

The plugin currently matches only POSIX-style paths (`src/...`) and will miss Windows paths with backslashes (e.g. `src\components\x.js`). For cross-platform support, normalize `id` to use `/` before testing, or base the check on `path.sep`/`endsWith('.js')` rather than a hardcoded `/src/` regex.

```suggestion
const jsxInJs = () => ({
  name: 'jsx-in-js',
  enforce: 'pre',
  async transform(code, id) {
    const normalizedId = id.replace(/\\/g, '/');
    if (!/src\/.*\.js$/.test(normalizedId)) return null;
    return transformWithOxc(code, normalizedId, { lang: 'jsx' });
  },
});
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread frontend/vite.config.js
Comment on lines +1 to +2
import { defineConfig } from 'vitest/config';
import { transformWithOxc } from 'vite';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Vite does not export transformWithOxc; this plugin will likely fail at runtime.

The jsxInJs plugin imports transformWithOxc from vite, but this symbol is not part of Vite’s public API, so the import will fail and prevent the dev server/build from starting. To handle .js files with JSX, use Vite’s transformWithEsbuild or rely on the React plugin’s JSX support (e.g., via appropriate esbuild options) instead of a non-existent helper.

Comment thread frontend/vite.config.js
Comment on lines +5 to +12
const jsxInJs = () => ({
name: 'jsx-in-js',
enforce: 'pre',
async transform(code, id) {
if (!/src\/.*\.js$/.test(id)) return null;
return transformWithOxc(code, id, { lang: 'jsx' });
},
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): The JSX-in-JS filter assumes POSIX paths and may skip files on non-Unix environments.

The plugin currently matches only POSIX-style paths (src/...) and will miss Windows paths with backslashes (e.g. src\components\x.js). For cross-platform support, normalize id to use / before testing, or base the check on path.sep/endsWith('.js') rather than a hardcoded /src/ regex.

Suggested change
const jsxInJs = () => ({
name: 'jsx-in-js',
enforce: 'pre',
async transform(code, id) {
if (!/src\/.*\.js$/.test(id)) return null;
return transformWithOxc(code, id, { lang: 'jsx' });
},
});
const jsxInJs = () => ({
name: 'jsx-in-js',
enforce: 'pre',
async transform(code, id) {
const normalizedId = id.replace(/\\/g, '/');
if (!/src\/.*\.js$/.test(normalizedId)) return null;
return transformWithOxc(code, normalizedId, { lang: 'jsx' });
},
});

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant