tnicola / cypress-parallel

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

Compatibility with cypress-cucumber-preprocessor #23

Open zamioku opened 3 years ago

zamioku commented 3 years ago

Hi,

I just wanted to ask if there could be some compatibility added to the cypress-tags command from the cypress-cucumber-preprocessor plugin. From what I've noticed running parallel on a cypress-tags command will not actually run anything in parallel (execution time stay the same even with 100+ tests) and also the .json report files don't get generated for any of the specs. I don't really understand the mechanism behind this parallelization, but since cypress-tags is a wrapper of the cypress run command, I would assume it could also work in parallel.

Cucumber is very popular and the cy-cucumber-preprocessor plugin is used on a lot of projects I've seen, so I think it would be great if there was any support for it in parallel execution.

prasanmgc commented 3 years ago

I am using cypress-cucumber-preprocessor and figured out to configure this plugin.

Cypress.json { "baseUrl": "https://google.com", "env": { "TAGS": "not @ignore", "environment": "staging" } }

Below are the changes required in the plugin code 'cli.js'.

splitting by space will create problem for cucumber tags, as tags will contain spaces. i.e. TAGS='@ui-smoke and not @abc_ui and not @ignore'. so we need to allow arguments to be comma-separated and shouldn't split the args by space.

Place 1: const CY_SCRIPT_ARGS = argv.args ? [argv.args.trim()] : [];

Place 2: const child = spawn(pckManager, [ 'run', ${CY_SCRIPT}, isYarn ? '' : '--', '--reporter', 'cypress/support/helpers/json-stream-reporter.js', '--spec', command.tests, **'--env',** ...CY_SCRIPT_ARGS ]);

once this is done, you can pass the tags as arguments cypress-parallel -s test:run:headless -t 5 -d 'cypress/integration/specs/ui' -a CYPRESS_baseUrl='https://www.google.com',TAGS='@ui-smoke and not @abc_ui and not @ignore',environment='staging'

Have tested and it is working as expected. Hope this helps. @tnicola Could you please implement the above changes and publish it?

LukasLewandowski commented 1 year ago

Any update on this one? Can we use this plugin to execute Cypress Cucumber tests using tags? CC @tnicola

LukasLewandowski commented 9 months ago

I did some experimenting and current cypress-parallel and cypress-cucumber-preprocessor are working together. You can start tests by filtering them using tags.

"cy:single": "cypress run --env name=local,TAGS='@sanity'" "cy:parallel": "cypress-parallel -s cy:single -t 2 -d cypress/e2e/tryMe -m false",