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 #2.4

Data-Driven Tests with Datasets

In This Lesson

Learn to write DRY tests using Japa's datasets! Define an array or callback function of data (primitives or objects) to run a single test multiple times, enabling TypeScript inference, and using interpolation in the test name for context.

Created by
@tomgobich
Published

Notes Used to Craft this Lesson

DRY stands for Don't Repeat Yourself and in testing, it is easy to accidentally repeat yourself if you need to test the same thing using different inputs or outputs.

That's where the magic of datasets in Japa comes in to help. We can easily use them to define an array of data to run a single test with, so that we don't have to copy/paste that test over and over again, keeping them nice and DRY.

Join the Discussion 0 comments

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

Be the first to comment!