How to use the tape.test.onFinish function in tape

To help you get started, we’ve selected a few tape examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buckless / requelize / test / utils.js View on Github external
const requelize = require('../')({ db: 'requelize_test' })
const { test } = require('tape')

function quitDb () {
  return requelize.r.getPoolMaster().drain()
}

test.onFinish(() => {
  quitDb()
})

module.exports.test = test
module.exports.requelize = requelize

module.exports.dropDb = () => {
  return requelize.r
    .dbDrop('requelize_test')
    .catch((err) => {
      if (err.message.match(/Database `.*` does not exist/)) {
        return Promise.resolve()
      }

      throw err
    })