Skip to content

Adds promise support (rejects(), doesNotReject()) to tape by decorating it using tape-promise.

Notifications You must be signed in to change notification settings

small-tech/tape-with-promises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tape With Promises

🚨 This package is depracated. 🚨

Tape version 5.x+ supports promises (and thus async/await) and so this module is no longer necessary.

If you’re still on Tape version 4

Please consider upgrading to Tape 5.x.

If you can’t right now, you can still install and use version 1.0.1 of this module:

npm install @small-tech/[email protected]

To switch from this module to Tape version 5.x+:

  1. Install tape:

    npm install tape
    
  2. Remove this module:

    npm remove @small-tech/tape-with-promises
    
  3. In your test files, import the tape instead of this module:

    // Replace:
    
    import test from '@small-tech/tape-with-promises'
    
    // With:
    
    import test from 'tape'
    

About

Adds promise support (rejects(), doesNotReject()) to tape by decorating it using tape-promise.

Install

npm install --save-dev @small-tech/tape-with-promises

Use

import test from '@small-tech/tape-with-promises'

test('promises', async t => {
  await t.rejects(() => {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        // This does, indeed, reject.
        reject('Oh, no!')
      }, 100)
    })
  })
  await t.doesNotReject(() => {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        // This does, indeed, resolve.
        resolve('Yay!')
      })
    })
  })
})

If you save the above test in tests/index.js, you can run it with:

npx tape tests/**/*.js

Or, in your package.json file:

{
  "scripts": {
    "test": "tape tests/**/*.js"
  }
}

Test

npm -s test

Like this? Fund us!

Small Technology Foundation is a tiny, independent not-for-profit.

We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.

Related projects

  • tap-monkey: A tap formatter that’s also a monkey. Displays test runner status using a static single-line spinner (hint: it’s a monkey) and only fills your screen with text on failures and with your coverage report.

Credits

Copyright

Copyright ⓒ 2022-present, Aral Balkan, Small Technology Foundation.

License

Released under GNU AGPL version 3.0 or later.

About

Adds promise support (rejects(), doesNotReject()) to tape by decorating it using tape-promise.

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published