Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wrumsby/testcaseloader

TestCaseLoader is a small utility to load test cases from files.
https://github.com/wrumsby/testcaseloader

Last synced: 6 days ago
JSON representation

TestCaseLoader is a small utility to load test cases from files.

Awesome Lists containing this project

README

        

# testcaseloader

`TestCaseLoader` is a small utility to load test cases from files.

Files are:

- expected to be written in JavaScript
- by default in a folder named `testcases` (or a subfolder of this folder)
- named with the prefix `input-` or `expected-` and an index suffix (e.g. `input-0.js`)

## Installation

```
npm install --save-dev @wrumsby/testcaseloader
```

## Usage

```ts
import { TestCaseLoader } from 'testcaseloader';
import { someFunction } from './someFunction';

describe('someFunction', () => {
// This will load testCases from ./testcases/someFunction
// testCases are pairs of files named input-${n}.js and expected-${n}.js
// e.g. input-0.js, expected-0.js, input-1.js, expected-1.js
const testCases = new TestCaseLoader().load('someFunction');

it('should work', () => {
testCases.forEach(({ input, expected }) => {
const actual = someFunction(input);

expect(actual).toEqual(expected);
});
});
});
```