https://github.com/paulvollmer/testtable.js
utility to write data driven tests
https://github.com/paulvollmer/testtable.js
testing
Last synced: 12 months ago
JSON representation
utility to write data driven tests
- Host: GitHub
- URL: https://github.com/paulvollmer/testtable.js
- Owner: paulvollmer
- License: mit
- Created: 2018-05-15T10:36:37.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-06-01T09:55:20.000Z (about 7 years ago)
- Last Synced: 2025-06-04T20:06:32.786Z (about 1 year ago)
- Topics: testing
- Language: JavaScript
- Homepage: https://paulvollmer.net/testtable.js
- Size: 103 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# testtable.js
Module to write data driven tests.
## Installation
```
npm install --save-dev @paulvollmer/testtable
```
or if you prefer yarn, run
```
yarn add --dev @paulvollmer/testtable
```
## Usage
```js
const TestTable = require('testtable');
describe('Sample test', () => {
// create an array with input and expected data
const testData = [
{ input: 'hello foo', expected: 'hello world', skip: true },
{ input: 'hello bar', expected: 'hello world' },
];
// run all tests defined at the testData array
new TestTable(testData).run((index, data) => {
test(`${index} should ...`, () => {
expect(index).toBe(1);
expect(data.input).toBe('hello bar');
expect(data.expected).toBe('hello world');
})
});
});
```
## Test data
Sample test data object
```
{
input: 'hello foo',
expected: 'hello bar',
only: true
}
```
#### input
The `input` property can be used to define the test data.
#### expected
The `expected` property set the data used to write code to check if x expect to be equal to y
#### only
The `only` property can be used to only run a specific item from the test data
#### skip
The `skip` property can be used to skip the execution of a test item