From 0c11df34bd6c5373f234bef25f3ecc59c65286ef Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sat, 8 Apr 2017 05:24:55 +0200 Subject: [PATCH] Basic protractor setup incl. example test --- .../e2e/example/example.e2e-spec.ts | 19 ++++++++++++ project-manager/e2e/tsconfig.e2e.json | 12 ++++++++ project-manager/package.json | 2 ++ project-manager/protractor.conf.js | 30 +++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 project-manager/e2e/example/example.e2e-spec.ts create mode 100644 project-manager/e2e/tsconfig.e2e.json create mode 100644 project-manager/protractor.conf.js diff --git a/project-manager/e2e/example/example.e2e-spec.ts b/project-manager/e2e/example/example.e2e-spec.ts new file mode 100644 index 0000000..fe2b630 --- /dev/null +++ b/project-manager/e2e/example/example.e2e-spec.ts @@ -0,0 +1,19 @@ +import {browser, element, by} from 'protractor' + +describe('angularjs homepage todo list', function() { + it('should add a todo', function() { + browser.get('https://angularjs.org'); + + element(by.model('todoList.todoText')).sendKeys('write first protractor test'); + element(by.css('[value="add"]')).click(); + + var todoList = element.all(by.repeater('todo in todoList.todos')); + expect(todoList.count()).toEqual(3); + expect(todoList.get(2).getText()).toEqual('write first protractor test'); + + // You wrote your first test, cross it off the list + todoList.get(2).element(by.css('input')).click(); + var completedAmount = element.all(by.css('.done-true')); + expect(completedAmount.count()).toEqual(2); + }); +}); diff --git a/project-manager/e2e/tsconfig.e2e.json b/project-manager/e2e/tsconfig.e2e.json new file mode 100644 index 0000000..83ca6b0 --- /dev/null +++ b/project-manager/e2e/tsconfig.e2e.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es6", + "types":[ + "jasmine", + "node" + ] + } +} diff --git a/project-manager/package.json b/project-manager/package.json index ce07f8a..8f01959 100644 --- a/project-manager/package.json +++ b/project-manager/package.json @@ -45,10 +45,12 @@ "codelyzer": "~2.0.0-beta.1", "concurrently": "^2.0.0", "jasmine-core": "^2.5.2", + "jasmine-spec-reporter": "^3.2.0", "karma": "^1.5.0", "karma-chrome-launcher": "^2.0.0", "karma-jasmine": "^1.1.0", "karma-spec-reporter": "0.0.30", + "protractor": "^5.1.1", "ts-node": "1.2.1", "tslint": "^4.3.0", "typescript": "~2.2.1" diff --git a/project-manager/protractor.conf.js b/project-manager/protractor.conf.js new file mode 100644 index 0000000..1c5e1e5 --- /dev/null +++ b/project-manager/protractor.conf.js @@ -0,0 +1,30 @@ +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +const { SpecReporter } = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + beforeLaunch: function() { + require('ts-node').register({ + project: 'e2e/tsconfig.e2e.json' + }); + }, + onPrepare() { + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +};