Miss any of our Open RFC calls?Watch the recordings here! »

@wrumsby/testcaseloader

1.0.4 • Public • Published

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

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);
    });
  });
});

Keywords

Install

npm i @wrumsby/testcaseloader

DownloadsWeekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

5.54 kB

Total Files

8

Last publish

Collaborators

  • avatar