Skip to content

browser: setInputFiles documentation and behavior mismatch #4655

Description

@lvogt

Brief summary

The documentation and typings for setInputFiles is wrong twice

k6 version

v0.57.0

OS

all

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Create any k6 script in Typescript with types provided by the @types/k6 package. The File interface from the k6/browser has two incorrect typings:

  • The mime type parameter is named in camel case (mimeType) but k6 actually expects all lowercase mimetype
  • The buffer parameter is typed as ArrayBuffer but string containing the base64 encoded data is expected

(The sample script in the documentation is actually correct btw)

Expected behaviour

The typings/documentation match and everything works.

Actual behaviour

You get either errors from the typescript compiler (due to mismatch ArrayBuffer vs string or mimeType vs mimetype) or issues during test execution (exceptions when the injected script tries to decode the ArrayBuffer with atob or missing mime type)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions