Not implemented: window.computedStyle(elt, pseudoElt)
See original GitHub issueI am getting the following error for the following test with jest-axe:
Am I missing something?
Error: Not implemented: window.computedStyle(elt, pseudoElt)
test/setup.ts:
import '@testing-library/jest-dom/extend-expect'
import 'jest-axe/extend-expect'
file.spec.tsx:
const a11y = await axe(container)
expect(a11y).toHaveNoViolations()
jest.config.js
{
displayName: 'web:test',
preset: 'ts-jest',
testEnvironment: 'jsdom',
testMatch: ['**/__tests__/**/+(*.)+(spec|test).+(js|ts)?(x)'],
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/src/$1',
'^test/(.*)$': '<rootDir>/test/$1'
},
setupFilesAfterEnv: ['<rootDir>/test/setup.ts'],
globals: {
'ts-jest': {
tsconfig: {
jsx: 'react'
}
}
}
}
deps:
“jest”: “^26.6.3”, “jest-axe”: “^4.1.0”, “react-test-renderer”: “^17.0.1”, “ts-jest”: “^26.4.4”, “typescript”: “^4.1.2”
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Not implemented: window.computedStyle(elt, pseudoElt) #147
I am getting the following error for the following test with jest-axe: Am I missing something? Error: Not implemented: window.
Read more >Not implemeted window errors in react-testing-library
The tests are all passing but I get a large amount of errors from jsdom logged to the console: Error: Not implemented: window.computedStyle(elt, ......
Read more >Not implemented: window.computedStyle(elt, pseudoElt)
Coming soon: A brand new website interface for an even better experience!
Read more >jest: debugging 'not implemented' errors - code-comments
I recently added a feature to an app that scrolls the user to the top of page on navigation. Unfortunately, this started spewing...
Read more >Window.getComputedStyle() - Web APIs | MDN
The Window.getComputedStyle() method returns an object containing the values of all CSS properties of an element, after applying active ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This workaround appears to break functionality in jest-axe, my simple check with a missing
<select>label will return green whenwindow.getComputedStyleis just replaced with a noop.As an alternative I’ve only stripped the second (unsupported) parameter and this at least keeps that test functional:
You can add this in a testSetup file to apply to all tests instead of using a local
beforeAll. That said: I expect that this will still introduce inaccuracy in tests, that second param must be there for a reason.This issue in the jest-dom repo got a bit heated but the conclusion seems to be that it should not be fixed be fixed there… so does this belong with React Testing Library?
It appears to be fixed in dom-testing-library and subsequently react-testing-library but I’m still getting it in newer versions of RTL.
So my conclusion is: I don’t know where to go with this 😅
I am experiencing this as well. For now, I’ve added the following to my tests where this fails. It’s a noop patch for now.
Happy to dig into this @nickcolley if you’re super busy.
Also, here’s the full stack trace of this error:
It seems that this might be a jsdom issue though and not a jest-axe issue.