
Product
Unify Your Security Stack with Socket Basics
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.
Psst — Want a reporter for this module? Go here -> Vehmloewff/zip-tap-reporter
A fast, promise-based TAP testing library
npm i -D zip-tap
The syntax is easy, humman readable, and familiar.
const { tests, describe } = require('zip-tap');
describe(`passing tests`, it => {
it(`should add`, expect => {
expect(1 + 1).toBe(2);
});
it(`should be the right type`, expect => {
expect(2 + 1).toBeType('number');
expect({}).not.toBeType('number');
});
});
To bring promises into the game, just add in await
and async
.
If there are delays between describe
functions, just wrap everyting in a tests
function.
const { tests, describe } = require('zip-tap');
const delay = require('delay');
tests(async () => {
await delay(100);
await describe(`first`, async it => {
await delay(300);
it(`should work with a promise`, async expect => {
await delay(400);
expect('Vehmloewff').toMatch(/loe/);
});
it(`should work without a promise`, expect => {
expect({ a: 'b', c: { d: ['e'], f: 'g' } }).toMatchObject({
a: 'b',
c: { d: ['e'], f: 'g' },
});
});
});
await delay(200);
describe(`second`, it => {
it(`should be third`, expect => {
expect(() => {
throw new Error(`Hello!`);
}).toThrow(/hello/i);
});
});
});
It is easy to add custom assertions:
const { tests, describe, addAssertion } = require('zip-tap');
addAssertion((actual, expected) => {
return {
ok: actual.length === expected,
actual: actual.length,
expected: expected,
};
}, `isLength`);
describe(`custom assertion`, it => {
it(`should be the same length`, expect => {
expect('foo').custom(`isLength`, 3);
});
});
Example output:
TAP version 13
# tests
ok 1 - should add the numbers
ok 2 - should subtract the numbers
# add() should work
ok 3 - should add the numbers
not ok 4 - should subtract the numbers and not be 0
---
message: failed at '!toBe'
operator: !toBe
at: !toBe(/home/vehmloewff/Code/zip-tap/dist/build.cjs.js:3252:95)
expected: -1
actual: -1
...
ok 5 - should be even
# try things async
ok 6 - should still run async
# try things even more async
ok 7 - should pass
1...7
# not ok
# success: 6
# failure: 1
Sure!
# fork and clone repo
cd zip-tap
npm install
npm test -- -w
Issues and PR's are welcome!
Just don't forget to npm run lint
! :sweat_smile:
FAQs
A fast, promise-based TAP testing library
We found that zip-tap 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.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.
Product
Socket is launching experimental protection for the Hugging Face ecosystem, scanning for malware and malicious payload injections inside model files to prevent silent AI supply chain attacks.
Research
/Security News
The Socket Threat Research Team uncovered a coordinated campaign that floods the Chrome Web Store with 131 rebranded clones of a WhatsApp Web automation extension to spam Brazilian users.