import {expect} from '@loopback/testlab';
import sinon from 'sinon';
describe('example test', () => {
let clock: sinon.SinonFakeTimers;
before(() => {
clock = sinon.useFakeTimers();
});
after(() => {
clock.restore();
});
it('should return the correct date', () => {
// set the clock to a specific time
clock.setSystemTime(new Date('2022-05-01T00:00:00Z'));
const currentDate = new Date();
expect(currentDate.getFullYear()).to.equal(2022);
expect(currentDate.getMonth()).to.equal(4);
expect(currentDate.getDate()).to.equal(1);
});
});
手机扫一扫
移动阅读更方便
你可能感兴趣的文章