addons icon indicating copy to clipboard operation
addons copied to clipboard

Server-specific tests should run w/ Jest testEnvironment: 'node'

Open ziir opened this issue 2 years ago • 1 comments

Uncovered in https://github.com/mozilla/addons-frontend/pull/11593#discussion_r899031000. Some server-specific tests run w/ Jest's testEnvironment: 'jsdom', which is the project's Jest config default. As a result, some globals are missing or extraneous & test environment is not suited. This can be solved by either:

  • splitting jsdom & node test environments w/ their own test command
  • using testEnvironment: 'node' by default, and using the @jest-environment jsdom docblock when needed
  • keeping testEnvironment: 'jsdom' by default, and using the @jest-environment node docblock when needed

See also:

  • https://testing-library.com/docs/react-testing-library/setup#jest-28
  • https://jestjs.io/docs/configuration#testenvironment-string

┆Issue is synchronized with this Jira Task

ziir avatar Jun 16 '22 14:06 ziir

Old Jira Ticket: https://mozilla-hub.atlassian.net/browse/ADDFRNT-84

KevinMind avatar May 03 '24 18:05 KevinMind