All Questions
6 questions
1
vote
0
answers
169
views
How to mock 3rd party API calls in next.js integration tests?
I am calling OpenAI APIs from my next routes, I can intercept browser requests using nock library like below, but it won't mock server-side API calls since I am not calling OpenAI API from the browser ...
2
votes
1
answer
248
views
Nock JS mocking tool produces error `Right-hand side of 'instanceof' is not an object`
I am trying to use this tool called Nock JS
https://www.npmjs.com/package/nock
with a Next JS, React demo app tested using Cypress
• Next JS 13.4
• Cypress 12.17.1
• React 18.2
e2e/homepage.cy.js
...
1
vote
1
answer
1k
views
Nock not mocking requests on Nextjs and Cypress
In some pages, we use getInitialProps that makes a request on the backend side to call an external endpoint. On the CI/CD machine we can´t call this other endpoint so we want to mock that endpoint. Im ...
3
votes
1
answer
1k
views
How to implement Code Coverage in a cypress environment where NextJS is build while running the tests?
We would like to add code coverage to a setup where we use cypress and nextjs. In our cypress config we build nextJs using next() to mock the backend requests inside nextjs.
The cypress.config.ts ...
0
votes
0
answers
830
views
Why these mocks are not resetting?
I am making app with Nextjs and Jest and React Testing Library for testing. I use nock for mock axios responses.
My tests:
axios.defaults.adapter = require('axios/lib/adapters/http');
describe('...
2
votes
1
answer
14k
views
Jest and HTTP mocking with nock
I was trying to write my first ever Jest test for an endpoint in my Next.js App and this test always passes, no matter, how I try to 'break' it. Which makes me think, I did all wrong. Here is my api/...