error-handling - Jest 失败的测试不再提供失败信息,仅提供 `maxLength` 错误

标签 error-handling jestjs

在我的项目中,Jest 运行得很好,据我所知,测试依赖项没有改变。当测试失败时,它会注销预期内容与收到内容的详细信息。但是,如果我现在测试失败(或者尝试使其失败,如下例所示),我得到的只是围绕 pretty-format 选项的错误:

when provided no parameters other than text › default values are set correctly

    pretty-format: Unknown option "maxWidth".

      48 |
      49 |     it('default values are set correctly', async () => {
    > 50 |       expect(element.variant).toBe('primarzy');

应该告诉我它期望“primarzy”(故意拼写错误)但得到“primary”。无论哪个测试套件测试失败,都会发生这种情况。

最佳答案

因此,对于遇到此问题的其他人来说,显然我的测试依赖项中的不同包试图运行不同版本的 pretty-format 破坏失败的测试输出。对我来说,修复方法只是手动安装 pretty-format: npm 我漂亮格式--save-dev 此后一切正常。

关于error-handling - Jest 失败的测试不再提供失败信息,仅提供 `maxLength` 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73735599/

相关文章:

javascript - 如何在 jest setupFiles 中访问 'expect'

javascript - 如果外部文件不存在,文件将停止 : is possible to solve this?

haskell - 如何检查命令行参数的数量?

javascript - 如何将 res 对象传递到 Jest 模拟函数中的回调函数中?

react-native - 使用 Jest 模拟命名导入

node.js - 用 Jest 模拟 nodemailer.createTransport.sendMail

angular - 自 Jest 25 以来,覆盖率报告具有不同的源路径

excel - 无法为 Excel UDF 返回正确的错误类型

exception - 在 PowerShell 中进行错误处理的正确方法是什么?

error-handling - 如何找出 tcl 命令可能生成哪些错误?