Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/vitest/src/integrations/env/jsdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,9 @@ function createCompatUtils(window: DOMWindow): CompatUtils {
return nodeFormData
},
makeCompatBlob(blob: Blob) {
const buffer = (blob as any)[implSymbol]._buffer
return new NodeBlob_([buffer], { type: blob.type })
const impl = (blob as any)[implSymbol]
// jsdom 28 renamed `_buffer` to `_bytes`
return new NodeBlob_([impl._bytes ?? impl._buffer], { type: blob.type })
},
}
return utils
Expand Down
7 changes: 7 additions & 0 deletions test/unit/test/environments/jsdom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ describe('FormData', () => {

expect(retrievedBlob).toBeInstanceOf(File)
})

test('keeps Blob bytes when used as a Request body', async () => {
const blob = new Blob(['hello world'], { type: 'text/plain' })
const request = new Request('http://localhost/', { method: 'POST', body: blob })

expect(await request.text()).toBe('hello world')
})
})

test('DOM APIs accept AbortController', () => {
Expand Down
Loading