1.0.7 • Published 10 months ago

@liorchamla/approval-utils v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

Approval testing with Vitest !

A collection of utilities to help with approval testing with Vitest.

Table of Contents

Installation

You can install the library using your preferred package manager:

Using npm:

npm install @liorchamla/approval-utils

Using Yarn:

yarn add @liorchamla/approval-utils

Using pnpm:

pnpm add @liorchamla/approval-utils

Introduction

@liorchamla/approval-utils is a utility library designed to simplify approval testing (also known as golden master testing) in combination with Vitest. Approval testing is a method of testing where you capture the output of your system and compare it to a previously approved version of that output. If the outputs match, the test passes; otherwise, it fails.

Examples

Here is a simple example of how you might use these utilities in a test:

import { spy, approveCombinations } from '@liorchamla/approval-utils'

function exampleFunction(a: number, b: number) {
    return a + b
}

// Define possible parameter values
const paramsSet = [
    [1, 2],
    [3, 4]
]

// Approve all combinations
approveCombinations('exampleFunction', exampleFunction, paramsSet)

In this example, approveCombinations will test exampleFunction with all combinations of 1, 2 and 3, 4 and compare the output to the approved golden master.

License

This project is licensed under the MIT License

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago