我注意到,如果我ramda
有时在尝试为Jest
要导出的方法编写测试时遇到问题。我将问题归结为以下测试和两个基本的减速器功能。我已将它们张贴在上面gist
,以免用代码堵塞这个问题。
https://gist.github.com/beardedtim/99aabe3b08ba58037b20d65343ed9d20
ramda
减速器出现以下错误:
● counter usage › counter counts the words and their index in the given list of words
expect(received).toEqual(expected)
Expected value to equal:
[{"count": 3, "indexes": [0, 2, 4], "value": "a"}, {"count": 1, "indexes": [1], "value": "b"}, {"count": 1, "indexes": [3], "value": "c"}]
Received:
[{"count": 15, "indexes": [0, 2, 4, 0, 2, 4, 0, 2, 4, 0, 2, 4, 0, 2, 4], "value": "a"}, {"count": 5, "indexes": [1, 1, 1, 1, 1], "value": "b"}, {"count": 5, "indexes": [3, 3, 3, 3, 3
], "value": "c"}]
这使我相信ramda
reduce 是保持某种状态或words
彼此共享。我不确定这是怎么发生的。任何人都知道我应该在谷歌上搜索什么或其他处理此问题的一些文档/示例?