nx/packages/angular/docs/component-test-examples.md
Leosvel Pérez Espinosa 2b820a274e
docs(misc): update /packages/ links to /nx-api/ (#26128)
- Update `/packages/` links to `/nx-api/`
- Convert some unneeded absolute links to relative
- Remove leftover examples doc for the already removed `cypress-project`
generator

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #26126
2024-05-28 09:44:48 -04:00

1.5 KiB

{% callout type="caution" title="Can I use component testing?" %} Angular component testing with Nx requires Cypress version 10.7.0 and up.

You can migrate with to v11 via the migrate-to-cypress-11 generator.

This generator is for Cypress based component testing.

If you're wanting to create Cypress tests for a Storybook story, then check out the component-cypress-spec generator docs

If you're wanting to create Storybook stories for a component, then check out the stories generator docs or component-story generator docs {% /callout %}

This generator is used to create a Cypress component test file for a given Angular component.

nx g @nx/angular:component-test --project=my-cool-angular-project --componentName=CoolBtnComponent --componentDir=src/cool-btn --componentFileName=cool-btn.component

Test file are generated with the .cy.ts suffix. this is to prevent colliding with any existing .spec. files contained in the project.

It's currently expected the generated .cy.ts file will live side by side with the component. It is also assumed the project is already setup for component testing. If it isn't, then you can run the cypress-component-project generator to set up the project for component testing.