【问题标题】:Prevent "t.expect(log).contains('string', 'message')" from printing log防止“t.expect(log).contains('string', 'message')”打印日志
【发布时间】:2022-01-11 21:03:27
【问题描述】:

我有一个测试,它查找一个大日志文件的约 100 个单独的子字符串,如果任何字符串不存在,则失败。每次找到一个不存在的字符串时,我都会发出一条消息,说明是哪一个。但是,日志文件也放入了输出日志中,而且非常大。我怎样才能防止它被打印出来?

【问题讨论】:

    标签: testing automation automated-tests e2e-testing testcafe


    【解决方案1】:

    TestCafe 不允许从报告中删除错误消息。但是,您可以通过以下方式重写您的断言以隐藏预期的字符串:

    const logContains = log.includes(myString);
    
    await t.expect(logContains).ok(`The log file does not contain the following string: "..."`);
    

    【讨论】:

      猜你喜欢
      • 2013-12-12
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 2016-04-28
      • 2021-12-22
      • 2016-03-22
      • 1970-01-01
      • 2015-07-08
      相关资源
      最近更新 更多