Skip to content

userEvent.type() breaks with a number #215

@wesbos

Description

@wesbos

Not sure if this is a bug, or as intended, so feel free to close :)

I I just tried to do this:

await userEvent.type(screen.getByPlaceholderText('Price'), item.price);

Where price is a number. That throws the error TypeError: text.slice is not a function

running with toString() fixes that:

await userEvent.type(screen.getByPlaceholderText('Price'), item.price.toString());

Since the browser would coerce to a string if we were setting a value, should this too? Or should I just always coerce it myself?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions