Skip to content

Fix error messages when running tests - #2909

Open
mckenfra wants to merge 1 commit into
mozilla:mainfrom
mckenfra:fix-test-errors
Open

Fix error messages when running tests#2909
mckenfra wants to merge 1 commit into
mozilla:mainfrom
mckenfra:fix-test-errors

Conversation

@mckenfra

Copy link
Copy Markdown
Contributor

Before submitting your pull request

  • I agree to license my code under the MPL 2.0 license.
  • I rebased my work on top of the main branch.
  • I ran npm test and all tests passed.
  • I added test coverages if relevant.

Description

Fixes error messages shown when running npm run test due to:

  1. window.matchMedia is unsupported by jsdom
  2. Mocked document is unavailable when resolving promises in popup.js and pageAction.js where those promises are started but not awaited

Error messages example

> testpilot-containers@8.3.8 coverage
> nyc --reporter=html --reporter=text mocha test/**/*.test.js --timeout 60000

(node:66431) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)


  Assignment Reopen Feature
    set to 'Always open in' firefox-container-4
TypeError: window.matchMedia is not a function
    at Object.getTheme (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:43:344)
    at Object.applyTheme (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:43:793)
TypeError: window.matchMedia is not a function
    at Object.getTheme (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:43:344)
    at Object.applyTheme (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:43:793)
TypeError: window.matchMedia is not a function
    at Object.getTheme (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:49:344)
    at Object.applyTheme (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:49:793)
TypeError: window.matchMedia is not a function
    at Object.getTheme (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:49:344)
    at Object.applyTheme (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:49:793)
      ✔ should open the page in the assigned container
TypeError: Cannot read properties of undefined (reading 'querySelector')
    at eval (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:81:281)
    at Array.forEach (<anonymous>)
    at Object.showPanel (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:81:115)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
TypeError: Cannot read properties of undefined (reading 'querySelector')
    at eval (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:81:281)
    at Array.forEach (<anonymous>)
    at Object.showPanel (eval at buildDom (multi-account-containers/node_modules/webextensions-jsdom/src/nyc.js:58:16), <anonymous>:81:115)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Type of change

Select all that apply.

  • Bug fix
  • New feature
  • Major change (fix or feature that would cause existing functionality to work differently than in the current version)

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