Skip to content

Commit

Permalink
fix(wpt): broken test (nodejs#1683)
Browse files Browse the repository at this point in the history
* fix(wpt): broken test

* fix: failing node-fetch tests

* fix: more failing tests
  • Loading branch information
KhafraDev authored and metcoder95 committed Dec 26, 2022
1 parent cb6853a commit c4166f8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
6 changes: 1 addition & 5 deletions lib/fetch/request.js
Expand Up @@ -949,11 +949,7 @@ webidl.converters.RequestInit = webidl.dictionaryConverter([
{
key: 'duplex',
converter: webidl.converters.DOMString,
allowedValues: ['half'],
// TODO(@KhafraDev): this behavior is incorrect, but
// without it, a WPT throws with an uncaught exception,
// causing the entire WPT runner to crash.
defaultValue: 'half'
allowedValues: ['half']
}
])

Expand Down
6 changes: 4 additions & 2 deletions test/fetch/client-fetch.js
Expand Up @@ -111,7 +111,8 @@ test('pre aborted with readable request body', (t) => {
async cancel (reason) {
t.equal(reason.name, 'AbortError')
}
})
}),
duplex: 'half'
}).catch(err => {
t.equal(err.name, 'AbortError')
})
Expand Down Expand Up @@ -141,7 +142,8 @@ test('pre aborted with closed readable request body', (t) => {
fetch(`http://localhost:${server.address().port}`, {
signal: ac.signal,
method: 'POST',
body
body,
duplex: 'half'
}).catch(err => {
t.equal(err.name, 'AbortError')
})
Expand Down
3 changes: 2 additions & 1 deletion test/node-fetch/main.js
Expand Up @@ -1135,7 +1135,8 @@ describe('node-fetch', () => {
const url = `${base}inspect`
const options = {
method: 'POST',
body: stream.Readable.from('a=1')
body: stream.Readable.from('a=1'),
duplex: 'half'
}
return fetch(url, options).then(res => {
return res.json()
Expand Down
3 changes: 2 additions & 1 deletion test/node-fetch/request.js
Expand Up @@ -207,7 +207,8 @@ describe('Request', () => {
follow: 3,
compress: false,
agent,
signal
signal,
duplex: 'half'
})
const cl = request.clone()
expect(cl.url).to.equal(url)
Expand Down
5 changes: 0 additions & 5 deletions test/wpt/status/fetch.status.json
@@ -1,9 +1,4 @@
{
"request-init-stream.any.js": {
"fail": [
"It is error to omit .duplex when the body is a ReadableStream."
]
},
"general.any.js": {
"fail": [
"Stream errors once aborted. Underlying connection closed.",
Expand Down
1 change: 1 addition & 0 deletions test/wpt/tests/fetch/api/abort/general.any.js
Expand Up @@ -490,6 +490,7 @@ promise_test(async t => {
const fetchPromise = fetch('../resources/empty.txt', {
body, signal,
method: 'POST',
duplex: 'half',
headers: {
'Content-Type': 'text/plain'
}
Expand Down

0 comments on commit c4166f8

Please sign in to comment.