Skip to content

Conversation

@nishitmistry
Copy link
Contributor

@nishitmistry nishitmistry commented Jan 6, 2026

In continuation of the previous PR #3880 for task #3768

  • disabled EntitiesList.test.js test and have created a Github issue regarding it Fix EntitiesList.test.js to properly work with vitest #3883
  • removed jest package, globals, and other related files
  • added vitest/eslint-plugin and tsconfig vitest type declarations
  • removed jest job and added vitest codecov action
  • changed relevant docs and makefile mentioning vitest

@eemeli this PR marks the completion of jest to vitest migration but alot of sinon mock are still present so should i start the migration of sinon mock to vitest under #3768 task ?

this PR will be ready to review once #3882 is merged

@nishitmistry nishitmistry marked this pull request as draft January 6, 2026 06:56
@nishitmistry nishitmistry force-pushed the drop-Jest-test-environment-in-favor-of-Vitest branch from 7f9a9ce to 49b971e Compare January 6, 2026 16:48
@eemeli
Copy link
Member

eemeli commented Jan 7, 2026

@eemeli this PR marks the completion of jest to vitest migration but alot of sinon mock are still present so should i start the migration of sinon mock to vitest under #3768 task ?

Yes please!

Copy link
Member

@eemeli eemeli left a comment

Choose a reason for hiding this comment

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

A first-pass review, see inline for fixes.

@nishitmistry Please note that I'll be on vacation from the end of this week until the end of January, so probably won't be available for reviews until early February.

Also, we have a Matrix channel #pontoon:mozilla.org you could consider joining?

Comment on lines 86 to 88
return Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query) => ({
value: vi.fn().mockImplementation((query) => ({
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we do something like this instead? Also, could we confirm that mocking this is even necessary anymore?

vi.spyOn(window, 'matchMedia').mockImplementation(() => ({ ... }));

Copy link
Contributor Author

@nishitmistry nishitmistry Jan 7, 2026

Choose a reason for hiding this comment

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

unfortunately this does not work i guess its because jsdom still haven't implemented matchMedia mock jsdom issue and spyOn cries when it receives undefined instead of a function.
i have changed this to mock using vi.stubGlobal which does same thing but cleaner.

the mock is indeed necessary, but thing is matchMedia is not being called in any test so removing this makes no difference. i have removed the mockMatchMedia calls but have kept the util function.

@nishitmistry nishitmistry force-pushed the drop-Jest-test-environment-in-favor-of-Vitest branch from dd504ab to 12eee31 Compare January 7, 2026 17:22
@nishitmistry nishitmistry force-pushed the drop-Jest-test-environment-in-favor-of-Vitest branch from 12eee31 to 97986ef Compare January 7, 2026 17:24
@nishitmistry
Copy link
Contributor Author

Hey @eemeli thanks for the heads up regarding your vacation i will try to create the sinon migration PR asap, i have joined Matrix channel and i guess all the future queries should be addressed directly in the channel or Dms, right :) ?

@nishitmistry nishitmistry marked this pull request as ready for review January 7, 2026 17:33
@nishitmistry nishitmistry requested a review from eemeli January 7, 2026 17:38
Copy link
Member

@eemeli eemeli left a comment

Choose a reason for hiding this comment

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

Other than the one inline suggestion, this looks good to merge.

i have joined Matrix channel and i guess all the future queries should be addressed directly in the channel or Dms, right :) ?

Feel free to continue with whatever seems most appropriate for any given query. Probably better to use the channel or comments/issues on GitHub as a default; while I'm out (and also otherwise!) @mathjazz is actually our main Pontoon developer, and there are also others who might be able to answer any questions you have.

*
* Source: https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
*/
export function mockMatchMedia() {
Copy link
Member

Choose a reason for hiding this comment

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

If/as this isn't used by anything anymore, we should remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

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.

2 participants