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.
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.
The Jasmine test framework provides everything needed to write basic tests. It ships with an HTML test runner that executes tests in the browser.
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 npm test
to Compile and run it in karma from the command line.
-
npm test it will open the karma browser window
-
Click the DEBUG button; it opens a new browser tab and re-runs the tests.
-
Open the browser's
Developer Tools
-
Pick the
sources
section. -
Open the
app.component.spec.ts
test file -
Set a breakpoint in the test.
-
Refresh the browser, and it stops at the breakpoint.
-
Install
Node.js 6.10
or higher -
Install
Angular Cli
-
Run
npm install
to install app dependencies -
Run
ng serve
in a separate terminal window to build the TypeScript, watch for changes and launch the web serverhttp://localhost:4200/
. -
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.
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.