File tree Expand file tree Collapse file tree
packages/vitest/src/integrations/env
test/unit/test/environments Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -321,8 +321,9 @@ function createCompatUtils(window: DOMWindow): CompatUtils {
321321 return nodeFormData
322322 } ,
323323 makeCompatBlob ( blob : Blob ) {
324- const buffer = ( blob as any ) [ implSymbol ] . _buffer
325- return new NodeBlob_ ( [ buffer ] , { type : blob . type } )
324+ const impl = ( blob as any ) [ implSymbol ]
325+ // jsdom 28 renamed `_buffer` to `_bytes`
326+ return new NodeBlob_ ( [ impl . _bytes ?? impl . _buffer ] , { type : blob . type } )
326327 } ,
327328 }
328329 return utils
Original file line number Diff line number Diff line change @@ -182,6 +182,13 @@ describe('FormData', () => {
182182
183183 expect ( retrievedBlob ) . toBeInstanceOf ( File )
184184 } )
185+
186+ test ( 'keeps Blob bytes when used as a Request body' , async ( ) => {
187+ const blob = new Blob ( [ 'hello world' ] , { type : 'text/plain' } )
188+ const request = new Request ( 'http://localhost/' , { method : 'POST' , body : blob } )
189+
190+ expect ( await request . text ( ) ) . toBe ( 'hello world' )
191+ } )
185192} )
186193
187194test ( 'DOM APIs accept AbortController' , ( ) => {
You can’t perform that action at this time.
0 commit comments