tnicola / cypress-parallel

Reduce up to 40% your Cypress suite execution time parallelizing the test run on the same machine.
MIT License
560 stars 117 forks source link

Spec files are not being split in different threads #152

Open jgonzalezalbisu opened 1 year ago

jgonzalezalbisu commented 1 year ago

When running tests using parallelization and the cypress-tags(https://www.npmjs.com/package/cypress-tags) library together, I see that the X executions are opened (x being the number of threads passed to the command with t) but both threads are executing the same things and specs are not being split in different threads.

Here is what I've got in my package.json:

"scripts": {
  "original-command": "CYPRESS_INCLUDE_TAGS=TAG1,TAG2,TAG3,TAG4 CYPRESS_EXCLUDE_TAGS=BROKEN,ARCHIVED,INPROGRESS npx cypress run --spec 'cypress/e2e/**/*.ts' --browser chrome",
  "parallel-command": "cypress-parallel -s original-command -t 2 -d '/cypress/e2e/**/*.ts'",
}

And when running the script parallel-command, I see that the the spec files are run in both threads and no splitting is being done. Am I missing something? Could it be cause it's the first run I'm doing and there is no weigh file?

Would you be able to help me?

Thanks!

lems3 commented 1 year ago

I started to use cypress parallel last week, and I had a similar issue. Turns out that setting spec and browser on the "original-command" as you do can cause issue.

Either remove those params from the original-command in your scripts or create a new command to use only with cypress-parallel. It should start behaving properly.

dthisner commented 1 year ago

@lems3 That seems to work, thank you :)

adoshi-branch commented 5 months ago

@lems3 any suggestions for me I'm hitting this same issue this is the command I'm using, This is a script that sits in the cypress directory and is referenced from my package.json as

"cy:runParallel": "python3 runParallel.py",

cypress-parallel -s cy:run -t {thread_count} -d \"cypress/e2e/*/.spec.ts\" " f"-a \" --browser chrome --headed --env grep={test_id_arguments} --spec '{formatted_file_paths}'\""

I am greping for specific strings, and I am passing in all the different spec files.

lems3 commented 5 months ago

@adoshi-branch I don't have a lot of experience with python, but I think you're facing the same limitation, where setting specs twice causes issues.

You'd need to find a way to only use the -d argument from cypress-parallel, as it will set cypress' --spec when running.

adoshi-branch commented 5 months ago

@lems3 thanks it looks like I need to find a way to combine both as -d should be the directory of where the tests are and the --spec is what specific spec files I'd like to run. If I find a solution I'll post back here.