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

Support checking for arbitrary options on .calls #430

Closed
nynkelys opened this issue May 28, 2019 · 0 comments · Fixed by #431
Closed

Support checking for arbitrary options on .calls #430

nynkelys opened this issue May 28, 2019 · 0 comments · Fixed by #431

Comments

@nynkelys
Copy link
Contributor

@nynkelys nynkelys commented May 28, 2019

I'm working on a Cloudflare Worker script that uses arbitrary options on a fetch call (as specified here).

However, I'm unable to test if those options are set correctly because fetch-mock removes them from the options list (as seen here).

Example:

function doFetchSomething(url) {
   fetch(url, { cf: { ttl: 30 } })
}

test('should add cf options', () => {
   const fetchMock = require('fetch-mock');
   const url = 'http://some.test.url.io';

   fetchMock.get(url, {});

   doFetchSomething(url);

   expect(fetchMock.calls(filter)[0][1]).toEqual({"cf": {"ttl": 30}, "headers": { "method": "GET"});
});

// Expected: {"cf": {"ttl": 30}, "headers": { "method": "GET"}
// Received: {"headers": { "method": "GET"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.