Skip to content

Commit 9370680

Browse files
Merge pull request samvloeberghs#34 from samvloeberghs/electron
upgraded angularjs + added electron
2 parents cef61c3 + 2b76f19 commit 9370680

File tree

6 files changed

+146
-74
lines changed

6 files changed

+146
-74
lines changed

config/protractor.electron.conf.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
dirname = __dirname;
2+
require('ts-node/register');
3+
var helpers = require('./helpers');
4+
5+
console.log("dirname");
6+
console.log(dirname);
7+
8+
exports.config = {
9+
10+
11+
/**
12+
* Angular 2 configuration
13+
*
14+
* useAllAngular2AppRoots: tells Protractor to wait for any angular2 apps on the page instead of just the one matching
15+
* `rootEl`
16+
*
17+
*/
18+
useAllAngular2AppRoots: true,
19+
20+
baseUrl: 'http://localhost:3000',
21+
22+
allScriptsTimeout: 110000,
23+
24+
framework: 'custom',
25+
frameworkPath: require.resolve('protractor-cucumber-framework'),
26+
specs: [
27+
helpers.root('test/e2e/**/*.feature')
28+
],
29+
cucumberOpts: {
30+
require: [
31+
'test/e2e/**/*.steps.ts'
32+
],
33+
format: 'pretty'
34+
},
35+
36+
directConnect: true,
37+
38+
// THIS IS platform specific!!
39+
// Change the binary to where your electron is
40+
capabilities: {
41+
'browserName': 'chrome',
42+
'chromeOptions': {
43+
'binary': '/Users/samvloeberghs/.nvm/versions/node/v6.2.2/lib/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron',
44+
'args': ['app=.']
45+
}
46+
},
47+
48+
onPrepare: function () {
49+
browser.ignoreSynchronization = true;
50+
}
51+
52+
};

main.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const electron = require('electron');
2+
// Module to control application life.
3+
const app = electron.app;
4+
// Module to create native browser window.
5+
const BrowserWindow = electron.BrowserWindow;
6+
7+
// Keep a global reference of the window object, if you don't, the window will
8+
// be closed automatically when the JavaScript object is garbage collected.
9+
let mainWindow;
10+
11+
function createWindow () {
12+
// Create the browser window.
13+
mainWindow = new BrowserWindow({width: 1200, height: 500});
14+
15+
// and load the index.html of the app.
16+
mainWindow.loadURL('http://localhost:3000');
17+
18+
// Open the DevTools.
19+
// mainWindow.webContents.openDevTools({mode: 'detach'});
20+
21+
// Emitted when the window is closed.
22+
mainWindow.on('closed', function () {
23+
// Dereference the window object, usually you would store windows
24+
// in an array if your app supports multi windows, this is the time
25+
// when you should delete the corresponding element.
26+
mainWindow = null;
27+
})
28+
}
29+
30+
// This method will be called when Electron has finished
31+
// initialization and is ready to create browser windows.
32+
// Some APIs can only be used after this event occurs.
33+
app.on('ready', createWindow);
34+
35+
// Quit when all windows are closed.
36+
app.on('window-all-closed', function () {
37+
// On OS X it is common for applications and their menu bar
38+
// to stay active until the user quits explicitly with Cmd + Q
39+
if (process.platform !== 'darwin') {
40+
app.quit();
41+
}
42+
});
43+
44+
app.on('activate', function () {
45+
// On OS X it's common to re-create a window in the app when the
46+
// dock icon is clicked and there are no other windows open.
47+
if (mainWindow === null) {
48+
createWindow()
49+
}
50+
});
51+
52+
// In this file you can include the rest of your app's specific main process

package.json

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"contributors": [
77
"Dennis Jaamann <dennis@jman-consulting.be>"
88
],
9+
"main": "main.js",
910
"homepage": "https://github.com/samvloeberghs/protractor-gherkin-cucumberjs-angular2",
1011
"license": "MIT",
1112
"scripts": {
@@ -17,6 +18,7 @@
1718
"webdriver-manager": "webdriver-manager",
1819
"protractor": "protractor protractor.conf.js",
1920
"protractor:saucelabs": "protractor protractor.saucelabs.conf.js",
21+
"protractor:electron": "protractor protractor.electron.conf.js",
2022
"clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist",
2123
"clean:dist": "npm run rimraf -- dist",
2224
"preclean:install": "npm run clean",
@@ -43,6 +45,7 @@
4345
"pree2e": "npm run webdriver:update -- --standalone",
4446
"e2e": "npm run protractor",
4547
"e2e:saucelabs": "npm run protractor:saucelabs",
48+
"e2e:electron": "npm run protractor:electron",
4649
"e2e:live": "npm run e2e -- --elementExplorer",
4750
"test": "node --max-old-space-size=4096 node_modules/karma/bin/karma start",
4851
"ci": "npm run e2e && npm run test",
@@ -54,14 +57,14 @@
5457
"postversion": "git push && git push --tags"
5558
},
5659
"dependencies": {
57-
"@angular/common": "2.0.0",
58-
"@angular/compiler": "2.0.0",
59-
"@angular/core": "2.0.0",
60-
"@angular/forms": "2.0.0",
61-
"@angular/http": "2.0.0",
62-
"@angular/platform-browser": "2.0.0",
63-
"@angular/platform-browser-dynamic": "2.0.0",
64-
"@angular/router": "3.0.0",
60+
"@angular/common": "2.1.0",
61+
"@angular/compiler": "2.1.0",
62+
"@angular/core": "2.1.0",
63+
"@angular/forms": "2.1.0",
64+
"@angular/http": "2.1.0",
65+
"@angular/platform-browser": "2.1.0",
66+
"@angular/platform-browser-dynamic": "2.1.0",
67+
"@angular/router": "3.1.0",
6568
"core-js": "^2.4.1",
6669
"jquery": "^2.2.2",
6770
"lodash": "^4.7.0",
@@ -80,12 +83,15 @@
8083
"awesome-typescript-loader": "~2.2.1",
8184
"chai": "^3.5.0",
8285
"chai-as-promised": "^5.3.0",
83-
"codelyzer": "0.0.25",
86+
"codelyzer": "1.0.0-beta.2",
8487
"compression-webpack-plugin": "^0.3.0",
8588
"copy-webpack-plugin": "^1.1.1",
8689
"css-loader": "^0.23.1",
8790
"cucumber": "^1.3.0",
8891
"cucumber-tsflow": "^1.2.1",
92+
"electron": "^1.4.3",
93+
"electron-chromedriver": "^1.4.0",
94+
"electron-prebuilt": "^1.4.3",
8995
"exports-loader": "^0.6.3",
9096
"expose-loader": "^0.7.1",
9197
"file-loader": "^0.8.5",

protractor.electron.conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @AngularClass
2+
// look in ./config for protractor.saucelabs.conf.js
3+
exports.config = require('./config/protractor.electron.conf.js').config;

src/app/app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewEncapsulation } from '@angular/core';
1+
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
22

33
import { AppState } from './app.service';
44

@@ -14,7 +14,7 @@ import { AppState } from './app.service';
1414
encapsulation: ViewEncapsulation.None
1515
})
1616

17-
export class AppComponent {
17+
export class AppComponent implements OnInit {
1818

1919
constructor(public appState: AppState) {
2020
}

tslint.json

Lines changed: 22 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,29 @@
11
{
22
"rulesDirectory": [
3-
"node_modules/codelyzer/dist/src"
3+
"node_modules/codelyzer"
44
],
5-
"rules": {
5+
"rules":{
6+
"directive-selector-name": [true, "camelCase"],
67
"component-selector-name": [true, "kebab-case"],
8+
"directive-selector-type": [true, "attribute"],
79
"component-selector-type": [true, "element"],
8-
"host-parameter-decorator": true,
9-
"input-parameter-decorator": true,
10-
"output-parameter-decorator": true,
11-
"attribute-parameter-decorator": false,
12-
"input-property-directive": true,
13-
"output-property-directive": true,
14-
15-
"class-name": true,
16-
"curly": false,
17-
"eofline": true,
18-
"indent": [
19-
true,
20-
"spaces"
21-
],
22-
"max-line-length": [
23-
true,
24-
100
25-
],
26-
"member-ordering": [
27-
true,
28-
"public-before-private",
29-
"static-before-instance",
30-
"variables-before-functions"
31-
],
32-
"no-arg": true,
33-
"no-construct": true,
34-
"no-duplicate-key": true,
35-
"no-duplicate-variable": true,
36-
"no-empty": false,
37-
"no-eval": true,
38-
"trailing-comma": true,
39-
"no-trailing-whitespace": true,
40-
"no-unused-expression": true,
41-
"no-unused-variable": false,
42-
"no-unreachable": true,
43-
"no-use-before-declare": true,
44-
"one-line": [
45-
true,
46-
"check-open-brace",
47-
"check-catch",
48-
"check-else",
49-
"check-whitespace"
50-
],
51-
"quotemark": [
52-
true,
53-
"single"
54-
],
55-
"semicolon": true,
56-
"triple-equals": [
57-
true,
58-
"allow-null-check"
59-
],
60-
"variable-name": false,
61-
"whitespace": [
62-
true,
63-
"check-branch",
64-
"check-decl",
65-
"check-operator",
66-
"check-separator",
67-
"check-type"
68-
]
10+
"directive-selector-prefix": [true, "sv"],
11+
"component-selector-prefix": [true, "sv"],
12+
"use-input-property-decorator": true,
13+
"use-output-property-decorator": true,
14+
"use-host-property-decorator": true,
15+
"no-attribute-parameter-decorator": true,
16+
"no-input-rename": true,
17+
"no-output-rename": true,
18+
"no-forward-ref": true,
19+
"use-life-cycle-interface": true,
20+
"use-pipe-transform-interface": true,
21+
"pipe-naming": [true, "camelCase", "sg"],
22+
"component-class-suffix": true,
23+
"directive-class-suffix": true,
24+
"import-destructuring-spacing": true,
25+
"templates-use-public": true,
26+
"no-access-missing-member": true,
27+
"invoke-injectable": true
6928
}
7029
}

0 commit comments

Comments
 (0)