Assertions package for Japa. Built on top of Chai.Assert

Overview

@japa/assert

Assertion library built on top of Chai.assert

github-actions-image npm-image license-image typescript-image

An assertion library built on top of Chai.assert with small tweaks and additional features like assertion planning.

Complete API documentation

Installation

Install the package from the npm registry as follows:

npm i @japa/assert

yarn add @japa/assert

Usage

You can use the assertion package with the @japa/runner as follows.

import { assert } from '@japa/assert'
import { configure } from '@japa/runner'

configure({
  plugins: [assert()]
})

Once done, you will be able to access the assert property on the test context.

test('test title', ({ assert }) => {
  assert.deepEqual({ id: 1 }, { id: 1})
})

Register open API schemas

You can register open API schema and then assert HTTP responses against.

configure({
  plugins: [assert({
    openApi: {
      schemas: [join(__dirname, '..', 'api-spec.json')]
    }
  })]
})

Validate response as follows.

test('get users', ({ assert }) => {
  const response = await supertest(baseUrl).get('/users')
  assert.isValidateApiResponse(response)
})
You might also like...

A messaging app built on top of Solana blockchain where you can store and view your messages.

Message App on Solana 💬 This Message application written Rust using Anchor ⚓ Setting up the Environment: Rust Installation curl --proto '=https' --tl

Oct 2, 2022

A fast and optimized middleware server with an absurdly small amount of code (300 lines) built on top of Deno's native HTTP APIs

A fast and optimized middleware server with an absurdly small amount of code (300 lines) built on top of Deno's native HTTP APIs with no dependencies. It also has a collection of useful middlewares: log file, serve static, CORS, session, rate limit, token, body parsers, redirect, proxy and handle upload. In "README" there are examples of all the resources. Faster's ideology is: all you need is an optimized middleware manager, all other functionality is middleware.

Dec 28, 2022

📬 Lightweight Typescript-first framework built on top of Express

🔖 abstain Lightweight Typescript-first framework built on top of Express [WIP] 📚 api // index.ts import { Application } from '@pinkcig/abstain'; imp

May 26, 2022

Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's `move-ts`.

Movehat Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's move-ts. Movehat aspires to b

Sep 30, 2022

Interplanetary Database: A Database built on top of IPFS and made immutable using Ethereum blockchain.

IPDB IPDB (Interplanetary Database) is a key/value store database built on top of IPFS (Interplanetary File System). Project is intended to be an MVP

Oct 6, 2022

GPU supercharged attraction-graph visualizations built on top of Three.js

Force Directed Graph GPU supercharged attraction-graph visualizations for the web built on top of Three.js. Importable as an ES6 module. Simulation co

Dec 9, 2022

Its a Advanced Content Management System built on top of Frappe.

Its a Advanced Content Management System built on top of Frappe.

Go1 CMS Go1 CMS - Its a Advanced Content Management System built on top of Frappe with Advanced Page builder. Lead your business towards the future of

Dec 29, 2022

This package is for developers to be able to easily integrate bad word checking into their projects.\r This package can return bad words in array or regular expression (regex) form.

Vietnamese Bad Words This package is for developers to be able to easily integrate bad word checking into their projects. This package can return bad

Nov 3, 2022

Multi-platform node package bundle to a package.json.

dmpc Multi-platform node package bundle to a package.json. install ### npm mode npm i -g @kingsword/dmpc ### yarn mode yarn global add @kingsword/dmp

Oct 16, 2022
Releases(v1.3.6)
  • v1.3.6(Sep 8, 2022)

    • chore: update package-lock file 03f99e6
    • docs(README): fix link to assert plugin docs 62d4faa
    • chore: remove github health files in favor of central .github repo 3fb9276
    • chore: update dependencies 02ecbc8

    https://github.com/japa/assert/compare/v1.3.5...v1.3.6

    Source code(tar.gz)
    Source code(zip)
  • v1.3.5(Sep 3, 2022)

    • chore: add peer dependency on @japa/runner 1799bd9
    • chore: update dependencies 1e082a1
    • docs(README): fix incorrect method name in example 5d8436f

    Full Changelog: https://github.com/japa/assert/compare/v1.3.4...v1.3.5

    Source code(tar.gz)
    Source code(zip)
  • v1.3.4(Apr 8, 2022)

  • v1.3.3(Apr 2, 2022)

  • v1.3.2(Mar 23, 2022)

  • v1.3.1(Mar 23, 2022)

  • v1.3.0(Mar 18, 2022)

    After this release, you will be able to register the open API schemas and assert API responses against it. Here's a small example.

    const config = {
      openApi: {
        schemas: [join(__dirname, '..', 'api-spec.json')],
      },
    }
    
    configure({
      plugins: [assert(config)],
    })
    

    Validate response as follows.

    test('get users', ({ assert }) => {
      const response = await supertest(baseUrl).get('/users')
      assert.isValidateApiResponse(response)
    })
    

    Commits

    • docs(README): add open API assertion example 46ef0e2
    • feat: add support for validating responses against api schema ed7b71f
    • feat: automatically augment TestContext 1c402fd
    • chore: update dependencies 8b71324

    https://github.com/japa/assert/compare/v1.2.4...v1.3.0

    Source code(tar.gz)
    Source code(zip)
  • v1.2.4(Mar 5, 2022)

  • v1.2.3(Feb 25, 2022)

  • v1.2.2(Feb 25, 2022)

    • fix: make all assertions methods to bump assertion count d7f87ca
    • chore: update dependencies 82b40a1

    https://github.com/japa/assert/compare/v1.2.1...v1.2.2

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Feb 20, 2022)

    • docs: remove typedoc and docs directory 6d3ff84
    • chore: update dependencies 68629a9

    https://github.com/japa/assert/compare/v1.2.0...v1.2.1

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Feb 11, 2022)

    • refactor: update plugin fn to work with the runner API af2abfc
    • chore: update dependencies 8437129

    https://github.com/japa/assert/compare/v1.1.1...v1.2.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Jan 31, 2022)

    • refactor: point assertion planning error stack to the line that called assert.plan f727ca8
    • chore: update dependencies 624d551

    https://github.com/japa/assert/compare/v1.1.0...v1.1.1

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Jan 27, 2022)

    • feat: add plugin function and complete documentation 1133a4b
    • chore: update dependencies 25f2bc7
    • chore: define repo details in package.json file 0a16008

    https://github.com/japa/assert/compare/v1.0.1...v1.1.0

    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Jan 10, 2022)

  • v1.0.0(Jan 10, 2022)

    Commits:

    • feat: add assert class macroable 23a22d8
    • chore(package): update publish files and publish info 1aa26f8
    • feat: initial implementation using chai.Assert 7a96dcc

    Full Changelog: https://github.com/japa/assert/commits/v1.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Japa.dev
An API first testing framework for Node.js
Japa.dev
A small CLI utility to configure Japa inside an existing Node.js project

A small CLI utility to configure Japa inside an existing Node.js project

Japa.dev 5 Mar 11, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
🧪 A Japa extension for VSCode

?? Japa extension for VSCode Features Run tests without typing anything. Either with a shortcut, or via Code Lenses Support multiple workspaces Suppor

Julien Ripouteau 10 Sep 27, 2022
A lightweight, performant, and simple-to-use wrapper component to stick section headers to the top when scrolling brings them to top

A lightweight, performant, and simple-to-use wrapper component to stick section headers to the top when scrolling brings them to top

Mayank 7 Jun 27, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 2022
Clinton Mbonu 20 Jun 30, 2022
`raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages

`raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages. Raaghu mfe can be used as a base to build complex components and UI layouts whilst maintaining a high level of reusability,flexibility with ease of maintenance.

Wai Technologies 160 Dec 30, 2022
The Web 3.0 social layer built on top of Twitter

Niftycase – The Web 3.0 Chrome extension for Twitter Niftycase is a open-source Chrome extension that allows you to view anybody's NFTs directly on Tw

Matt Welter 16 Jul 14, 2022
A JavaScript library built on top of the Faker.JS library. It generates massive amounts of fake data in the browser and node.js.

Blaver - generate massive amounts of fake data in the browser and node.js Blaver is a JavaScript library built on top of the Faker.JS library. It gene

Priyansh 113 Dec 30, 2022