nise
nise copied to clipboard
cache request parameter is not stored?
The following is a request parameter that we are using: https://developer.mozilla.org/en-US/docs/Web/API/Request/cache But I'm unable to see it in the tests, here's my simple test:
test('should be provided to fetch API in getJSON function', async () => {
server.respondWith(request => {
request.respond(200, {'Content-Type': 'application/json'}, '{"foo": "bar"}');
});
// this basically does a fetch request with cache as one of the options
const promise = getJSON({url: 'http://example.com/test-params.json', cache: 'force-cache', headers: {'Authorization': 'Bearer 123'}}, new AbortController());
server.respond();
await promise;
expect(server.requests.length).toBe(1);
expect(server.requests[0].url).toBe('http://example.com/test-params.json');
expect(server.requests[0].method).toBe('GET');
console.log(server.requests[0]["cache"]);
expect(server.requests[0]["cache"]).toBe('force-cache'); // I can't find cache in the request object...?
expect(server.requests[0].requestHeaders["Authorization"]).toBe('Bearer 123');
});
Any help would be appreciated :-)