Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache request parameter is not stored? #214

Open
HarelM opened this issue Oct 27, 2023 · 2 comments
Open

cache request parameter is not stored? #214

HarelM opened this issue Oct 27, 2023 · 2 comments

Comments

@HarelM
Copy link
Contributor

HarelM commented Oct 27, 2023

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 :-)

Copy link

stale bot commented Dec 27, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 27, 2023
@HarelM
Copy link
Contributor Author

HarelM commented Dec 27, 2023

Still relevant...

@stale stale bot removed the stale label Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant