小编Art*_*Vic的帖子

无法理解的单元测试使用 Jest 导致错误

我正在处理两个几乎相同的测试用例,我应该断言期望两个 NgRx 效果返回一个布尔值流。在第一个测试用例中一切都按预期工作,尽管对第二个测试用例执行相同的操作,但我无法使其按预期工作。无论我做什么,收到的值总是一个空数组:

expect(received).toEqual(expected) // deep equality
    - Expected
    + Received

    - Array [
    -   Object {
    -     "frame": 10,
    -     "notification": Notification {
    -       "error": undefined,
    -       "hasValue": true,
    -       "kind": "N",
    -       "value": true,
    -     },
    -   },
    - ]
    + Array []
Run Code Online (Sandbox Code Playgroud)

工作测试

logger.effects.spec.ts:

expect(received).toEqual(expected) // deep equality
    - Expected
    + Received

    - Array [
    -   Object {
    -     "frame": 10,
    -     "notification": Notification {
    -       "error": undefined,
    -       "hasValue": true,
    -       "kind": "N",
    -       "value": true, …
Run Code Online (Sandbox Code Playgroud)

jestjs ngrx ngrx-effects angular

5
推荐指数
1
解决办法
832
查看次数

标签 统计

angular ×1

jestjs ×1

ngrx ×1

ngrx-effects ×1