Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/wrumsby/testcaseloader
- Owner: wrumsby
- Created: 2020-03-21T04:49:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T16:41:15.000Z (almost 2 years ago)
- Last Synced: 2024-04-13T22:06:50.821Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 941 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
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);
});
});
});
```