Possible to respond differently based on order of calls?
See original GitHub issueTrying to test retry logic of a method, so I’ve it wired up like this:
moxios.wait(() => {
const request = moxios.requests.at(0)
request.respondWith({
status: 401
, response: mockApiError
})
const nextRequest = moxios.requests.at(1)
nextRequest.respondWith({
status: 200
, response: mockApiResponse
})
})
const mockRequest = {
headers: {}
, method: 'get'
, url: 'to/no/where'
}
const response = await tryMakeRequest(mockRequest)
expect(response.status).toBe(200)
expect(response.data).toEqual(mockApiResponse)
The test fails with this error:
Timeout - Async callback was not invoked within timeout specified by
jasmine.DEFAULT_TIMEOUT_INTERVAL.
at node_modules/jest-jasmine2/build/queue_runner.js:64:21
at Timeout.callback [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:523:19)
at ontimeout (timers.js:469:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:264:5)
Any ideas what am I missing here?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Possible to stub method twice within a single test to return ...
"test should stub method differently on consecutive calls": function () { var callback = sinon.stub(); callback.onCall(0).returns(1); callback.
Read more >How to Answer Customer Service Calls: The Dos and Don'ts
How NOT to answer calls in a call center · Don't Interrupt your customer · Don't belittle the customer's issues · Don't give...
Read more >How To Answer the Phone Professionally (With Examples)
Try switching out phrases like "I don't know" for proactive alternatives like "Let me see if I can figure that out for you."...
Read more >Telephone Etiquette - LTS Knowledge Base
Listen actively and listen to others without interrupting. Don't make people dread having to answer their phone or call your department.
Read more >Stop Trying to Delight Your Customers
Twenty-four percent of the repeat calls in our study stemmed from emotional disconnects between customers and reps—situations in which, for instance, the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Couldn’t find a resolution for this. This is how I addressed this issue, if it helps the next poor soul:
In this example, the same route fails the first time, then succeeds for subsequent requests. This logic can be expanded to check anything from authentication flow to rate limit
For the time being, I’m using
axios-mock-adapter
and this works: