@nx/angular:component-test
Create a *.cy.ts
file for Cypress component testing for an Angular component.
Create a *.cy.ts
file for Cypress component testing for an Angular component.
Angular component testing with Nx requires Cypress version 10.7.0 and up.
You can migrate with to v10 via the migrate-to-cypress-10 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
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.
nx generate component-test ...
By default, Nx will search for component-test
in the default collection provisioned in workspace.json.
You can specify the collection explicitly as follows:
nx g @nx/angular:component-test ...
Show what will be generated without writing to disk:
nx g component-test ... --dry-run
Class name of the component to create a test for.
Relative path to the folder that contains the component from the project root.
File name that contains the component without the .ts
extension.
The name of the project where the component is located.
false
Skip formatting files.