taiko
taiko copied to clipboard
Empty body for intercept not possible
Describe the bug
If not setting the body for an intercept, the intercept fails when called.
There are responses without bodies, e.g. 204 No Content, so this behaviour has to be an expected one.
Same applies if the body actively is set to undefined
or null
To Reproduce
const { openBrowser, intercept, goto } = require('taiko');
(async () => {
await openBrowser();
await intercept('https://example.com', {status: 204});
await goto('https://example.com');
})()
Error message
Uncaught The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
Expected behavior Intercept works.
Additional context
- This bug is caused by
Buffer.from(responseBodyJson)
inlib/handlers/fetchHandler.js
(undefined is passed to Buffer.from)
@RobertBeilich would you like to send a pull request with a fix? I see that you've identified what's causing the issue.
@RobertBeilich would you like to send a pull request with a fix? I see that you've identified what's causing the issue.
Yes, I'm going to tackle it.
I'm asking to reopen this issue. The merged solution is not only not sufficient, it rather is arguably even more erroneous, as it now adds an empty body to all requests, instead of omitting it where necessary.
I'm still investigating how to properly handle null
, as the chrome fetch api is not handling it. Probably the right solution is to process it as JSON.stringify
would do it and convert it to the string 'null'
, but I'll need to have a deeper look into it.
@RobertBeilich Just circling back to see if you are still on this? No worries if you aren't this can be assigned to someone.
@RobertBeilich Just circling back to see if you are still on this? No worries if you aren't this can be assigned to someone.
Ah, sry, totally forgot about that one. Will have a look at the current state of my implementation and how it fits in current master.