
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
ava-fixture
Advanced tools
Helps you to easily write fixture tests with ava
.
Fixture tests are tests that require access to some files. The tests may write files and in that case the files can be compared with a baseline (i.e. Baseline Tests)
Assume you have the following folders:
+ fixtures
+ cases
+ case-1
- something.txt
+ other-cases
+ baselines
+ case-1
- something.txt
+ results # empty, not check into repository
When you only need to access files in each test case (i.e. don't need to perform baseline test):
import ava from 'ava';
import fixture from 'ava-fixture';
// Point to the base folder which contain the fixtures.
// Relative path starts from project root.
const ftest = fixture(ava, 'fixture/cases');
// You can also use absolute path.
// const ftest = fixture(ava, join(process.cwd(), 'fixture/cases'));
ftest('test title', 'case-1', (t) => {
// t is ava test.
// process.cwd() points to `case-1`
// ...test away
});
// test title can be omitted
ftest('case-1', (t) => {
// ...
})
When you want to perform baseline tests:
import test from 'ava';
import fixture from 'ava-fixture';
// Point to the base folder which contain the fixtures.
// Relative path starts from project root.
const btest = fixture(test, 'fixture/cases', 'fixture/baselines', 'fixture/results');
btest('test title', 'case-1', (t, d) => {
// t is ava test.
// process.cwd() points to `case-1`
// d.casePath, d.baselinePath, d.resultPath points to respective folder for `case-1`
// ...do tests
// `d.match()` will check if the result folder has the same content as the baseline folder.
return d.match()
});
// test title can be omitted
btest('case-1', (t) => {
// ...
})
import test from 'ava';
import fixture from 'ava-fixture';
const ftest = fixture(test, 'fixture/cases');
ftest.only(...)
ftest.skip(...)
For before()
, beforeEach()
, after()
, afterEach()
, todo()
, use ava
directly.
# right after clone
npm install
# begin making changes
git checkout -b <branch>
npm run watch
# edit `webpack.config.dev.js` to exclude dependencies for the global build.
# after making change(s)
git commit -m "<commit message>"
git push
# create PR
There are a few useful commands you can use during development.
# Run tests (and lint) automatically whenever you save a file.
npm run watch
# Run tests with coverage stats (but won't fail you if coverage does not meet criteria)
npm run test
# Manually verify the project.
# This will be ran during 'npm preversion' so you normally don't need to run this yourself.
npm run verify
# Build the project.
# You normally don't need to do this.
npm run build
# Run tslint
# You normally don't need to do this as `npm run watch` and `npm version` will automatically run lint for you.
npm run lint
Generated by generator-unional@0.3.1
FAQs
Write fixture tests with ava
The npm package ava-fixture receives a total of 27 weekly downloads. As such, ava-fixture popularity was classified as not popular.
We found that ava-fixture demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.