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.5

Asserting OpenAPI Specifications

In This Lesson

We'll learn how to validate AdonisJS API responses against an OpenAPI Specification, like those generated by Swagger APIs, using Japa's OpenAPI Assertions plugin.

Created by
@tomgobich
Published

If you're making an API and using something that generates an OpenAPI Specification for you, like Swagger, then Japa has a nifty plugin for you, called OpenAPI Assertions.

npm i -D @japa/openapi-assertions

For this, we won't want to use Japa's API client to send the request; instead, we'll want to use axios, superagent, superset, request, or light-my-request. These are the responses supported by the @japa/openapi-assertions plugin. I'll go ahead and use axios here, and I'll install it as a normal dependency since I might not explicitly use it for testing.

Join the Discussion 0 comments

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

Be the first to comment!