@wrumsby/testcaseloader
TypeScript icon, indicating that this package has built-in type declarations

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.4
    0
  • 1.0.3
    0
  • 1.0.2
    0

Package Sidebar

Install

npm i @wrumsby/testcaseloader

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

5.54 kB

Total Files

8

Last publish

Collaborators

  • wrumsby