Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const chai = require('chai');
- const sinonChai = require('sinon-chai');
- const chaiAsPromised = require('chai-as-promised');
- const chaiEnzyme = require('chai-enzyme');
- chai.use(sinonChai);
- chai.use(chaiAsPromised);
- chai.use(chaiEnzyme());
- // Make sure chai and jasmine ".not" play nice together
- const originalNot = Object.getOwnPropertyDescriptor(chai.Assertion.prototype, 'not').get;
- Object.defineProperty(chai.Assertion.prototype, 'not', {
- get() {
- Object.assign(this, this.assignedNot);
- return originalNot.apply(this);
- },
- set(newNot) {
- this.assignedNot = newNot;
- return newNot;
- }
- });
- // Combine both jest and chai matchers on expect
- const jestExpect = global.expect;
- global.expect = actual => {
- const originalMatchers = jestExpect(actual);
- const chaiMatchers = chai.expect(actual);
- const combinedMatchers = Object.assign(chaiMatchers, originalMatchers);
- return combinedMatchers;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement