@zebrunner/javascript-agent-mocha
Version:
Zebrunner Agent for Mocha
70 lines (59 loc) • 2.23 kB
JavaScript
const assertChai = require('chai').assert;
const { expect } = require('chai');
// eslint-disable-next-line no-unused-vars
const should = require('chai').should();
const logger = require('./logger');
describe('Chai assertions', () => {
describe('that fail', () => {
it('assert style', async () => {
logger.info('fail: hello world');
logger.info('fail: hello world2');
logger.info('fail: hello world3');
const child = logger.child({ a: 'property' });
child.info('fail: hello child!');
const numbers = [1, 2, 3, 4, 5];
assertChai.isArray(numbers, 'is array of numbers');
logger.info('fail: hello world4');
assertChai.include(numbers, 2, 'array contains 2');
logger.info('fail: hello world5');
assertChai.lengthOf(numbers, 4, 'array contains 5 numbers');
logger.info('fail: hello world6');
});
it('expect style', () => {
const numbers = [1, 2, 3, 4, 5];
expect(numbers).to.be.an('array').that.includes(2);
expect(numbers).to.have.lengthOf(4);
});
it('should style', () => {
const numbers = [1, 2, 3, 4, 5];
numbers.should.be.an('array').that.includes(2);
numbers.should.have.lengthOf(4);
});
});
describe('that pass', () => {
it('assert style', () => {
logger.info('pass: hello world');
logger.info('pass: hello world2');
logger.info('pass: hello world3');
const child = logger.child({ a: 'property' });
child.info('pass: hello child!');
const numbers = [1, 2, 3, 4, 5];
assertChai.isArray(numbers, 'is array of numbers');
logger.info('pass: hello world4');
assertChai.include(numbers, 2, 'array contains 2');
logger.info('pass: hello world5');
assertChai.lengthOf(numbers, 5, 'array contains 5 numbers');
logger.info('pass: hello world6');
});
it('expect style', () => {
const numbers = [1, 2, 3, 4, 5];
expect(numbers).to.be.an('array').that.includes(2);
expect(numbers).to.have.lengthOf(5);
});
it('should style', () => {
const numbers = [1, 2, 3, 4, 5];
numbers.should.be.an('array').that.includes(2);
numbers.should.have.lengthOf(5);
});
});
});