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

identify suitable testing substitute #1667

Open
2 of 7 tasks
Tracked by #1666
sydneywalcoff opened this issue Jan 13, 2025 · 4 comments
Open
2 of 7 tasks
Tracked by #1666

identify suitable testing substitute #1667

sydneywalcoff opened this issue Jan 13, 2025 · 4 comments
Assignees
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 role: development anything related to code size: 1pt can be done in 6 hours or less

Comments

@sydneywalcoff
Copy link
Member

sydneywalcoff commented Jan 13, 2025

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

@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 role: development anything related to code priority: medium size: 1pt can be done in 6 hours or less DevOps type of development task related to Process, Github Actions, and Deployment feature: technical standards accessibility, usability, unit testing, etc. labels Jan 13, 2025
@sydneywalcoff sydneywalcoff added this to the y. Technical Debt milestone Jan 13, 2025
@sydneywalcoff sydneywalcoff added the issue level I: request Smallest type of issue; Typically can be completed by one person label Jan 13, 2025
@sydneywalcoff sydneywalcoff moved this from New Issues for approval to Prioritized Backlog in P: EA: Project Board Jan 13, 2025
Copy link

Hey @eburdekin! Thanks for taking this issue.

To help keep everyone in the loop, please comment your Estimated Time to Completion (ETC) below!

Thanks again!

@sydneywalcoff sydneywalcoff moved this from Prioritized Backlog to In Progress (active) in P: EA: Project Board Feb 4, 2025
Copy link

github-actions bot commented Feb 6, 2025

Hey @eburdekin! Thanks again for taking this issue.

Time for an update! Please comment the following update:
**Progress:** What's the status of the project? What have you done and what still needs to be done?
**Estimated Time to Completion (ETC):** When do you estimate to be finished?
**Blockers:** Anything preventing you from finishing?

Thanks again!

1 similar comment
Copy link

Hey @eburdekin! Thanks again for taking this issue.

Time for an update! Please comment the following update:
**Progress:** What's the status of the project? What have you done and what still needs to be done?
**Estimated Time to Completion (ETC):** When do you estimate to be finished?
**Blockers:** Anything preventing you from finishing?

Thanks again!

@eburdekin
Copy link
Member

Hey @sydneywalcoff !

Setup notes for Vitest:

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

  • remove
  • 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.

References:
Vitest - Jest migration docs

@eburdekin eburdekin moved this from In Progress (active) to Ready for Review in P: EA: Project Board Feb 22, 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 role: development anything related to code size: 1pt can be done in 6 hours or less
Projects
Status: Ready for Review
Development

No branches or pull requests

2 participants