All Questions
18 questions
2
votes
1
answer
312
views
Wrong count execution times of Sinon Spy
I have a major function that call 3 other functions. I want to test if those 3 function were called.
myController.ts
import axios from 'axios';
export async function functionOne() {
console.log('...
1
vote
0
answers
222
views
How to do integration test with chai for internal and nock for external api call
I have an app for Slack Interactivity Handling, what I'd like to do is just to receive webhook from the slack button and update the message via Slack API.
I use express on my server, and core https ...
0
votes
1
answer
3k
views
Nock is not intercepting request if it runs multiples test in certain order
I'm creating some unit test for my endpoint. This endpoint will fetch data from an external API and send diff responses depending on finding a certain item on that data fetched or if there is an ...
1
vote
1
answer
2k
views
Nock is not working with multiple test cases with same method
If I comment the first test case then second test works fine. If I run this test file. It gives 400 status which is the the status of first test case. How I can run the both test cases.
I also added ...
1
vote
0
answers
329
views
Nock, Async/Await, Bitbucket: Intercept does not return before Chai begins assertion
I have an endpoint that makes an external API call.
//outside.js
const createTicket = async () => {
try{
const someOptions = { /*stuff here*/}
results = await rp.post('https://...
0
votes
0
answers
288
views
Intercepting an external API calls in nodejs
js), I want to test it normally using mocha and chai, but the API is having dependency with external service which I want to mock. Is it possible to mock that internal calls
follow the below eg to ...
2
votes
1
answer
998
views
Nock does not returns the setted headers
I'm using Nock to intercept a http request.
test.js:
const nock = require('nock');
const server = require('../server');
const request = require('request');
describe('My test', () =>{
it('...
1
vote
1
answer
248
views
Invalid Chai property: setEncoding on nock
I was using nock 9.1.6 to mock nylas API with chai 3.5.0. It was working perfectly with the code:
it('fails when no state is given and provider fails', () => {
const user = fixture.elements....
1
vote
0
answers
250
views
All sinon stubs fail after nock intercept
Im running unit tests against a software application. Within the specific part of the application I have some async functions, followed by an http request, followed by more async functions. I am ...
1
vote
1
answer
661
views
Testing async code in catch block using Nock or httpMock
I making a axios request which fails and throws error in catch block.
In catch block I am making request to other end point to get results
router.get('/info', (req, res) => {
axios('www....
0
votes
1
answer
426
views
How to mock a line in unit test using Nock, Node js
I'm trying to inject one line in unit test i got failed, it seems that it hits a real request, the following code is part of football api and i need to mock the last line in this file
module.exports....
0
votes
1
answer
540
views
nock for axios mockup on 400 does not return the defined value
I am using nock to mock my ajax call with axios.
Here is my code:
describe("unSuccessful rest call",()=>{
it('should dispatch types: SET_DROP_DOWN_CHECK_STATUS in order ', () => {
...
1
vote
0
answers
225
views
mocha + chai : nock returns "302 Found" for any http urls
I am trying to mock a remote service using chai-http and nock. If I provide the host url with "http://" I am getting "302 Found", full response is as follows:
error: StatusCodeError: 302 - "\r\...
1
vote
1
answer
1k
views
nock: reply is not a function
I am using nock to intercept my http requests in a mocha / chai environment. Also i am using supertest and supertest-chai to query my own express server. Like this:
import { it } from 'mocha';
import ...
10
votes
2
answers
2k
views
how to test react-saga axios post
I am learning how to test and using some examples as a guideline I am trying to mock a login post. The example used fetch for the http call but I using axios. This is the error I am getting
Timeout ...
1
vote
0
answers
392
views
How to use nockback with promises?
I am trying to use nockBack to automate my fixtures recording/playback with code that uses promises and chai-as-promised.
But I can't figure out how to make the async nockBack work with it.
context('...
0
votes
1
answer
2k
views
Nock - Bodies don't match
Why does Nock give me an error saying that bodies don't match??
here is my code.
it('Should Delete /user/removeuserskills', function(done){
mockRequest
.delete('/user/removeuserskills',{...
1
vote
1
answer
2k
views
Mocking with Nock, DELETE
How would I mock a delete with nock
this is what I have done so far:
var nock = require('nock');
var request = require('supertest')("http://localhost:8080");
var expect = require('chai').expect;
...