Advertisement
Guest User

Untitled

a guest
May 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. const chai = require('chai');
  2. const sinonChai = require('sinon-chai');
  3. const chaiAsPromised = require('chai-as-promised');
  4. const chaiEnzyme = require('chai-enzyme');
  5.  
  6. chai.use(sinonChai);
  7. chai.use(chaiAsPromised);
  8. chai.use(chaiEnzyme());
  9.  
  10. // Make sure chai and jasmine ".not" play nice together
  11. const originalNot = Object.getOwnPropertyDescriptor(chai.Assertion.prototype, 'not').get;
  12. Object.defineProperty(chai.Assertion.prototype, 'not', {
  13. get() {
  14. Object.assign(this, this.assignedNot);
  15. return originalNot.apply(this);
  16. },
  17. set(newNot) {
  18. this.assignedNot = newNot;
  19. return newNot;
  20. }
  21. });
  22.  
  23. // Combine both jest and chai matchers on expect
  24. const jestExpect = global.expect;
  25.  
  26. global.expect = actual => {
  27. const originalMatchers = jestExpect(actual);
  28. const chaiMatchers = chai.expect(actual);
  29. const combinedMatchers = Object.assign(chaiMatchers, originalMatchers);
  30. return combinedMatchers;
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement