reactjs - 我如何模拟我的日期,以便它也可以在部署服务器上工作
问题描述
我正在开玩笑并做出反应。
我有以下测试:
import sut from '../../utils/timeFormater';
describe('timeFormater utils ', () => {
test('hours should be 09 if the getHours method return number less then 10', () => {
const date = new Date('Mon Feb 08 2021 09:18:11 GMT+0100 (Central European Standard Time');
const result = sut(date);
expect(result.split(':')[0]).toBe('09');
});
});
在我在服务器上部署之后-时间比我早一个小时,所以当我期望时-expect(result.split(':')[0]).toBe('09');
它在我的本地机器上工作
但它在部署的服务器上不起作用 - 那里的测试失败了,因为那里
它收到 08 而不是 09
const date = new Date('Mon Feb 08 2021 09:18:11 GMT+0100 (Central European Standard Time');
我该如何解决这个问题?
解决方案
推荐阅读
- java - 如何仅列出指定目录中的文件夹?
- c# - C# Graphics DrawImage 函数重新缩放从原始位图中提取的位图
- asp.net-core - 通过命名参数解析路由
- php - 无法使用 AJAX 删除 php 中的行
- android - Recyclerview 移至屏幕外可见性
- python - Boto3 Python Lambda自定义返回错误
- java - 如何从 XML 中获取哈希以登录 java
- java - Java 套接字服务器,在集群服务器上
- vb.net - 如何创建仅适用于支持特定接口的类的泛型类?
- python - 如何在 Google Colab 上安装 nvidia apex