Skip to content

Commit

Permalink
Reduce noise in unit test logs
Browse files Browse the repository at this point in the history
The logs contain a number of the following type of error:
```
      Error: Not implemented: window.computedStyle(elt, pseudoElt)
          at module.exports
(/home/prow/go/src/github.com/tektoncd/dashboard/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
          at Window.getComputedStyle
(/home/prow/go/src/github.com/tektoncd/dashboard/node_modules/jsdom/lib/jsdom/browser/Window.js:798:7)
          at getComputedStyle
(/home/prow/go/src/github.com/tektoncd/dashboard/node_modules/carbon-components-react/lib/components/Tooltip/Tooltip.js:81:55)
```

This is caused by the Carbon Tooltip component passing a second argument to
`getComputedStyle` referencing a pseudo element. This is not implemented in
jsdom resulting in the errors.

Since this shouldn't affect the tests, strip the second argument when calling
`getComputedStyle` in the tests to resolve the error and reduce noise in the logs.
  • Loading branch information
AlanGreene committed Apr 26, 2023
1 parent 12fe270 commit cda9f85
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config_frontend/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ window.HTMLElement.prototype.scrollIntoView =
window.TextDecoder = TextDecoder;
window.TextEncoder = TextEncoder;

const { getComputedStyle } = window;
window.getComputedStyle = element => getComputedStyle(element);

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
Expand Down

0 comments on commit cda9f85

Please sign in to comment.