File tree Expand file tree Collapse file tree 6 files changed +99
-1
lines changed
Expand file tree Collapse file tree 6 files changed +99
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,18 @@ Based on the awesome [unit testing example](https://github.com/roblouie/unit-tes
55
66Clone repo, run ` npm install ` .
77
8+ Unit Tests
9+ ----------
10+
811To run the tests, run ` npm test ` .
912
1013See the example test in ` src/app/app.component.spec.ts ` for an example of a component test.
14+
15+ End-To-End Tests (Browser-Only)
16+ -------------------------------
17+
18+ To serve the app, run ` ionic serve ` .
19+
20+ To run the end-to-end tests, run (while the app is being served) ` npm run e2e ` .
21+
22+ See the example end-to-end test in ` e2e/app.e2e-spec.ts ` .
Original file line number Diff line number Diff line change 1+ import { Page } from './app.po' ;
2+
3+ describe ( 'App' , function ( ) {
4+ let page : Page ;
5+
6+ beforeEach ( ( ) => {
7+ page = new Page ( ) ;
8+ } ) ;
9+
10+ describe ( 'default screen' , ( ) => {
11+ beforeEach ( ( ) => {
12+ page . navigateTo ( '/' ) ;
13+ } ) ;
14+
15+ it ( 'should have a title saying Page One' , ( ) => {
16+ page . getTitle ( ) . then ( title => {
17+ expect ( title ) . toEqual ( 'Page One' ) ;
18+ } ) ;
19+ } ) ;
20+ } )
21+ } ) ;
Original file line number Diff line number Diff line change 1+ import { browser } from 'protractor' ;
2+
3+ export class Page {
4+
5+ navigateTo ( destination ) {
6+ return browser . get ( destination ) ;
7+ }
8+
9+ getTitle ( ) {
10+ return browser . getTitle ( ) ;
11+ }
12+
13+ }
Original file line number Diff line number Diff line change 1+ {
2+ "compileOnSave" : false ,
3+ "compilerOptions" : {
4+ "declaration" : false ,
5+ "emitDecoratorMetadata" : true ,
6+ "experimentalDecorators" : true ,
7+ "module" : " commonjs" ,
8+ "moduleResolution" : " node" ,
9+ "outDir" : " ../dist/out-tsc-e2e" ,
10+ "sourceMap" : true ,
11+ "target" : " es5" ,
12+ "typeRoots" : [
13+ " ../node_modules/@types"
14+ ]
15+ }
16+ }
Original file line number Diff line number Diff line change 88 "build" : " ionic-app-scripts build" ,
99 "ionic:build" : " ionic-app-scripts build" ,
1010 "ionic:serve" : " ionic-app-scripts serve" ,
11- "test" : " karma start ./test-config/karma.conf.js"
11+ "test" : " karma start ./test-config/karma.conf.js" ,
12+ "e2e" : " webdriver-manager update --standalone false --gecko false; protractor ./test-config/protractor.conf.js"
1213 },
1314 "dependencies" : {
1415 "@angular/common" : " 2.4.8" ,
3940 "angular2-template-loader" : " ^0.6.2" ,
4041 "html-loader" : " ^0.4.5" ,
4142 "jasmine" : " ^2.5.3" ,
43+ "jasmine-spec-reporter" : " ^3.2.0" ,
4244 "karma" : " ^1.5.0" ,
4345 "karma-chrome-launcher" : " ^2.0.0" ,
4446 "karma-jasmine" : " ^1.1.0" ,
4547 "karma-jasmine-html-reporter" : " ^0.2.2" ,
4648 "karma-sourcemap-loader" : " ^0.3.7" ,
4749 "karma-webpack" : " ^2.0.3" ,
4850 "null-loader" : " ^0.1.1" ,
51+ "protractor" : " ^5.1.1" ,
4952 "ts-loader" : " ^2.0.3" ,
53+ "ts-node" : " ^3.0.2" ,
5054 "typescript" : " 2.1.6"
5155 },
5256 "version" : " 0.0.1" ,
Original file line number Diff line number Diff line change 1+ // Protractor configuration file, see link for more information
2+ // https://github.com/angular/protractor/blob/master/lib/config.ts
3+
4+ /*global jasmine */
5+ var SpecReporter = require ( 'jasmine-spec-reporter' ) . SpecReporter ;
6+
7+ exports . config = {
8+ allScriptsTimeout : 11000 ,
9+ specs : [
10+ '../e2e/**/*.e2e-spec.ts'
11+ ] ,
12+ capabilities : {
13+ 'browserName' : 'chrome'
14+ } ,
15+ directConnect : true ,
16+ baseUrl : 'http://localhost:8100/' ,
17+ framework : 'jasmine' ,
18+ jasmineNodeOpts : {
19+ showColors : true ,
20+ defaultTimeoutInterval : 30000 ,
21+ print : function ( ) { }
22+ } ,
23+ useAllAngular2AppRoots : true ,
24+ beforeLaunch : function ( ) {
25+ require ( 'ts-node' ) . register ( {
26+ project : 'e2e'
27+ } ) ;
28+ } ,
29+ onPrepare : function ( ) {
30+ jasmine . getEnv ( ) . addReporter ( new SpecReporter ( ) ) ;
31+ }
32+ } ;
You can’t perform that action at this time.
0 commit comments