How to use the AssertionError function from chai

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

214
215
216
217
218
219
220
221
222
223
224
225
}


// Inspired by what is done within chai project itself to test assertions
// https://github.com/chaijs/chai/blob/main/test/bootstrap/index.js
global.chaiErr = function globalErr(fn, val) {
  if (chai.util.type(fn) !== 'function') throw new chai.AssertionError('Invalid fn');


  try {
    fn();
  } catch (err) {
fork icon48
star icon196
watch icon0

+ 5 other calls in file

301
302
303
304
305
306
307
308
309
310
  const index = meta[dashedBlockName]?.challengeOrder?.findIndex(
    arr => arr[0] === challenge.id
  );

  if (index < 0) {
    throw new AssertionError(
      `Cannot find ID "${challenge.id}" in meta.json file for block "${dashedBlockName}"`
    );
  }
});
fork icon0
star icon0
watch icon1

+ 7 other calls in file