cypress: Cypress reporter error in 10.7.0+ in Azure Pipileines with CRA
Current behavior
After ugrading cypress from 8 to 10.8.0 we are experience flaky component tests with the reporter reporting null issues. We have tried 10.9.0 (hung completly) and 10.7.0 experiencing the same.
We are using CRA with cypress, babel, ny, istanbul, cypress/code-coverage
Invalid array length
RangeError: Invalid array length
at Runner.runner._events.pass.<computed> (/home/vsts/.cache/Cypress/10.8.0/Cypress/resources/app/packages/server/lib/reporter.js:314:11)
at Runner.emit (node:events:538:35)
at Runner.emit (node:domain:475:12)
at Reporter.emit (/home/vsts/.cache/Cypress/10.8.0/Cypress/resources/app/packages/server/lib/reporter.js:362:46)
at Object.onMocha (/home/vsts/.cache/Cypress/10.8.0/Cypress/resources/app/packages/server/lib/project-base.js:272:34)
at Socket.<anonymous> (/home/vsts/.cache/Cypress/10.8.0/Cypress/resources/app/packages/server/lib/socket-base.js:260:40)
at Socket.emit (node:events:526:28)
at Socket.emit (node:domain:475:12)
at Socket.emitUntyped (/home/vsts/.cache/Cypress/10.8.0/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/typed-events.js:69:22)
at /home/vsts/.cache/Cypress/10.8.0/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/socket.js:428:39
at processTicksAndRejections (node:internal/process/task_queues:78:11)
Desired behavior
The tests should run and report on code coverage as previously.
Test code to reproduce
The config is here:
import { defineConfig } from 'cypress';
export default defineConfig({
viewportHeight: 768,
viewportWidth: 1024,
video: false,
defaultCommandTimeout: 12000,
requestTimeout: 12000,
retries: {
// Configure retry attempts for `cypress run`
runMode: 2,
// Configure retry attempts for `cypress open`
openMode: 0,
},
component: {
specPattern: 'src/**/*.spec.{js,jsx,ts,tsx}',
setupNodeEvents(on, config) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@cypress/code-coverage/task')(on, config);
return config;
},
devServer: {
framework: 'create-react-app',
bundler: 'webpack',
webpackConfig: {
mode: 'development',
devtool: false,
module: {
rules: [
// application and Cypress files are bundled like React components
// and instrumented using the babel-plugin-istanbul
// (we will filter the code coverage for non-application files later)
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-typescript'],
plugins: [
// we could optionally insert this plugin
// only if the code coverage flag is on
'istanbul',
],
},
},
},
],
},
},
},
experimentalSingleTabRunMode: true,
},
});
I haven’t enclosed a test as it’ pretty random - can do at request.
Cypress Version
10.7.0
Node version
16.15.0
Operating System
Linux
Debug Logs
No response
Other
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 30 (6 by maintainers)
@zzzorgo - which version of cypress are you running? This fix did not work for me -
Invalid array length RangeError: Invalid array length at indent (C:\Users\paulg\AppData\Local\Cypress\Cache\10.11.0\Cypress\resources\app\node_modules\mocha-7.0.1\lib\reporters\spec.js:45:12)@amehta265 - putting a null check in the indent function did work :
if(isNaN(indents)) { indents = 0; }So your educated guess would be correct and lies in the indents counter in the cypress version of mocha - 7.0.1 C:\Users\paulg\AppData\Local\Cypress\Cache\10.11.0\Cypress\resources\app\node_modules\mocha-7.0.1\lib\reporters\spec.js
This issue is not addressed in mocha 10.10 https://github.com/mochajs/mocha/blob/master/lib/reporters/spec.js
Thanks Alex, one immediate difference I see is in your cypress config file, we are using the component setup, not the e2e setup. https://docs.cypress.io/guides/component-testing/quickstart-react#Configuring-Component-Testing
I believe it is actually down to Azure Pipelines and it not having enough processing power - this is under review for us now. I will review your github over the next day or so - see if I can reproduce the issue! PG On Tuesday, 25 October 2022 at 13:55:47 BST, AlexandreGaubert @.***> wrote:
I’ve managed to setup a reproducible repository here by forking your examples repository (directory react-cra5-ts).
I’ve made it pretty close to our configuration, but I didn’t reproduced the error in CI. But you can clearly see that tests are reported twice here in the run npm ci job.
But this bug didn’t happened in this run here.
So it must be something in this commit
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
This is still a huge problem for us. This bug ends up killing about 25% of our runs within GitHub Actions. We’ve tried debugging lots of proposed solutions from the users above and nothing seems to have really helped. We’re still getting it very frequently.
Of our last 100 CI test runs, we’ve had 24 of them randomly fail because of this bug.
That’s roughly 1 in 4! When it happens, we have to just restart the run and hope it finishes. Please fix it!
An update from me, after upgrading to Cypress 12.5.1, I am still receiving the same issue.
RangeError: Invalid array length at t (<embedded>:2851:153968) at R.<anonymous> (<embedded>:2851:154134) at R.emit (node:events:539:35) at S.emit (<embedded>:4592:16654) at Object.onMocha (<embedded>:4639:425395) at p.<anonymous> (<embedded>:4639:66778) at p.emit (node:events:527:28) at p.emitUntyped (<embedded>:4350:84346) at <embedded>:4350:91863 at process.processTicksAndRejections (node:internal/process/task_queues:78:11) Resolution macbook-16 target closed while handling command Error: target closed while handling commandWell, I have left the boat, I swapped reporters to teamcity 😐
I’m thinking of adding your changes by using https://www.npmjs.com/package/patch-package I’ve hundreds of builds a day and plenty of them failing on this issue… first time using that one, I’ll let you know how it went if you are interested.
I too have been running into this issue after upgrading to
10.10.0. The runs fail about ~70% of the time immediately after the first test file complete its run:However, I’ve been able to execute ~8 consecutive successful suite runs after making the
reporter: 'spec'fix that @zzzorgo suggested so that seems to have at least allowed us to start working again without having to downgrade. Thanks @zzzorgo for the help.