
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@cypress/schematic
Advanced tools
🔖 Official Angular Schematic and Builder for the Angular CLI.
This project is maintained by the Cypress Team.
Add this schematic to quickly get up and running with Cypress in your Angular project.
Once added to your project, it will:
✅ Install Cypress
✅ Add npm scripts for running Cypress e2e tests in run mode and open mode
✅ Scaffold base Cypress files and directories
✅ Provide the ability to add new e2e and component specs easily using ng-generate
✅ Optional: prompt you to add or update the default ng e2e command to use Cypress for e2e tests.
✅ Optional: prompt you to add a ng ct command to use Cypress component testing.
@cypress/schematic@2 supports Angular 13 - 16 and @cypress/schematic@3 supports Angular 17)To install the schematic via prompts:
ng add @cypress/schematic
To install the schematic via cli arguments (installs both e2e and component testing):
ng add @cypress/schematic --e2e --component
The installation will add this schematic to the default schematic collections. This allows you to execute the CLI commands without prefixing them with the package name.
To run Cypress in open mode within your project:
ng run {project-name}:cypress-open
To run Cypress headlessly via run mode within your project:
ng run {project-name}:cypress-run
If you have chosen to add or update the ng e2e command, you can also run Cypress in open mode using this:
ng e2e
If you have chosen to add Cypress component testing, you can run component tests in open mode using this:
ng run {project-name}:ct
To generate a new e2e spec file:
ng generate spec
or (without cli prompt)
ng generate spec {name}
To generate a new component spec file:
ng generate spec --component
or (without cli prompt)
ng generate spec {component name} --component
To generate a new component spec file in a specific folder:
ng generate spec {component name} --component --path {path relative to project root}
To generate new component spec files alongside all component files in a project:
ng generate specs-ct
To generate a new, generic component definition with a component spec file in the given or default project. This wraps the Angular CLI Component Generator and supports the same arguments.
ng generate component {component name}
Before running Cypress in open mode, ensure that you have started your application server using ng serve.
"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"watch": true,
"headless": false,
"browser": "chrome"
},
"configurations": {
"production": {
"devServerTarget": "{project-name}:serve:production"
}
}
}
Read our docs to learn more about launching browsers with Cypress.
We recommend setting your Cypress Cloud recording key as an environment variable and NOT as a builder option when running it in CI.
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "{project-name}:serve",
"record": true,
"key": "your-cypress-cloud-recording-key"
},
"configurations": {
"production": {
"devServerTarget": "{project-name}:production"
}
}
}
Read our docs to learn more about recording test results to Cypress Cloud.
It may be useful to have different Cypress configuration files per environment (ie. development, staging, production).
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "{project-name}:serve",
"configFile": "cypress.production.js"
},
"configurations": {
"production": {
"devServerTarget": "{project-name}:production"
}
}
}
Read our docs to learn more about all the configuration options Cypress offers.
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "{project-name}:serve",
"parallel": true,
"record": true,
"key": "your-cypress-cloud-recording-key"
},
"configurations": {
"production": {
"devServerTarget": "{project-name}:production"
}
}
}
Read our docs to learn more about speeding up test execution in CI via Cypress parallelization
You may want to specify a custom reporter. Cypress works with any reporters built for Mocha: built-in, third-party, or custom. In addition to specifying reporters, you can specify reporter options. These differ based on the reporter, and you should refer to its documentation for supported options.
"cypress-run": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "{project-name}:serve",
"reporter": "junit",
"reporterOptions": {
"mochaFile": "results/my-test-output.xml",
"toConsole": true
}
},
"configurations": {
"production": {
"devServerTarget": "{project-name}:production"
}
}
}
Read our docs to learn more about working with reporters.
You can specify a baseUrl that is different than the one in cypress.config.js. There are two ways to do this.
baseUrl to configurations like the following:"cypress-open": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "{project-name}:serve",
"watch": true,
"headless": false
},
"configurations": {
"production": {
"devServerTarget": "{project-name}:serve:production"
},
"local-dev": {
"devServerTarget": "{project-name}:serve:development",
"baseUrl": "http://localhost:4002"
},
"another-env": {
"devServerTarget": "{project-name}:serve:development",
"baseUrl": "http://localhost:4004"
}
}
}
devServerTarget in angular.json:"options": {
"host": "localhost",
"port": 4200
},
In order to prevent the application from building, add the following to the end of your command:
--dev-server-target=''
The default generated spec is E2E. In order to generate a component test you can run:
ng generate @cypress/schematic:spec --name=button -t component
-t is an alias for testing-type. It accepts e2e or component as arguments. If you are using the CLI tool, a prompt will appear asking which spec type you want to generate.
In order to bypass the prompt asking for your spec name add a --name= flag like this:
ng generate @cypress/schematic:spec --name=login
This will create a new spec file named login.cy.ts in the default Cypress folder location.
Add a --project= flag to specify the project:
ng generate @cypress/schematic:spec --name=login --project=sandbox
Add a --path= flag to specify the project:
ng generate @cypress/schematic:spec --name=login --path=src/app/tests
This will create a spec file in your specific location, creating folders as needed. By default, new specs are created in either cypress/e2e for E2E specs or cypress/ct for component specs.
You can scaffold component test specs alongside all your components in the default project by using:
ng generate @cypress/schematic:specs-ct -g
This will identify files ending in component.ts. It will then create spec files alongside them - if they don't exist.
If you would like to specify a project, you can use the command:
ng generate @cypress/schematic:specs-ct -g -p {project-name}
Read our migration guide to help you make the transition from Protractor to Cypress.
Visit our plugins discussion to ask questions or report issues related to this package.
This project is licensed under an MIT license.
The Cypress Angular Schematic package was made possible by the original work of the Briebug team and the contributors of @briebug/cypress-schematic.
@briebug/cypress-schematic served as the starting point for improvements and new functionality the Cypress team will continue to develop along with the community.
FAQs
Official Cypress schematic for the Angular CLI
The npm package @cypress/schematic receives a total of 92,722 weekly downloads. As such, @cypress/schematic popularity was classified as popular.
We found that @cypress/schematic demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.