python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Mocking JavaScript Math.random with Jest doesn't work
Math.random() always giving random values instead of mocked ones.
index.test.js
jest.spyOn(global.Math, "random").mockReturnValue(0.123456789);
const html = fs.readFileSync(path.resolve(__d...
EugenSunic
Votes: 0
Answers: 1
Node.js Application, leveraging JSDOM and node-canvas, trying to drawImage from one canvas to another
I have a code snippet, where I'm leveraging two canvases...
One is generated in an emulated DOM, using JSDOM...
and the other is directly using NPM-Canvas
I am using heatmap.js to create an image in t...
Justin Young
Votes: 0
Answers: 1
Convert string read from a local mdx file to a window.document object
I have a next.js project using mdx-bundler'
Is there a way to convert string read from a local mdx file to a window.document object so I can use querySelector to query dom elements?
for example, I hav...
Joji
Votes: 0
Answers: 0
How to load script that uses `window` object in jsdom (jest)
I am a beginner to jest, not sure how do I test a script that's suppossed to be run in the dom, if possible I don't want to load the dom, just app.env.js
app.env.js
window.APP_ENV = Object.freeze({
...
LuisEnMarroquin
Votes: 0
Answers: 0