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

feat(component-testing): Expose CT through CLI module API #16368

Merged
merged 13 commits into from
May 7, 2021

Conversation

agg23
Copy link
Contributor

@agg23 agg23 commented May 6, 2021

User facing changelog

Allows launching Component Testing through the CLI module API. This provides for programmatic access to the CT runner.

// 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({})

Additional details

Slightly cleaned up the current CLI implementation of Component Testing. Expect further work on this front.

PR Tasks

@agg23 agg23 requested a review from a team as a code owner May 6, 2021 13:18
@agg23 agg23 requested review from kuceb and removed request for a team May 6, 2021 13:18
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 6, 2021

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented May 6, 2021



Test summary

13767 0 164 5Flakiness 0


Run details

Project cypress
Status Passed
Commit e330e25
Started May 7, 2021 4:47 PM
Ended May 7, 2021 4:58 PM
Duration 11:17 💡
OS Linux Debian - 10.8
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, mostly stylistic - the actual functionality looks good.

Maybe we can change one of the examples in npm/react to launch via the module api as a test?

cli/lib/exec/open.js Outdated Show resolved Hide resolved
Copy link
Contributor

@JessicaSachs JessicaSachs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, one minor comment. How do I manually test the module API?

cli/types/cypress-npm-api.d.ts Outdated Show resolved Hide resolved
@agg23
Copy link
Contributor Author

agg23 commented May 6, 2021

My testing was done with:

/* @ts-ignore */
import cypress from '../../cli/lib/cypress'

const run = cypress.run as (options?: Partial<CypressCommandLine.CypressRunOptions>) => Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>

run({
  spec: './cypress/component/advanced/framer-motion/Motion.spec.tsx',
  testingType: 'component',
  /* @ts-ignore */
  dev: true,
}).then(results => {
  console.log(results)
})

@JessicaSachs
Copy link
Contributor

My testing was done with:

/* @ts-ignore */
import cypress from '../../cli/lib/cypress'

const run = cypress.run as (options?: Partial<CypressCommandLine.CypressRunOptions>) => Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>

run({
  spec: './cypress/component/advanced/framer-motion/Motion.spec.tsx',
  testingType: 'component',
  /* @ts-ignore */
  dev: true,
}).then(results => {
  console.log(results)
})

I kinda want this documented in the CONTRIBUTING.md, yknow? You didn't know how to test it either.

@agg23
Copy link
Contributor Author

agg23 commented May 6, 2021

Done. See /cli/README.md

Copy link
Contributor

@elevatebart elevatebart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (we could have use the existing isComponentTesting flag but it felt odd)

@JessicaSachs JessicaSachs merged commit b8527a2 into develop May 7, 2021
tgriesser added a commit that referenced this pull request May 10, 2021
* develop:
  remove unused deps from webpack-preprocessor (#16384)
  feat: exclude html pwa plugin in webpack dev server (#16388)
  fix(ui): display duplicate aliases in command log (#16382)
  fix(ui): show req stub/fn when a handler is supplied (#16383)
  feat(component-testing): Expose CT through CLI module API (#16368)
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 10, 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.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow component tests to be run via the module API
4 participants