Uploading a File

Learn how to simulate a user selecting a file in an input element.

Starter project

The starter project contains an AttachmentForm component, which allows the user to choose and upload a file.

A copy of the project is in the code widget below. Clicking the “Run” button will run the app and display the attachment form.

export default "test-file-stub";
Uploading a file

Run the app.

Select a file and click the “Upload” button. We should see that a success message appears containing the chosen file name:

The project contains a half-implemented test that checks whether a success message appears when an attachment has been selected and uploaded.

Another copy of the project is in the code widget below. ...

Access this course and 1400+ top-rated courses and projects.