Cypress Angular Schematic
Add Cypress to an Angular CLI project
This schematic will:
- install Cypress, its dependencies, and new scripts
- add necessary files for Cypress to work with Angular & Typescript
- prompt for removal of Protractor files and configuration
🚀
Usage Run as one command in an Angular CLI app directory. Note this will add the schematic as a dependency to your project.
ng add @briebug/cypress-schematic
With the custom builder installed, you can run cypress with the following commands:
ng e2e
ng run {your-project-name}:cypress-open
These two commands do the same thing. They will launch the (Electron) Cypress Test Runner in watch mode.
ng run {your-project-name}:cypress-run
This command will open the (Electron) Cypress Test Runner and run your tests one time, with output to your terminal.
Options
Option | Description |
---|---|
addCypressTestScripts | This will add Cypress open and run command scripts to your package.json . Include --addCypressTestScripts in your ng add command. |
noBuilder | This will skip the builder addition, leaving the angular.json file unmodified and requiring you to run Cypress from the command line or through your IDE. Include --noBuilder in your ng add command. |
Issues
Issues with this schematic can be filed here.
If you want to contribute (or have contributed in the past), feel free to add yourself to the list of contributors in the package.json
before you open a PR!
🛠
Development Getting started
npm i && cd sandbox && npm i && cd ..
npm run link:sandbox
npm run build:clean:launch
E2E testing
Execute the schematic against the sandbox. Then run linting, unit & e2e tests and a prod build in the sandbox.
npm run test
Unit Testing
Run the unit tests using Jasmine as a runner and test framework.
npm run test:unit
Reset the sandbox
Running the schematic locally makes file system changes. The sandbox is version controlled so that viewing a diff of the changes is trivial. After the schematic has run locally, reset the sandbox with the following.
npm run clean