Questions tagged [jestjs]

Jest is a JavaScript unit testing framework made by Facebook that's based on Jasmine and provides automated mock creation, and a jsdom environment. It's often used for testing React components.

Filter by
Sorted by
Tagged with
0
votes
0answers
27 views

How can I mock location.pathname in reactjs

I tried all the possibilities to mock location.pathname This is my code if(typeof location !== undefined) { this.setParentPath(location.pathname); } This is one of the possibility I used to cover ...
0
votes
1answer
10 views

Testing nodejs gRPC client functions

I have a task to test gRPC client call functions with Jest. Here is what a whole thing looks like: We import a package from proto file: const packageDef = protoLoader.loadSync(PROTO_PATH,{ ...
1
vote
1answer
71 views

Typescript function not waiting for the waitForExist() and printing the next line

I'm using webdriverIO with typescript and jest to automate react application. I have a simple test to check how long it takes for a particular element to display on the screen. There's a process ...
1
vote
1answer
164 views

How to wait till next page opens after a button click in Jest + TypeScript?

I want to pass or fail the tests of "Login" function based on fields available on the second page. I used "xpath" to capture the fields. But it does not capture the fields of the second page. I ...
5
votes
1answer
3k views

Is there a way to run a subset of tests using Jest?

I would like to be able to run a subset of it's or describe's in a Jasmine test file using jest with some type of tagging system. I know I can indicate a filter of sorts by using a word after the ...
2
votes
1answer
5k views

Wait for element change not present (WebDriver/JavaScript/Jest)

Yesterday I struggled with waiting for a loading indicator to be removed. Added this question and answer here because we spend a lot of time on it and Google didn't help much. Hopefully this will help ...
2
votes
1answer
3k views

Rerun failed (flaky) tests with Jest

We are using Jest as our test runner for our JavaScript (React and Selenium) tests. We have one or two flaky tests (as TeamCity marks them flaky and we process them as technical-debt), although we ...