Skip to content

Latest commit

 

History

History
117 lines (86 loc) · 2.08 KB

api.md

File metadata and controls

117 lines (86 loc) · 2.08 KB

Sanna API

suite

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)
});

suite.test(description, test)

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)
});

suite.setup(hook)

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)
});

suite.teardown(hook)

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)
});

suite.before(hook)

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)
});

suite.after(hook)

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)
});