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

Cypress’ parallel mode overwrites files among Cypress instances #26211

Open
romankhomitskyi opened this issue Mar 24, 2023 · 4 comments
Open
Assignees
Labels
E2E Issue related to end-to-end testing npm: @cypress/webpack-preprocessor @cypress/webpack-preprocessor package issues topic: preprocessors 🔧 Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: enhancement Requested enhancement of existing feature

Comments

@romankhomitskyi
Copy link

romankhomitskyi commented Mar 24, 2023

Current behavior

My Cypress test specs are coded in TypeScript. Compiling TypeScript code in Cypress’ parallel mode causes overwriting in files among Cypress instances

I am getting the following errors on CI

  • Invalid or unexpected token
  • Unexpected end of input
  • Failed to execute 'atob' on 'Window'
  • is not a function, however it is a function and works OK on local and without parallel mode, or with work around

Screenshot 2023-03-24 at 10 19 13

Screenshot 2023-03-24 at 10 20 10

Screenshot 2023-03-24 at 10 20 42

Screenshot 2023-03-24 at 10 21 24

Screenshot 2023-03-24 at 10 21 43

And also this error in this issue #9442

The only workaround is to isolate test files in their test runs, so test code will not get overwritten by other instances

I have this code to append unique IDs to filenames before Webpack processes test files in cypress.config.ts

import { v4 as uuid } from "uuid";

import webpackPreprocessor from "@cypress/webpack-batteries-included-preprocessor";

const filePreprocessor = webpackPreprocessor({ typescript: "typescript" });

const id = uuid();
on("file:preprocessor", (file) => {
  file.outputPath = file.outputPath.replace(
    /^(.*\/)(.*?)(\..*)$/,
    `$1$2.${id}$3`
  );
  console.log("File output", file.outputPath);
  return filePreprocessor(file);
});

The path will be replaced with “specs/my_feature/abc.<uuid>.spec.ts”. is unique among each cypress instances.

Desired behavior

Cypress should not overwrite files among Cypress instances
It should be implemented under the hood

Test code to reproduce

I run 58 cypress instances in one container which is starting in one Gitlab job

Overall I have the following flow

4 parallel gitlab jobs
4 cypress docker container in each
58 cypress instances in each container

I am using AWS spot instances

Screenshot 2023-03-24 at 10 31 13

Cypress Version

12.5.0

Node version

18.13.0

Operating System

Debian, cypress/factory docker image

Debug Logs

No response

Other

No response

@AtofStryker
Copy link
Contributor

Hi @romankhomitskyi . Thank you for opening an issue. This seems like it might be a hard issue to reproduce. Is there anyway we can get a small scale reproduction repository going that shows the issues with the file overwriting with the preprocessor? Also what version of Typescript are you using?

@romankhomitskyi
Copy link
Author

Hi @romankhomitskyi . Thank you for opening an issue. This seems like it might be a hard issue to reproduce. Is there anyway we can get a small scale reproduction repository going that shows the issues with the file overwriting with the preprocessor? Also what version of Typescript are you using?

Typescript: 4.9.5, and oldest

Here is an article describing a problem and solution to this issue

https://link.medium.com/Q9YrwZGaryb

Also @BlueWinds confirmed that is a root cause
SmartSelect_20230324_220014_Chrome

#9442

@romankhomitskyi
Copy link
Author

romankhomitskyi commented Mar 24, 2023

The reproduction is a running multiple cypress runner instances on the same machine, which is not recommended but anyway, they should not mutate each other

@emilyrohrbough emilyrohrbough added type: enhancement Requested enhancement of existing feature npm: @cypress/webpack-preprocessor @cypress/webpack-preprocessor package issues and removed topic: typescript Needs Reproduction labels Mar 30, 2023
@emilyrohrbough
Copy link
Member

emilyrohrbough commented Mar 30, 2023

@romankhomitskyi Yeah, Cypress is not setup out-of-the box to run in parallel on the same machine. The webpack output is assuming a single directory when leveraging the cypress/webpack-preprocessor and the way we load these processed files in, we assume the are already unique. The solution you posted is the correct path forward. I will flag as an enhacement for our team to consider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing npm: @cypress/webpack-preprocessor @cypress/webpack-preprocessor package issues topic: preprocessors 🔧 Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: enhancement Requested enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

4 participants