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

update test suites #1668

Open
20 tasks
Tracked by #1666 ...
sydneywalcoff opened this issue Jan 13, 2025 · 0 comments
Open
20 tasks
Tracked by #1666 ...

update test suites #1668

sydneywalcoff opened this issue Jan 13, 2025 · 0 comments
Labels
DevOps type of development task related to Process, Github Actions, and Deployment feature: technical standards accessibility, usability, unit testing, etc. issue level I: request Smallest type of issue; Typically can be completed by one person priority: medium ready for dev lead task ready for dev lead to evaluate role: development anything related to code size: 3pt Can be done in 13-18 hours

Comments

@sydneywalcoff
Copy link
Member

sydneywalcoff commented Jan 13, 2025

Dependency

Overview

Create React App(CRA) deprecated and we had to migrate to Vite for future sustainability. However many of our test suites from #1241 use testing packages from CRA. We need to translate these test suites to use Vite-compatible tests.

Action Items

Update the test suites using the new test library:

Root folder

  • install vitest and @vitest/types npm packages
  • uninstall jest
  • update scripts in package.json so running npm run test uses vitestcommand instead of react-scripts test
  • update vite.config.ts file to add this to defineConfig in addition to plugins
    • some projects would have a separate vitest.config.ts file, but don't think we need one in this case
    • setupTests.js file already set up with @testing-library/jest-dom import
    • Jest has their globals API enabled by default, but Vitest doesn't, so needs to be included in the config
    • to replicate Jest's behavior of running hooks (like beforeEach, used in input button/routing tests) sequentially in Vitest, you can configure Vitest's sequence.hooks to 'list' in the test object
  test: {
    globals: true,
    environment: "jsdom",
    setupFiles: "./src/setupTests.js",
    sequence: {
      hooks: 'list',
    },
  • update tsconfig.json to add "types": ["vitest"], under compilerOptions

Individual test files

  • add import { describe, test, expect, vi } from 'vitest';
  • use vi.fn() instead of jest.fn() to mock functions

There may be additional updates needed based on the specifics of each test file, but this should get us most of the way there.

Resources/Notes

Vitest - Jest migration docs

@sydneywalcoff sydneywalcoff added role: development anything related to code dependency The issue or reason why this issue is in the icebox feature: technical standards accessibility, usability, unit testing, etc. DevOps type of development task related to Process, Github Actions, and Deployment priority: medium size: 3pt Can be done in 13-18 hours draft Not yet ready to be worked on labels Jan 13, 2025
@github-project-automation github-project-automation bot moved this to New Issues for approval in P: EA: Project Board Jan 13, 2025
@sydneywalcoff sydneywalcoff added this to the y. Technical Debt milestone Jan 13, 2025
@github-actions github-actions bot added the issue level: missing This issue is missing an issue level label label Jan 19, 2025
@sydneywalcoff sydneywalcoff added issue level I: request Smallest type of issue; Typically can be completed by one person and removed draft Not yet ready to be worked on issue level: missing This issue is missing an issue level label labels Jan 26, 2025
@sydneywalcoff sydneywalcoff moved this from New Issues for approval to Icebox in P: EA: Project Board Jan 26, 2025
@eburdekin eburdekin removed the dependency The issue or reason why this issue is in the icebox label Mar 17, 2025
@eburdekin eburdekin moved this from Icebox to New Issues for approval in P: EA: Project Board Mar 17, 2025
@eburdekin eburdekin added the ready for dev lead task ready for dev lead to evaluate label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DevOps type of development task related to Process, Github Actions, and Deployment feature: technical standards accessibility, usability, unit testing, etc. issue level I: request Smallest type of issue; Typically can be completed by one person priority: medium ready for dev lead task ready for dev lead to evaluate role: development anything related to code size: 3pt Can be done in 13-18 hours
Projects
Status: New Issues for approval
Development

No branches or pull requests

2 participants