Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Commit

Permalink
Add Protractor E2E-Testing with sample
Browse files Browse the repository at this point in the history
  • Loading branch information
about-code committed Sep 16, 2017
1 parent 2c7075f commit 05cf27d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {browser, by} from 'protractor';

describe('AppComponent', () => {

it('should display "Welcome Home"', (done) => {
browser.get('http://localhost:8080<%= app_ctx_root %>');
browser
.findElement(by.xpath('.//h1'))
.then(el => el.getText())
.then(innerText => {
expect(innerText).toBe('Welcome Home', 'Wrong inner text. Did HomeViewComponent-Template change?');
done();
})
.catch((err) => {
fail(err);
done();
});
});
});
6 changes: 6 additions & 0 deletions templates/files-project-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@
## Library development (TBD)


## Testing

### End-To-End / UI-Testing

1. Before you run tests the very first time: `npm run webdriver-manager update`
1. Run Application (console 1): `npm start`
1. Run Selenium Server locally (console 1): `npm run selenium`
1. Run Tests locally (console 2): `npm run test-e2e`
35 changes: 35 additions & 0 deletions templates/files-project-package/config/protractor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
let path = require('path');

// An example configuration file
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
seleniumArgs: [],
jvmArgs: [],
// Capabilities to be passed to the webdriver instance.
capabilities: {
browserName: 'chrome'
},

// Spec patterns are relative to the configuration file location passed
// to protractor (in this example conf.js).
// They may include glob patterns.
specs: [
'../src/**/*e2e.{ts,js}',
'../packages/**/*e2e.{ts,js}'
],

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
defaultTimeoutInterval: 15000
},

beforeLaunch: function() {
require('ts-node').register({
project: path.resolve(__dirname, '../'),
compiler: 'typescript'
});
}
};

7 changes: 6 additions & 1 deletion templates/files-project-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@
"karma-jasmine": "^1.1.0",
"karma-webpack": "^2.0.4",
"lerna": "^2.1.2",
"protractor": "^5.1.2",
"node-sass": "^4.5.3",
"raw-loader": "^0.5.1",
"run-sequence": "^1.2.2",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"typescript": "^2.2.2",
"ts-node": "^3.3.0",
"webpack": "^3.4.0",
"webpack-dev-server": "^2.7.1",
"webpack-merge": "^4.1.0"
Expand All @@ -54,8 +56,11 @@
"develop": "webpack-dev-server --config ./config/webpack.dev.js --progress",
"lerna": "lerna",
"linter-fix": "tslint --fix --project='./tslint.json' --type-check",
"selenium": "webdriver-manager start",
"start": "webpack-dev-server --config ./config/webpack.prod.js --progress --watch=true",
"test": "./node_modules/karma/bin/karma start ./config/karma.conf.js"
"test": "./node_modules/karma/bin/karma start ./config/karma.conf.js",
"test-e2e": "protractor ./config/protractor.js",
"webdriver-manager": "webdriver-manager"
},
"author": "<%= pkg_author %>",
"license": "SEE LICENSE IN LICENSE.txt"
Expand Down

0 comments on commit 05cf27d

Please sign in to comment.