ava-fixture
This library helps you to write fixture tests: test-per-folder or test-per-file.
Usage
For example, you are testing code that process files (e.g. a compiler, config-reader, etc).
You put each test case inside its own folder:
+ fixtures
+ cases
+ empty
- somefiles
+ basic-case
- someOtherFiles
+ single-line
- ...
+ ...
You can run each test case like this:
import ava from 'ava';
import fixture from 'ava-fixture';
const ftest = fixture(ava, 'fixtures/cases', 'fixtures/baselines', 'fixtures/results');
ftest.each((t, d) => {
target.process(d.casePath, d.resultPath)
return d.match()
})
You can also use this library to run tests that only read files:
import ava from 'ava';
import fixture from 'ava-fixture';
const ftest = fixture(ava, 'fixture/cases');
ftest('test title', 'case-1', (t, d) => {
t.is(d.casePath, 'absolut path the the case folder')
const result = target.read(d.casePath)
t.deepEqual(result, 'expected result')
});
ftest('case-1', (t, d) => {
})
ftest.each((t, d) => {
})
ftest.each(/some filter/, (t, d) => {
})
Other API
import test from 'ava';
import fixture from 'ava-fixture';
const ftest = fixture(test, 'fixture/cases');
ftest.only(...)
ftest.skip(...)
ftest.failing(...)
ftest.only.each.failing(...)
For before()
, beforeEach()
, after()
, afterEach()
, todo()
, use ava
directly.
Contribute
npm install
git checkout -b <branch>
npm run watch
git commit -m "<commit message>"
git push
Npm Commands
There are a few useful commands you can use during development.
npm run watch
npm run test
npm run verify
npm run build
npm run lint
Generated by generator-unional@0.9.0