How to use the Assertion function from chai

Find comprehensive JavaScript chai.Assertion code examples handpicked from public code repositorys.

72
73
74
75
76
77
78
79
80
81
const chaiAssertionsCount = require('chai-assertions-count');
chai.use(chaiAssertionsCount);

describe('suite #2', () => {
  beforeEach(() => {
    chai.Assertion.resetAssertsCheck();
  });
  afterEach(() => {
    // you don't need both of them
    chai.Assertion.checkAssertionsCount();
fork icon73
star icon45
watch icon6

+ 9 other calls in file

186
187
188
189
190
191
192
193
194
195
196
197
    throw new Error('Expected an error, but none was thrown.');
  };
}


chai.use(function (chai) {
  const Assertion = chai.Assertion;


  Assertion.addMethod('exactlyContain', function (expectedElements) {
    const errorMessage = `expect [${this._obj}] to exactly contain [${expectedElements}]`;
    new Assertion(this._obj, errorMessage).to.deep.have.members(expectedElements);
fork icon48
star icon196
watch icon0

+ 3 other calls in file