Skip to content
Advertisement

Tag: jestjs

React Testing with history passed

Problem Statement I’m using create react app with Jest. In my test, I simply want to render out a component that needs history passed to the state before it can load. I’ve been researching and trying to get to this to work for awhile. The source I’ve been using shows how to pass the history to the router – https://testing-library.com/docs/example-react-router/

jest is failing to find `bota` and `atob`

Creating a jest test like: fails with however, node does define btoa as of node 16, and so the following: correctly outputs YWFh. How can I configure jest to get this test to pass? Clearly something is happening in the jest test runner to not execute in the current node environment, or otherwise is stripping specific built-ins, only I can’t

Angular v13 Jest with nx test – SyntaxError: Cannot use import statement outside a module at Runtime.createScriptFromCode

I tried to follow every comment with a possible solution here to the letter. I relied on an example project on github as well which works perfectly. This also started to happen to me after updating everything manually and when running the nx test command, occurrs this error. My jest.config.js inside apps/my-app: jest.config.js in the project root: jest.preset.js in the

MUI5 not working with jest – SyntaxError: Cannot use import statement outside a module

Reproducible repo: https://github.com/hutber/cannotusestatement What is more worrying is: https://codesandbox.io/s/vigilant-bartik-bmz8x in the sandbox the tests pass. However if you checkout the above repo, which was imported into this sandbox it will not pass locally. I have no doubt that the issue is my jest does not compile the node_modules that would be needed for running my tests. But I am at

Unable to run JEST test

I’m facing an issue when I try to import something using require() function in jest test file. script2.test.js Package.json babel.config.cjs I’m getting following errors when I run the test using npm test I’m new to JEST, any help is much appreciated. My Node version is 14.17.3 Thanks you. Answer It seems that one still needs to jump through the hoops

Jest coverage tools fail

During in my react-native project, during test execution, Jest shows coverage and creates coverage reports. Jest config: During testing I get errors: in files which are generated during creation of coverage folder: So, in jest documentation we see that we can specify jsdom environment in file which produces error like: Ok, but here we have auto-generated files, not my test-files.

Puppeteer not picking up dialog box

I’m trying to test for an alert box in Puppeteer: However, it doesn’t seem to return the message inside the alert box (even though I’ve confirmed it works doing it manually). Any ideas why page.on(‘dialog’, async dialog => { isn’t being entered? Answer I’m not sure what’s going on with your page — it looks like you’re testing XSS, but

Advertisement