-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
I have problem with my unit test.
Example test for reproduce problem:
const chai = require('chai');
const sinon = require('sinon');
const strftime = require('strftime');
let { expect } = chai;
let sandbox = new sinon.createSandbox();
describe('strftime test', function () {
afterEach(function () {
sandbox.restore();
});
it('test one', () => {
sandbox.useFakeTimers(new Date(2021,8,3));
expect(strftime('%Y-%m-%d %H:%M:%S')).to.be.eq('2021-09-03 00:00:00'); // ok
});
it('test second, () => {
sandbox.useFakeTimers(new Date(2021,8,1));
expect(strftime('%Y-%m-%d %H:%M:%S')).to.be.eq('2021-09-01 00:00:00'); // fail
});
})Problem relate with save state _cachedDateTimestamp/_cachedDate.
How can I reset the state for my case?
Metadata
Metadata
Assignees
Labels
No labels