I am using https://github.com/ctimmerm/axios-mock-adapter
I would like to know how I can verify that the endpoint was actually caused by the system under test.
In this example:
var axios = require('axios'); var MockAdapter = require('axios-mock-adapter'); // This sets the mock adapter on the default instance var mock = new MockAdapter(axios); // Mock any GET request to /users // arguments for reply are (status, data, headers) mock.onGet('/users').reply(200, { users: [ { id: 1, name: 'John Smith' } ] });
How can I find out if the "/ users" call is called?
I am looking for something similar to what you can do in Jest:
expect(mockFunc).toHaveBeenCalledTimes(1)
I understand that I can use some user logic when using the function to respond and set a local variable indicating whether the request was completed. I'm just wondering if there is a cleaner way to do this.
acios-mock-adapter, , , jest, jest.spyOn.
let spy = jest.spyOn(axios, "get"); //run http request here expect(spy).toHaveBeenCalled();
: , , , , setTimeout (function, 0),
Source: https://habr.com/ru/post/1690441/More articles:isDevMode / enableProdMode error: Unable to enable prod mode after configuring the platform - angularConvert Pandas DataFrame to multidimensional ndarray - pythonКак получить имя детской диаграммы с помощью Helm? - kubernetesMulti-caliber computation in a bigint array - bigintKeras: does save_model save all optimizer weights? - kerasclr.Dll! MetaDataGetDispenser and higher than expected CPU usage - c #How to refer to the value defined in the template in the subgraph in the steering wheel for the cockernets? - kubernetesSubordinate slave support with Redis Sentinel? - rediswhat '???' in Scala? - scalaWhy are types executed in `(fmap. Fmap) sum Just [1, 2, 3]`? - haskellAll Articles