cypress-parallel icon indicating copy to clipboard operation
cypress-parallel copied to clipboard

Spec files are not being split in different threads

Open jgonzalezalbisu opened this issue 2 years ago • 5 comments

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!

jgonzalezalbisu avatar Dec 28 '22 19:12 jgonzalezalbisu

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.

lems3 avatar Apr 03 '23 20:04 lems3

@lems3 That seems to work, thank you :)

dthisner avatar Apr 04 '23 16:04 dthisner

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

adoshi-branch avatar Jan 26 '24 05:01 adoshi-branch

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

lems3 avatar Jan 26 '24 13:01 lems3

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

adoshi-branch avatar Jan 26 '24 16:01 adoshi-branch