Skip to content

Commit b67788c

Browse files
authored
fix(browser): fix upload File instance (#9294)
1 parent b70c961 commit b67788c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/browser/src/client/tester/locators/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ export abstract class Locator {
117117
return {
118118
name: file.name,
119119
mimeType: file.type,
120-
base64: bas64String,
120+
// strip prefix `data:[<media-type>][;base64],`
121+
base64: bas64String.slice(bas64String.indexOf(',') + 1),
121122
}
122123
})
123124
return this.triggerCommand<void>('__vitest_upload', this.selector, await Promise.all(filesPromise), options)

test/browser/test/userEvent.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ describe('uploading files', async () => {
895895
const uploadedFile = input.files[0]
896896
expect(uploadedFile.name).toBe('hello.png')
897897
expect(uploadedFile.type).toBe('image/png')
898+
expect(await uploadedFile.text()).toBe('hello')
898899
})
899900

900901
test.skipIf(server.provider === 'webdriverio')('can upload several instances of File', async () => {

0 commit comments

Comments
 (0)