Cypress: TypeError Array(...).keys(...).slice is not a function after upgrade from 3.8.3 to 4.4.1

Created on 22 Apr 2020  路  4Comments  路  Source: cypress-io/cypress

Current behavior:

I am using Cypress on an Angular application.

The following test is working on version 3.8.3

it('cy.get() - query DOM elements', () => {
  let x = [...Array(100).keys()].map(x => x + "");
  cy.server().route('/test', x);
  cy.get('[data-cy=landmark]').invoke('text').should('contain', 'Welcome');
})

but throws an error on 4.4.1

TypeError: Array(...).keys(...).slice is not a function
    at Context.<anonymous> (http://localhost:4200/__cypress/tests?p=cypress/integration/examples/querying.spec.js-628:8:35)

Test code to reproduce

Repository demonstrating the problem: https://github.com/Kimserey/cypress-test-issue

  • branch master is 3.8.3
  • branch upgrade-4 is 4.4.1
  1. From the root directory, run ng serve,
  2. From the root directory, start cypress npx cypress open,
  3. The only test in the integration specs will throw the TypeError.

Versions

Cypress 4.4.1

typescript regression v4.4.0

All 4 comments

I'm not able to reproduce this solely from the snippet provided.

Screen Shot 2020-04-22 at 1 42 41 PM

I am able to reproduce this from the repository provided, so this means it is something related to the environment setup. I suspect that it has something to do with the TypeScript configuration, since this begins failing in 4.4.0, which introduced out of the box TypeScript support in https://github.com/cypress-io/cypress/pull/5906

Indeed, I've confirmed that the test code above does not work when there is a devDependency of typescript. cc @sainthkh

To Reproduce

spec.js

let x = [...Array(100).keys()].map(x => x + "");

package.json

{
  "name": "cypress-test",
  "scripts": {},
  "devDependencies": {
    "cypress": "4.4.1",
    "typescript": "3.8.3"
  }
}

4.3.0

Screen Shot 2020-04-22 at 1 42 41 PM

4.4.0

Screen Shot 2020-04-22 at 1 54 34 PM

4.4.1

Screen Shot 2020-04-22 at 1 59 23 PM

TypeScript version 3.5.3

Screen Shot 2020-04-22 at 2 20 20 PM

TypeScript version 3.8.3 (current)

Screen Shot 2020-04-22 at 2 19 41 PM

Workaround

Downgrade to Cypress 4.3.0 for now.

It happened because I didn't set up downlevelIteration option. It will be fixed in the preprocessor first and added to Cypress.

The code for this is done in cypress-io/cypress#7129, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

Released in 4.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.5.0, please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings