I created an API that serves an Apollo-Server with an Query. When I test it with your library it returns 404 Not Found and I can't access the Response Data json without invalid json error.
await testApiHandler({
requestPatcher: (req) => {
req.headers = {
...req.headers,
Origin: "localhost:3000",
Host: "localhost:3000",
};
},
handler: graphQlHandler,
test: async ({ fetch }) => {
const query = `query getYoutubeVideoMetadata($youtubeVideoId: String!) {
videoData: youtubeVideoMeadata(youtubeVideoId: $youtubeVideoId) {
id
title
thumbnails {
default {
url
}
}
}
}
`;
const res = await fetch({
method: "POST",
headers: {
Accept: " */*",
"Accept-Encoding":
"gzip deflate",
"Accept-Language":
"de,en-US;q=0.7,en;q=0.3",
"Content-Type":
"application/json",
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:85.0) Gecko/20100101 Firefox/85.0",
},
body: JSON.stringify({
operationName:
"getYoutubeVideoMetadata",
query,
variables: {
youtubeVideoId: exampleYoutubeVideoId,
},
}),
});
console.log(await res.json());
},
});