Add integration tests
Closed this issue · 3 comments
Markus-Ende commented
We should add integration tests that run schematics and check if the resulting file tree is correct.
Resources
Example of how the Angular CLI itself does this can be found here: https://github.com/angular/angular-cli/tree/master/tests/legacy-cli/e2e
Other examples of integration tests of Angular:
https://github.com/angular/angular/tree/master/integration
Containing the bazel-schematics integration test:
https://github.com/angular/angular/blob/master/integration/bazel-schematics/test.sh
CLI e2e Tests
Markus-Ende commented
This is how kevinschuchard is doing it according to his blog: https://www.kevinschuchard.com/blog/2018-11-20-schematic-sandbox/
Markus-Ende commented
Steps to manually test our schematics:
- run
yarn link
from root folder - change to any other Angular project's root folder and run
yarn link @co-it/schematics
- Run
ng generate @co-it/schematics:commitlint
(or use any other schematic name) from within that test Angular project
GregOnNet commented
Thoughts
- Generate new Angular project with the current version of the CLI
- Link built schematics into the generated project
- Specify which commands should be executed (A command can be the schematic command itself or an npm script)
- Provide an API asserting the expected console output
- Use Git to rollback the changes done by the command