How to use the chai.use function in chai

To help you get started, we’ve selected a few chai 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 invisible-college / democracy / tests / link.spec.js View on Github external
const demo = require('..')
const chai = require('chai')
const assert = chai.assert
const expect = chai.expect
const should = chai.should()
chai.use(require('chai-as-promised'))

const { Map, List } = require('immutable')

let networkId

describe('Democracy linking', () => {

  before(async () => {
    demo.cleanCompileSync("TestLibrary")
    eth = demo.getNetwork('test')
    networkId = await eth.net_version()
  })

  // Expect error thrown from promise
  // https://stackoverflow.com/a/45496509
  it('throws an error to link without compiling', async () => {
github interledgerjs / ilp / test / clientSpec.js View on Github external
'use strict'
/* global describe it beforeEach afterEach */

const chai = require('chai')
const expect = chai.expect
const mockRequire = require('mock-require')
const sinon = require('sinon')
const sinonChai = require('sinon-chai')
chai.use(sinonChai)

const MockCore = require('./mocks/mock-core')
mockRequire('ilp-core', MockCore)
const Client = require('../src/lib/client')
const PaymentRequest = require('../src/lib/request')

const FAKE_TIME = 0

describe('Client', function () {
  describe('constructor', function () {
    it('should instantiate an ilp-core client', function () {
      const client = new Client({
        auth: {
          account: 'https://ledger.example/accounts/alice',
          password: 'alice'
        }
github ipfs / js-ipfs-http-client / test / refs.spec.js View on Github external
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const isNode = require('detect-node')
const waterfall = require('async/waterfall')
const path = require('path')
const fs = require('fs')

const ipfsClient = require('../src')
const f = require('./utils/factory')

describe('.refs', function () {
  this.timeout(80 * 1000)

  if (!isNode) { return }

  let ipfs
  let ipfsd
  let folder
github GiladShoham / seven-boom / lib / sevenBoom.spec.js View on Github external
import chai from 'chai';
import chaiAsPromised from "chai-as-promised";

import 'regenerator-runtime/runtime';

import SevenBoom from './sevenBoom';

var chaiDateString = require('chai-date-string');
chai.use(chaiAsPromised);
chai.use(chaiDateString);
const expect = chai.expect;

// Most of this tests are taken from the Boom repo
// In order to make sure that you can just replace all Boom with SevenBoom
describe('Seven Boom features', () => {
  it('does not use default guid generator and timeThrown if they are not set in option', (done) => {
    SevenBoom.init();
    const error = SevenBoom.badRequest();
    expect(error.output.payload.guid).to.not.exist
    expect(error.output.payload.timeThrown).to.not.exist
    done();
  });

  it('uses the default guid generator and timeThrown', (done) => {
    const opts = [{
        name : 'timeThrown',
github obniz / obniz / test / obniz / libs / embeds / switch.js View on Github external
let chai = require('chai');
let expect = chai.expect;
let sinon = require('sinon');

let testUtil = require('../../../testUtil.js');
chai.use(require('chai-like'));
chai.use(testUtil.obnizAssert);

describe('obniz.libs.switch', function() {
  beforeEach(function(done) {
    return testUtil.setupObnizPromise(this, done);
  });

  afterEach(function(done) {
    return testUtil.releaseObnizePromise(this, done);
  });

  it('onchange', function() {
    let stub = sinon.stub();
    this.obniz.switch.onchange = stub;
    expect(this.obniz).to.be.obniz;
    sinon.assert.callCount(stub, 0);
github bkimminich / juice-shop / test / server / keyServerSpec.js View on Github external
const sinon = require('sinon')
const chai = require('chai')
const sinonChai = require('sinon-chai')
const expect = chai.expect
chai.use(sinonChai)

describe('keyServer', () => {
  const serveKeyFiles = require('../../routes/keyServer')

  beforeEach(() => {
    this.req = { params: { } }
    this.res = { sendFile: sinon.spy(), status: sinon.spy() }
    this.next = sinon.spy()
  })

  it('should serve requested file from folder /encryptionkeys', () => {
    this.req.params.file = 'test.file'

    serveKeyFiles()(this.req, this.res, this.next)

    expect(this.res.sendFile).to.have.been.calledWith(sinon.match(/encryptionkeys[/\\]test.file/))
github quasarframework / quasar-cli / test / setup.js View on Github external
/**
 * Export modules to global scope as necessary
 * (only for testing)
 */

var chai = require('chai');

global.expect = chai.expect;
global.moquire = require('moquire');
global.sinon = require('sinon');

chai.use(require('sinon-chai'));
github jishi / node-sonos-discovery / test / unit / prototypes / Player / setGroupVolume.js View on Github external
'use strict';
const expect = require('chai').expect;
const sinon = require('sinon');
require('chai').use(require('sinon-chai'));

describe('Player.setGroupVolume', () => {
  const setGroupVolume = require('../../../../lib/prototypes/Player/setGroupVolume.js');
  let players;
  let coordinator;
  let system;

  beforeEach(() => {
    coordinator = {
      uuid: '123456789',
      groupState: {
        volume: 22
      }
    };

    players = [{
github jwplayer / jw-showcase / test / features / support / expect.js View on Github external
defineSupportCode(function () {
    chai.use(chaiAsPromised);
    global.expect = chai.expect;
});
github SetProtocol / setprotocol.js / test / helpers / chaiSetup.ts View on Github external
public configure() {
    if (this.isConfigured) {
        return;
    }

    chai.config.includeStack = true;
    chai.use(require('chai-bignumber')());
    chai.use(ChaiAsPromised);
    this.isConfigured = true;
  }
}