【问题标题】:Expected to have been called with T23:59:59.999Z but the actual calls were T12:59:59.999Z预计已使用 T23:59:59.999Z 调用,但实际调用为 T12:59:59.999Z
【发布时间】:2018-03-05 22:28:53
【问题描述】:

我正在使用 Angular 4+Moment 2.18.1

使用 moment().endOf('day') 在 Angular 应用程序代码中返回 2018-03-06T23:59:59.999Z,而在 jasmine 测试中返回 2018-03-06T12:59:59.999Z(截至今天)。

我正在使用以下函数来格式化日期

private getISODate(date: any) {
    return moment(date).utc().add(date.utcOffset(), 'm').toISOString();
}

如何让我的测试通过?

【问题讨论】:

  • 这是 Angular 代码和 Jasmine 代码都在同一台服务器上运行?

标签: angular jasmine momentjs


【解决方案1】:

我在代码中有date.utcOffset(),在测试中有date.utcOffset。它没有标记错误,而是给了我这些不同的结果。 Javascript 很奇怪!

【讨论】:

    猜你喜欢
    • 2017-11-02
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-26
    • 2017-01-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多