/Angular-4-protractor-karma-testing-demo

Angular 4 protractor karma testing demo

Primary LanguageTypeScriptMIT LicenseMIT

Angular-4-protractor-karma-testing-demo

Angular 4 protractor karma testing demo

Angular Cli in Angular 4 + Material 2.0 +webpack 2.0.

Used Material 2.0 and Angular Flex Layout.

Protractor

Use protractor to write and run end-to-end (e2e) tests. End-to-end tests explore the application as users experience it. In e2e testing, one process runs the real application and a second process runs protractor tests that simulate user behavior and assert that the application respond in the browser as expected.

Jasmine

The Jasmine test framework provides everything needed to write basic tests. It ships with an HTML test runner that executes tests in the browser.

Karma

The karma test runner is ideal for writing and running unit tests while developing the application. It can be an integral part of the project's development and continuous integration processes. This guide describes how to set up and run tests with karma.

Run with karma

Run npm test to Compile and run it in karma from the command line.

karma debugging

  1. npm test it will open the karma browser window

  2. Click the DEBUG button; it opens a new browser tab and re-runs the tests.

  3. Open the browser's Developer Tools

  4. Pick the sources section.

  5. Open the app.component.spec.ts test file

  6. Set a breakpoint in the test.

  7. Refresh the browser, and it stops at the breakpoint.

Running the Application

  1. Install Node.js 6.10 or higher

  2. Install Angular Cli

  3. Run npm install to install app dependencies

  4. Run ng serve in a separate terminal window to build the TypeScript, watch for changes and launch the web server http://localhost:4200/.

  5. if your already using port 4200 you can run ng serve --port xxxx command to specify your own port

This project was generated with Angular CLI version 1.0.0.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Project Screenshot

1 2 3 4