question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow component tests to be run via the module API

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
JessicaSachscommented, 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({})
0reactions
jennifer-shehanecommented, May 11, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module API - Cypress Documentation
cypress.run(). Runs Cypress tests via Node.js and resolve with all test results. See the Cypress Module API recipe.
Read more >
What is Component Testing Or Module Testing (Learn With ...
Component Testing is performed after unit testing. Components are tested as soon as they are created, so there are chances that the results ......
Read more >
Component testing scenarios - Angular
The waitForAsync() utility hides some asynchronous boilerplate by arranging for the tester's code to run in a special async test zone. You don't...
Read more >
Testing Components depending on Services - Testing Angular
How to write unit and integration tests for Components with Service dependencies.
Read more >
API Testing: Approaches, Tools, and Frameworks - AltexSoft
Usually, API testing is performed on APIs produced by the in-house development team. We don't test third-party APIs, but we can test the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found