Skip to content

angular 2 project configured with unit and e2e reporting

License

Notifications You must be signed in to change notification settings

ppolavar/angular2

 
 

Repository files navigation

Angular 2 QuickStart With e2e and unit test reporting configured.

The basic scaffolding structue for this app is taken from angular2 Qucik start angular.io quickstart, and John papa angular basics.

Unit test and E2E are are extended with testing support form basic scaffolding structure and jasime and karma reporters spec reporters.

Install npm packages

Install the npm packages described in the package.json and verify that it works:

Attention Windows Developers: You must run all of these commands in administrator mode.

npm install
npm start

If the typings folder doesn't show up after npm install please install them manually with:

npm run typings -- install

The npm start command first compiles the application, then simultaneously re-compiles and runs the lite-server. Both the compiler and the server watch for file changes.

Shut it down manually with Ctrl-C.

npm scripts

Useful commands in npm scripts defined in the package.json:

  • npm start - runs the compiler and a server at the same time, both in "watch mode".
  • npm run tsc - runs the TypeScript compiler once.
  • npm run tsc:w - runs the TypeScript compiler in watch mode; the process keeps running, awaiting changes to TypeScript files and re-compiling when it sees them.
  • npm run lite - runs the lite-server, a light-weight, static file server, written and maintained by John Papa and Christopher Martin with excellent support for Angular apps that use routing.
  • npm run typings - runs the typings tool.
  • npm run postinstall - called by npm automatically after it successfully completes package installation. This script installs the TypeScript definition files this app requires. Here are the test related scripts:
  • npm test - compiles, runs and watches the karma unit tests
  • npm run e2e - run protractor e2e tests, written in JavaScript (*e2e-spec.js)[*make sure lite server is running for the e2e to work.]

Unit Tests

TypeScript unit-tests are usually in the app folder. Their filenames must end in .spec.

Look for the example app/components/app.component.spec.ts. Add more .spec.ts files as you wish; we configured karma to find them.

Run it with npm test

That command first compiles the application, then simultaneously re-compiles and runs the karma test-runner. Both the compiler and the karma watch for (different) file changes.

Shut it down manually with Ctrl-C.

End-to-end (E2E) Tests

E2E tests are in the e2e directory, side by side with the app folder. Their filenames must end in .e2e-spec.ts.

Look for the example e2e/app.e2e-spec.ts. Add more .e2e-spec.js files as you wish (although one usually suffices for small projects); protractor is configured to find them.

Thereafter, run them with npm run e2e.

That command first compiles, then simultaneously starts the Http-Server at localhost:3000 and launches protractor.

Shut it down manually with Ctrl-C.

alias npm-exec='PATH=$(npm bin):$PATH'

About

angular 2 project configured with unit and e2e reporting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 81.3%
  • TypeScript 8.5%
  • JavaScript 7.3%
  • HTML 2.9%