【发布时间】:2021-09-29 01:33:25
【问题描述】:
最近切换到在我们的管道中为我们的 Angular 项目使用 Cypress 并行。我们在 AWS 上的 Codebuild 上运行,并运行 Cypress runner 的 5 个线程。大约四分之一的时间,对其中一个线程的第一次测试失败并出现以下错误:
An uncaught error was detected outside of a test
Invalid or unexpected token
This error originated from your test code, not from Cypress.
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test. We dynamically generated a new test to display this failure.
尝试了很多方法来解决这个问题,包括将 modifyObtrusiveCode 设置为 false、chromeWebSecurity 设置为 false、升级 Cypress。我们已经在捕获未捕获的异常,因此这似乎不应该成为问题。我为此打开了一些额外的日志,这是输出
[3] 2020-03-06T19:57:20.369Z cypress:server:project onMocha start
[3] 2020-03-06T19:57:20.369Z cypress:server:reporter got mocha event 'start' with args: [ { start: '2020-03-06T19:57:20.366Z' } ]
[3] 2020-03-06T19:57:20.374Z cypress:server:project onMocha suite
[3] 2020-03-06T19:57:20.374Z cypress:server:reporter got mocha event 'suite' with args: [ { id: 'r1', title: '', root: true, type: 'suite', file: 'cypress/integration/ci-tests/content-acquisition/channels/channel-manual-upload-run-acquired-items-tab.spec.ts' } ]
[3]
[3] 2020-03-06T19:57:20.390Z cypress:server:project onMocha test
[3] 2020-03-06T19:57:20.391Z cypress:server:reporter got mocha event 'test' with args: [ { id: 'r2', title: 'An uncaught error was detected outside of a test', body: 'function throwErr() {\n throw err;\n }', type: 'test' } ]
[3] 2020-03-06T19:57:20.555Z cypress:server:reporter got mocha event 'fail' with args: [ { id: 'r2', title: 'An uncaught error was detected outside of a test', err: { message: 'Unexpected end of input\n' + '\n' + 'This error originated from your test code, not from Cypress.\n' + '\n' + 'When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.\n' + '\n' + 'Cypress could not associate this error to any specific test.\n' + '\n' + 'We dynamically generated a new test to display this failure.', name: 'Uncaught SyntaxError', stack: 'Uncaught SyntaxError: Unexpected end of input\n' + '\n' + 'This error originated from your test code, not from Cypress.\n' + '\n' + 'When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.\n' + '\n' + 'Cypress could not associate this error to any specific test.\n' + '\n' + 'We dynamically generated a new test to display this failure.' }, state: 'failed', body: 'function throwErr() {\n throw err;\n }', type: 'test', duration: 179, wallClockStartedAt: '2020-03-06T19:57:20.374Z', timings: { lifecycle: 26, test: [Object] } } ]
我真的不能犯这些错误,但也许其他人可以。我有点不知道该尝试什么(我今天尝试的东西比我列出的要多,但我想不起来了)。有什么想法吗?
【问题讨论】:
-
我也遇到了这个问题,但一直没能找到解决办法。分享我所做的,希望它可能会激发一些想法。我让每个线程都设置了自己的 appdata 位置。我正在使用 webpack 预处理器,并认为可能某些输出文件在某种竞争条件下相互覆盖。
标签: cypress