co-IT/schematics

Add integration tests

Closed this issue · 3 comments

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

This is how kevinschuchard is doing it according to his blog: https://www.kevinschuchard.com/blog/2018-11-20-schematic-sandbox/

Steps to manually test our schematics:

  1. run yarn link from root folder
  2. change to any other Angular project's root folder and run yarn link @co-it/schematics
  3. Run ng generate @co-it/schematics:commitlint (or use any other schematic name) from within that test Angular project

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