diff --git a/commands/initial/templates/e2e/example.e2e-spec.ts b/commands/initial/templates/e2e/example.e2e-spec.ts new file mode 100644 index 0000000..057f689 --- /dev/null +++ b/commands/initial/templates/e2e/example.e2e-spec.ts @@ -0,0 +1,10 @@ +import {examplePo} from './page-objects/example.po'; + +describe('Example Page', () => { + + beforeEach(() => examplePo.go()); + + it('should welcome user to the example page', () => { + expect(examplePo.welcome.getText()).toBe('Welcome'); + }); +}); \ No newline at end of file diff --git a/commands/initial/templates/e2e/page-objects/example.po.ts b/commands/initial/templates/e2e/page-objects/example.po.ts new file mode 100644 index 0000000..e1432a0 --- /dev/null +++ b/commands/initial/templates/e2e/page-objects/example.po.ts @@ -0,0 +1,12 @@ +import {by, element, browser} from 'protractor'; + +class ExamplePo { + + welcome = element(by.className('welcome')); + + go() { + browser.get('/'); + } +} + +export const examplePo = new ExamplePo(); \ No newline at end of file diff --git a/commands/initial/templates/e2e/tsconfig.e2e.json b/commands/initial/templates/e2e/tsconfig.e2e.json new file mode 100644 index 0000000..9f3ab07 --- /dev/null +++ b/commands/initial/templates/e2e/tsconfig.e2e.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "node" + ] + } +} \ No newline at end of file diff --git a/commands/initial/templates/examples/example.component.html b/commands/initial/templates/examples/example.component.html new file mode 100644 index 0000000..52851fc --- /dev/null +++ b/commands/initial/templates/examples/example.component.html @@ -0,0 +1 @@ +
Welcome
\ No newline at end of file diff --git a/commands/initial/templates/package.json b/commands/initial/templates/package.json index df6f4d8..832a0bb 100644 --- a/commands/initial/templates/package.json +++ b/commands/initial/templates/package.json @@ -15,7 +15,9 @@ "prebuild": "rimraf dist out-tsc", "start": "webpack-dev-server --open --config ./webpack/webpack.dev.js", "tagVersion": "np --no-publish", - "test": "node ./tasks/test" + "test": "node ./tasks/test", + "pree2e": "webdriver-manager update", + "e2e": "protractor" }, "keywords": [], "author": "", @@ -46,7 +48,7 @@ "html-webpack-plugin": "^2.19.0", "istanbul-instrumenter-loader": "^1.2.0", "jasmine-core": "2.5.2", - "jasmine-spec-reporter": "2.5.0", + "jasmine-spec-reporter": "^4.1.1", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-coverage-istanbul-reporter": "^1.3.0", @@ -57,6 +59,7 @@ "node-sass": "^4.1.1", "np": "^2.12.0", "phantomjs-prebuilt": "^2.1.7", + "protractor": "^5.1.2", "raw-loader": "^0.5.1", "rimraf": "^2.5.3", "rollup": "0.43.0", @@ -67,6 +70,7 @@ "semver": "5.3.0", "source-map-loader": "^0.1.5", "style-loader": "^0.13.1", + "ts-node": "^3.2.0", "tslint": "^4.0.2", "tslint-loader": "^3.3.0", "typescript": "~2.2.1", diff --git a/commands/initial/templates/protractor.conf.js b/commands/initial/templates/protractor.conf.js new file mode 100644 index 0000000..581364c --- /dev/null +++ b/commands/initial/templates/protractor.conf.js @@ -0,0 +1,39 @@ +const {SpecReporter} = require('jasmine-spec-reporter'); +const WebpackDevServer = require('webpack-dev-server'); +const webpack = require('webpack'); +const config = require('./webpack/webpack.dev'); + +const PORT = 9001; + +exports.config = { + allScriptsTimeout: 5000, + specs: [ + './e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: `http://localhost:${PORT}/`, + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000 + }, + beforeLaunch() { + return new Promise(resolve => { + let compiler = webpack(config); + compiler.plugin('done', resolve); + new WebpackDevServer(compiler, { + disableHostCheck: true + }).listen(PORT, 'localhost'); + }); + }, + onPrepare() { + require('ts-node').register({ + project: 'e2e/tsconfig.e2e.json' + }); + + jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}})); + } +}; diff --git a/commands/initial/templates/webpack/webpack.dev.js b/commands/initial/templates/webpack/webpack.dev.js index 70ad913..e941195 100644 --- a/commands/initial/templates/webpack/webpack.dev.js +++ b/commands/initial/templates/webpack/webpack.dev.js @@ -29,7 +29,6 @@ module.exports = webpackCommon('dev', { devtool: 'cheap-module-eval-source-map', entry: { app: [ examplePath('example.main') ], - scripts: [], vendor: [ webpackUtils.srcPath('vendor') ], styles: [ examplePath('styles.scss') ] },