Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

alibaba-archive/assert-extends

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

assert-extends

NPM version build status Test coverage David deps Known Vulnerabilities npm download

power-assert module extends.

  • assert.asyncThrows(block[, error][, message])

Note: use assert.rejects(asyncFn, error, message) instead of this module at Node.js 10.x+.

Usage

  • Add mocha --require intelli-espower-loader to your test scripts.

assert throws with async function

  • API: assert.asyncThrows(block[, error][, message]), return a promise
it('should throw error', () => {
  return assert.asyncThrows(function* () {
    yield fs.readFile(filepath);
  }, /not exists/);
});

it('should throw error', function* () {
  yield assert.asyncThrows(function* () {
    yield fs.readFile(filepath);
  }, /not exists/);
});

it('should throw error', done => {
  assert.asyncThrows(function* () {
    yield fs.readFile(filepath);
  }, /not exists/).then(done).catch(done);
});

License

MIT