Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Kimserey opened this issue Apr 21, 2020 · 4 comments · Fixed by #7129
Closed
Labels
topic: typescript type: regression A bug that didn't appear until a specific Cy version release v4.4.0 🐛 Issue present since 4.4.0

Comments

@Kimserey
Copy link

Kimserey commented Apr 21, 2020

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

@jennifer-shehane jennifer-shehane added the v4.4.0 🐛 Issue present since 4.4.0 label Apr 22, 2020
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Apr 22, 2020

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 #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.

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Apr 22, 2020
@jennifer-shehane jennifer-shehane added topic: typescript type: regression A bug that didn't appear until a specific Cy version release and removed stage: needs investigating Someone from Cypress needs to look at this labels Apr 22, 2020
@sainthkh
Copy link
Contributor

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

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 28, 2020

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.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 28, 2020

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.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: typescript type: regression A bug that didn't appear until a specific Cy version release v4.4.0 🐛 Issue present since 4.4.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants