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

Allow component tests to be run via the module API #16302

Closed
DamienCassou opened this issue May 3, 2021 · 5 comments · Fixed by #16368
Closed

Allow component tests to be run via the module API #16302

DamienCassou opened this issue May 3, 2021 · 5 comments · Fixed by #16368
Assignees
Labels
type: feature New feature that does not currently exist

Comments

@DamienCassou
Copy link

Current behavior

We start our Cypress tests by using the Cypress module API. This has worked fine for us until the release Cypress 7 and its Component Test Runner. We don't know how to run the component tests from the API anymore.

Desired behavior

I expect to be able to write cypress.runCT({...}) in my JS script to run the component tests.

Versions

Cypress 7.2.0

@jennifer-shehane jennifer-shehane added component testing type: feature New feature that does not currently exist stage: proposal 💡 No work has been done of this issue labels May 3, 2021
@jennifer-shehane
Copy link
Member

Yeah, this is a good idea. We'll have to work through the specifics on what the API will look like to run component tests via the Module API.

@jennifer-shehane jennifer-shehane changed the title No API to run Component tests Allow component tests to be run via the module API May 3, 2021
@JessicaSachs
Copy link
Contributor

JessicaSachs commented May 3, 2021

Hey @DamienCassou, thanks for the issue report! I proposed an API below. Looking for input before going ahead and scheduling this work. @brian-mann, any changes needed here?

Motivation

Passing testingMode within the Cypress module API's options would allow the user to swap between cypress run and cypress run-ct from within node.

Proposed API

We'll do an options-object approach and pass that through to run/open. Since 7.x we have the concept of testingType.

Cypress's module API is options-based, so we should continue that pattern and add another property to the options object. The property testingType is already used within Cypress internally and exposed on the Cypress config object. Currently, testingType's main use is within the plugins file to support users that run both CT + E2E. It allows users to swap between Component-only plugins and E2E-only plugins. I think it makes sense to use it within the Cypress module API as well.

We would extend the existing options defined in the module API docs with the following:

Property: testingType
Valid values: e2e, component
Default: e2e

// Run/open Component testing
cypress.run({ testingType: 'component' })
cypress.open({ testingType: 'component' })

// Run/open E2E testing
cypress.run({ testingType: 'e2e' })
cypress.open({ testingType: 'e2e' })

// Defaults to e2e
cypress.run({})
cypress.open({})

@agg23 agg23 self-assigned this May 5, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: proposal 💡 No work has been done of this issue stage: needs review The PR code is done & tested, needs review stage: work in progress labels May 6, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 7, 2021

The code for this is done in cypress-io/cypress#16368, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label May 7, 2021
@DamienCassou
Copy link
Author

I think it has been release in 7.3.0.

@jennifer-shehane
Copy link
Member

Released in 7.3.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.3.0, please open a new issue.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature New feature that does not currently exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants