Category "jestjs"

React - Jest - Enzyme: How to mock ref properties

I'm writing test for a component with ref. I'd like to mock the ref element and change some properties but have no idea how to. Any suggestions? // MyComp.jsx

Typescript paths not resolving when running jest?

Attempting to convert this project over to jest using these instructions. I have everything working except for the files that use the paths configuration: "pa

How to mock interface with Jest without creating an instance

I know we can do it in Kotlin but I did not find it with Jest. I have complex interfaces and array of those interfaces and I do not want to specify all values o

How to view Jest snapshot in test

Is there a way to check the actual snapshot taken by Jest when running a snapshot test? So if I have a component with a fancy date thing that's supposed to show

Jest SecurityError: localStorage is not available for opaque origins

When I want to run my project with the command npm run test, I get the error below. What is causing this? FAIL ● Test suite failed to run SecurityError:

how to implement page navigation in react testing library (Link, a tag, history.push)

I am trying perform Dom testing at '/test' url page. my application use BrowseRouter from react-router-dom As following user approach, I want to manually chang

Jest gives an error: "SyntaxError: Unexpected token export"

I'm using Jest to test my React app. Recently, I added DeckGL to my app. My tests fail with this error: Test suite failed to run /my_project/node_modules/de

Jest beforeAll vs beforeEach unexpected behaviour

I have a quite simple test, basically I'm trying to mock i18next's t function: import { t } from 'i18next'; import { changeDocumentTitle } from './utils'; jest

Test process.env with Jest

I have an application that depends on environmental variables like: const APP_PORT = process.env.APP_PORT || 8080; And I would like to test that for example: A

What is jest's equivalent of `mocha -g` (grep option)?

Per the Mocha documentation, I can run a group of tests with a particular pattern in their describe/suite or it/test block using mocha -g. For example mocha -g

Babel throwing Support for the experimental syntax 'jsx' isn't currently enabled

I started newly writing unit test cases using Jest and Enzyme for the react application and when try to run test cases using jest like "test": "jest --watch" ra

Intercept navigation change with jest.js (or how to override and restore location.href)

Application code is calling location.href = "some-url". I want to write a test that verify the navigation redirect has happened. Using jest on jsdom, I tried t

TypeError: Cannot read properties of undefined (reading 'click'). fireEvent.click works but userEvent.click does not. Why?

Just started learning React testing with Jest, and am struggling with something simple. When I call userEvent.click(btn), the test fails saying that userEvent.c

Can Jest be used as browser based testing tool?

I understand that Jest is a unit testing tool for developers used for JavaScript. Is Jest a browser based testing tool similar to Selenium or a functional testi

How to mock S3 with jest?

I am tryng to code a test for upload. But i am not understating how to properly use jest.mock('aws-sdk') export class S3Service { private readonly s3: S3;

How can I modify the value of state in pinia in vue3 component test and affect the component?

Using vue-test-utils to test the component using pinia, I need to modify the value of the state stored in pinia, but I have tried many methods to no avail. The

How do I get text from input text box in selenium?

I need to insert with selenium to text box and then get it to another use. how can I do this? The function getText() doesn't work.

how to integrate jenkins with react jest testing results

My project is using reatJS, jest is used to do unit test and also to generate the coverage report. Now I need to use jenkins to automatically build the project

jest unit test mock google oauthClient in nestjs

I am currently doing unit test for the services in Nestjs using Jest, one of which is using the google Oauth service. My goal is to verify the token from google

Is there any way to mock private functions with Jest?

The ES6 module that I want to test looks as follows: function privateFunction() { ... } export function publicFunction() { ... does something ... priva