Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beforeEach does not execute for each test #1

Closed
fatso83 opened this issue May 16, 2019 · 0 comments
Closed

beforeEach does not execute for each test #1

fatso83 opened this issue May 16, 2019 · 0 comments

Comments

@fatso83
Copy link
Owner

fatso83 commented May 16, 2019

See sinonjs/sinon#2022 (comment).

Testcase below should print the "beforeEach" twice, but it only happens once.

const assert = require('chai').assert;
const sinon = require('sinon');

describe('resetHistory', function() {
  var num = null;


  var i = 0;
  beforeEach(function() {
    num = sinon.createStubInstance(Number);
    console.log('beforeEach', ++i);
  });

  afterEach(() => {
    // Restore the default sandbox here
    sinon.restore();
  });

  describe('called on individual stub method', function() {
    it('should clear "called" status on stub', function() {
      num.toFixed();
      assert.isTrue(num.toFixed.called);
      num.toFixed.resetHistory();
      assert.isFalse(num.toFixed.called);
    });
  });

  describe('called on module', function() {
    it('should clear "called" status on all stubs', function() {
      num.toFixed();
      assert.isTrue(num.toFixed.called);
      sinon.resetHistory();
      assert.isFalse(num.toFixed.called);
    });
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant