mocha-node-setup.js 580 B

12345678910111213141516171819202122232425262728
  1. // non-Cypresss environment (plain Mocha)
  2. // simulate Cypress built-in tools, like sinon-chai
  3. if (!global.cy) {
  4. const chai = require('chai')
  5. const sinon = require('sinon')
  6. const sinonChai = require('sinon-chai')
  7. chai.use(sinonChai)
  8. global.expect = chai.expect
  9. let sandbox
  10. beforeEach(() => {
  11. sandbox = sinon.createSandbox()
  12. global.cy = {
  13. stub: function () {
  14. return sandbox.stub.apply(sandbox, arguments)
  15. },
  16. log () {
  17. console.log.apply(console, arguments)
  18. }
  19. }
  20. })
  21. afterEach(() => {
  22. sandbox.restore()
  23. })
  24. }