Skip to content

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

Closed
@DamienCassou

Description

@DamienCassou

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

Activity

jennifer-shehane

jennifer-shehane commented on May 3, 2021

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

changed the title [-]No API to run Component tests[/-] [+]Allow component tests to be run via the module API[/+] on May 3, 2021
JessicaSachs

JessicaSachs commented on May 3, 2021

@JessicaSachs
Contributor

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({})
self-assigned this
on May 5, 2021

9 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: featureNew feature that does not currently exist

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @DamienCassou@agg23@jennifer-shehane@JessicaSachs

    Issue actions

      Allow component tests to be run via the module API · Issue #16302 · cypress-io/cypress