Jest测试失败:JS函数独立运行正常但测试返回Undefined求助
Jest测试返回Undefined,但函数独立运行正常
我编写了一个JavaScript函数,该函数独立运行时能正常生成预期的哈希字符串,但通过Jest测试时失败,返回值为undefined而非预期的哈希字符串。
测试报错信息如下:
FAIL node/FileParseHashChallenge.test.js ● FileParseHashChallenge expect(received).toBe(expected) // Object.is equality Expected: "0bX78Xa3X9eXe8Xf9Xc4X9bX60X09X00X38XbaX9xXfiXmcX" Received: undefined 7 | 8 | test('FileParseHashChallenge', async () => { > 9 | expect(await FileParseHashChallenge()).toBe('0bX78Xa3X9eXe8Xf9Xc4X9bX60X09X00X38XbaX9xXfiXmcX') |
执行npm test的结果:
> npm test Test Suites: 1 failed, 3 passed, 4 total Tests: 1 failed, 6 passed, 7 total Snapshots: 0 total Time: 0.736 s, estimated 1 s
我希望所有测试能够通过,恳请各位提供帮助!
内容的提问来源于stack exchange,提问作者Bevo
相关产品推荐
相关产品推荐

