nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.62k stars 2.36k forks source link

Add Cypress Component Test as UnitTestRunner for libs/components #17616

Closed the-ult closed 1 year ago

the-ult commented 1 year ago

Description

With Cypress Component Testing getting more and more popular adn being used instead of a combination of jest with @testing-library/angular|react|etc, it would be great if Cypress Component test could be selected when creating a library or generating a (Angular/React/??) Component, instead of none | jest

For example. For our utils (and maybe Angular Pipes) we like to use Jest. But otherwise, with components, directives, etc. We like to use Cypress Component Tests. So it would be great to be able to select the proper (unit/Component)TestRunner

Suggested Implementation

Run the cypress component test configuration when creating a library. And/or run it when generating a new component and Cypress Component Tests is not yet setup.

barbados-clemens commented 1 year ago

Hi there, looking into this. it doesn't really make sense to make cypress component testing a 'unitTestRunner' option since it's not a unit test runner and cypress/jest are not mutually exclusive. i.e. you can have both jest and cypress within the same project.

this makes CT it's own thing. a 'componentTestRunner' if you will.

after talking with the team it doesn't seem like the right fit to add another testing option to generators which you can run 2 commands.

nx g lib --unitTestRunner=none
nx g cypress-component-configuration --project=<existing-project-name>

if this is a very common pattern for you then a custom generator to run this specific setup for you sounds like a good path to look.

https://nx.dev/plugins/recipes/local-generators#local-generators

the-ult commented 1 year ago

hi @barbados-clemens,

Thanks for looking into the suggestion and your response.

It was indeed meant more like a ComponentTestRunner, since (I think 🤔 ) most people who use Cypress Component Test Runner for their components, they won't use/need a Unit Test as well. (or Jest in combination with Testing-Library)

--

I need to create some overrides/custom generator for our libraries in the future. So I will look into it, to add your suggestion as well.

Thanks

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.