Angular with Testim

🚧

TDK Feature

This is not supported in Testim's visual editor.

250

Testim ❤️ Angular, the superheroic framework. We use Angular in several of our internal codebases and testing Angular and AngularJS is a supported use case with TDK.

Adding Tests to my Angular Project

Adding tests should typically be done rather early in Angular and AngularJS. It is encouraged to write unit tests for the majority of your logic and use Testim to test end to end-user flows.

Without the Angular CLI - Angular/AngularJS

Without the Angular CLI you can initialize Testim like you would for any other non-angular project. You would follow the instructions shown in getting started and create a new project.

With the Angular CLI

You probably have an e2e folder in your project containing protractor and the CLI generated test configuration. We would recommend you either keep it if you have useful tests there and add a second testim or remove it if you are not using it.

Other than that follow getting started and create a new project.

Sharing Code between Angular and TypeScript

You can share code between your Angular codebase and your Testim codebase.

This has the advantage of letting you share code between the test project and the main project which has positive consequences (less code) and negative ones (you are no longer writing black box tests).

In your initialized TDK code can require Angular code if you do the following things:

  • TDK accepts a webpack config with the --webpack-config option.
  • Assuming you are using TypeScript in your Angular code initialize Testim with TypeScript enabled.
  • Create a tsconfig.json file in your project root that "extends": '../tsconfig.json' to reuse all your TypeScript configuration from your Angular project.
  • That should be it!

This is possible regardless of whether or not you used the Angular CLI to generate the project or not.