Returns an single test suite withe the
const { suite } = require('sanna');
const assert = require('assert');
c = suite('Component')
c.test('it is true', () => {
assert.ok(true, true)
});
Registers a singe test in the suit.
- description: The text description of the test
- test: The actual test function. It is called with the test context.
const { suite } = require('sanna');
const assert = require('assert');
c = suite('Component')
c.test('it is true', () => {
assert.equal(true, true)
});
Registers a hook that is executed before all test in the suit
- hook: A function that is called
const { suite } = require('sanna');
const assert = require('assert');
c = suite('Component')
const context = {
value: false;
};
c.setup(() => {
context.value = true;
});
c.test('it is true', () => {
assert.equal(context.value, true)
});
Registers a hook that is executed before all test in the suit
- hook: A function that is called Can be used to close databases connections for instance.
const { suite } = require('sanna');
const assert = require('assert');
c = suite('Component')
const context = {
value: false;
};
c.test('it is true', () => {
context.value = undefined
});
c.teardown(() => {
assert.equal(context.value, true)
});
Registers a hook that is executed before each test in the suit
- hook: A function that is called
const { suite } = require('sanna');
const assert = require('assert');
c = suite('Component')
c.before((context) => {
context.value = true;
});
c.test('it is true', (context) => {
assert.equal(context.value, true)
});
Registers a hook that is executed after each test in the suit
- hook: A function that is called
const { sanna } = require('sanna');
const assert = require('assert');
c = sanna('Component')
c.test('it is true', (context) => {
context.value = undefined
});
c.after((context) => {
assert.equal(context.value, true)
});