jsdom Questions
6
Solved
I'm building a React app, with create-react-app.
I got the following error when running ESLint:
8:3 error 'document' is not defined no-undef.
My app runs without error, but I got this ESLint erro...
4
Solved
I'm testing a couple of components that reach outside of their DOM structure when mounting and unmounting to provide specific interaction capability that wouldn't be possible otherwise.
I'm using ...
6
I'm trying to upgrade my project to React 18, everything works in dev and production mode in the browser. But after upgrading to the latest version of @testing-library/react some of my unit tests a...
Villous asked 25/4, 2022 at 17:24
1
I'm in a Vite/React/TypeScript application and I'm configuring my first test with Vitest.
When I run my Button test (yarn vitest), I get this error:
packages/frontend/src/components/Generic/Button/...
Cushman asked 17/2, 2023 at 9:26
2
I fail to get the computed style value of color with jsdom:
require("jsdom").env({
html: '<html><head><style> html { color: red; } </style></head><body></bo...
Rostand asked 24/4, 2015 at 13:40
3
Solved
I'm trying to migrate from AVA to Jest. In AVA you can set ava.setup, in which you set the jsdom environment. For example, creating the DOM structure and doing necessary polyfills (localStorage).
H...
Hirza asked 5/12, 2016 at 9:17
1
Solved
I'd like to do some integration testing of my svelte + page.js-based router using vitest, but I'm running into an issue where the jsdom instance only updates correctly once per test file.
In the fo...
Expiate asked 27/11, 2022 at 11:33
9
Solved
I am writing tests using Jest for components that use canvas elements. I keep getting an error when I run my tests that looks like this.
Error: Not implemented: HTMLCanvasElement.prototype.getCont...
Purebred asked 16/2, 2018 at 14:20
6
I found a few reference to people having a similar issue where the answer always was, make sure you call window.close() when done. However that does not seem to be working for me (node 0.8.14 and j...
Snaggletooth asked 15/12, 2012 at 14:43
2
Can anyone help me with testing of following function
function onload(cb){
const image = 'http://placehold.it/350x150'
const img = new Image()
img.src = image
img.onload = () => {
cb()
}
...
Indonesia asked 9/10, 2016 at 9:39
14
Solved
In my Jest unit test I am rendering a component with a ColorPicker. The ColorPicker component creates a canvas object and 2d context but returns 'undefined' which throws an error "Cannot set proper...
Para asked 21/10, 2015 at 20:57
2
Try to use jsdom with Jest in an NX repo (typescript/angular) and I get the problem that TextEncoder and TextDecoder are not present. I get the same result whether I set the jest testEnvironment to...
10
Solved
I'm trying to write tests for my web components projects in jest. I already use babel with es2015 preset. I'm facing an issue while loading the js file. I have followed a piece of code where docume...
Hedgerow asked 12/12, 2016 at 9:47
2
Solved
There are similar questions with this same error message, but every one I found is a runtime error. For me, globalThis does exist at runtime, but ESLint reports that it does not. How do I tell ESLi...
Infecund asked 7/12, 2023 at 1:29
3
I have a config and constants folder in my project. Located in src\config\test.ts & src\constants\index.js respectively.
I've setup Jest to use moduleNameMapper as below so I can just do impor...
2
Solved
I can parse XML like this:
import JSDOM from "jsdom";
const myXml = "... some xml loaded from somewhere ...";
const dom = new JSDOM.JSDOM(myXml);
I was really surprised when I googled "jsdom sav...
Culliton asked 9/1, 2020 at 17:7
2
Node JS application giving a websocket error in a JEST, Puppeteer test. Chromium opens for a second and then closes instantly. I am not using websocket in my test so not sure why the attached error...
4
I am trying to run a test on a component at a certain viewport width. I am doing the following, but this doesn't seem to change it:
test('Component should do something at a certain viewport width.'...
Carbuncle asked 14/9, 2017 at 14:2
1
I have an issue where a 3rd-party library is using some valid CSS parser features that are not available in JSDOM, and I'd just like to suppress those kinds of errors. But given that I'm using JSDO...
Quatrefoil asked 3/10, 2018 at 16:27
4
Solved
When testing a function that uses either the TextEncoder or the TextDecoder I get:
ReferenceError: TextEncoder is not defined
ReferenceError: TextDecoder is not defined
I am using jsdom, so why is...
Astereognosis asked 21/7, 2021 at 10:50
2
Solved
I am currently working on a project that requires me to have computed styles send to the browser via JSDOM. I am currently looking for a way to inject some basic CSS into JSDOM so that it could com...
3
Solved
I'm using react with ViteJS and Vitest for testing. I have set up the config for vitest and the test setup file too as you can see in the screenshots below.
vite.config.js
src/test/setup.ts
src/a...
Rhona asked 31/12, 2022 at 14:57
2
I npm installed jQuery and am now seeing a bunch of Module not found: Error: Can't resolve... errors. Any idea of what the root issue could be and a resolution?
ERROR in ./node_modules/jquery/...
9
Solved
I try to convert an existing project to use Typescript and I have problems doing so with my testing setup.
I had a setup file for my tests that sets up jsdom so that all my DOM interacting code wo...
Myers asked 22/11, 2016 at 13:29
6
Solved
I want to write a jest unit test for a module that uses requestAnimationFrame and cancelAnimationFrame.
I tried overriding window.requestAnimationFrame with my own mock (as suggested in this answer...
Orcein asked 4/5, 2020 at 13:47
1 Next >
© 2022 - 2025 — McMap. All rights reserved.