有时使用 testcafé 登录失败

Sometimes log in fails with testcafé

我正在使用 testcafe 进行软件测试,一个月了,我一直面临一个问题,当我 运行 测试并点击登录按钮时,有时它会通过并且有时不会,这会导致测试失败。它抛出一个错误

错误详情: 无法对

处的资源执行请求

"mysite.com" 因为一个错误。 请求 header 的大小为 10242 字节,超出了设置的限制。 解析此 header 时会导致内部 Node.js 错误。 要解决此问题,您需要将 '--max-http-header-size=...' 标志添加到 'NODE_OPTIONS' 环境变量:

  macOS, Linux (bash, zsh)
  export NODE_OPTIONS='--max-http-header-size=20000'

  Windows (powershell)
  $env:NODE_OPTIONS='--max-http-header-size=20000'

  Windows (cmd)
  set NODE_OPTIONS='--max-http-header-size=20000'

  and then start your tests.

当我 运行 在本地和在 Azure Pipelines 中进行测试时,会发生这种情况。 我尝试在本地使用 --max-http-header-size=20000 并在管道中使用 maxHttpHeaderSize,但没有帮助。

有人可以帮忙吗?

在这种情况下似乎有两个错误在起作用。

第一个: 错误信息中有错误。 Windows (cmd) 的命令应如下所示: set NODE_OPTIONS="--max-http-header-size=20000"(带双引号)。

第二个: TestCafe 有一个已知的 issue with header size. If a header is larger than ~65 KB, it is split into multiple packets. Right now, testcafe only takes the last packet into account when calculating the recommended header size. To run tests, you'll need to find an appropriate max header size that is larger than 80 KB as it's the default maxHeaderSize