将 createdAt/updatedAt 时间戳(毫秒)四舍五入为 000?

Sequelize createdAt/updatedAt timestamps (milliseconds) being rounded to 000?

我正在尝试对 createJob 函数进行单元测试。

我正在将作为 createJob 响应的一部分返回的 job 对象与在数据库中查询新创建的对象时返回的对象进行比较。

第一个对象的时间戳中包含毫秒数,第二个对象将它们四舍五入为 000createdAtupdatedAt 是自动创建的,实际上似乎根本不存储毫秒数。

actual = createJob(...)

的结果

expected = getJob(5)

的结果
  showDiff: true,
  actual: {
    id: 5,
    companyId: 2,
    title: 'Future Markets Designer',
    wage: 80000,
    location: 'East Paolohaven',
    description: 'Dynamic',
    featured: false,
    updatedAt: 2021-08-03T15:53:44.335Z,
    createdAt: 2021-08-03T15:53:44.335Z
  },
  expected: {
    id: 5,
    title: 'Future Markets Designer',
    wage: 80000,
    location: 'East Paolohaven',
    description: 'Dynamic',
    featured: false,
    createdAt: 2021-08-03T15:53:44.000Z,
    updatedAt: 2021-08-03T15:53:44.000Z,
    companyId: 2
  },
  operator: 'deepStrictEqual'

不确定解决此问题的最佳方法?

谢谢

我会把它留在这里以防它对其他人有帮助。不确定这是否是最好的方法,但明确添加 createdAtupdatedAt 解决了问题:

createdAt: {
    type: Sequelize.DATE(3),
    allowNull: false,
},
updatedAt: {
    type: Sequelize.DATE(3),
    allowNull: false,
}