Ready to get started?

Join Adocasts Plus for $8/mo, or sign into an existing Adocasts Plus account, to get access to all of our lessons.

robot mascot smiling

Pragmatic Testing in AdonisJS with Japa #4.6

Testing File Uploads

In This Lesson

We'll learn how to test AdonisJS file uploads using Drive Fakes and the Japa API Client. We'll generate fake files for testing, use a multipart request, assert successes, test validation failures, and impress the importance of cleanup.

Created by
@tomgobich
Published

Notes Used to Craft this Lesson

The native file upload option for AdonisJS is to use Drive; outside of AdonisJS, this package is called Flydrive. Like Japa can be used outside of AdonisJS projects, Flydrive is the same. Also, similar to mail and the other first-party AdonisJS packages, Drive comes with fakes and helpful assertions when it comes to testing.

The project we're working on already has Drive installed and configured, and our PostsController contains a simple uploadThumbnail method which we'll be testing here today.

Join the Discussion 0 comments

Create a free account to join in on the discussion
robot comment bubble

Be the first to comment!