All Questions
7 questions
0
votes
0
answers
39
views
How to use localStorage with jest nextjs
I am testing my nextjs web app with react testing library jest.
I am using localstorage to store the jwt for logged in users.
And in my app i am using useEffect to fetch the content from the server on ...
1
vote
1
answer
1k
views
React Testing Library with Next.Js, unit test failing because of state?
I'm trying to create a unit test using react testing library + jest in my nextjs app, it's a simples test, once a click on the button without fill the fields, it should show a error message "...
-1
votes
1
answer
362
views
How to write effective tests for a project with i18n support?
I am coding on a Next.js project for a while. My project has i18n support and I want to write unit tests. But I couldn't figure out how to write effective tests. Am I supposed to write unit tests for ...
3
votes
0
answers
382
views
not able to mock router.push react-testing - **expect(jest.fn()).toHaveBeenCalledWith(...expected)**
Here I am trying to mock router.push but it doesn't seem to work, I tried different approach
and still facing the same issue
here's the code of my component
const onProceed = () => {
...
0
votes
0
answers
469
views
How to test methods in functional component for nextjs components
Component:
const Demo = () => {
const handler = () => {
// some logic written
};
return (
<div>
<button data-testid={'handler_id'} onClick={() => handler()}>
...
0
votes
1
answer
2k
views
How to spy on a mock function next.js jest RTL
I am trying to mock replace function which is in useRouter() hook from next/router
my mocks and tests looks like this:
jest.mock("next/router", () => ({
useRouter() {
return {
...
6
votes
1
answer
5k
views
Testing Api with Next.Js in Jest
I wanted to write test cases for my Api file using Jest. That uses Next.js. I tried many things but was not able to get any coverage of file.
ApiFile.js
const axios = require('axios');
import ...