Skip to content

Commit 2840071

Browse files
author
Evgeny Barabanov
authored
E2e testing support (#3)
* First e2e test * Create basic test for native strings Move shared code to utils Remove Web e2e stuff * Hot-fix * Initial travis-ci yaml for linux * Rename travis.yml * Update to node 8 * disable cache for a little while * Get caching back Fix webpack paths * Disable cache * Fix node version * Fix electron-builder config * Fix electron-builder config * Fix image name for linux * Enlarge build timeout * Try other language * Remove enlarged timeout * Add windows build file * Fix appveyor * Temp workaround for node-gyp * Hot fix * Try to fix appveyor * Temp workaround for node-gyp * Temp workaround for node-gyp * Temp workaround for node-gyp * Remove explicit version set to python * Increase timeout * Wait until window is loaded before accessing elements * Change artifact name * Post-merge fixes * Fix clean script * Remove problematic test
1 parent 7d63451 commit 2840071

File tree

11 files changed

+4016
-3641
lines changed

11 files changed

+4016
-3641
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,22 @@ addons:
2222
apt:
2323
packages:
2424
- icnsutils
25+
- graphicsmagick
26+
- libgnome-keyring-dev
27+
- xz-utils
28+
- xorriso
29+
- xvfb
2530

2631
install:
2732
- npm install
33+
- export DISPLAY=':99.0'
34+
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
35+
36+
before_script:
37+
- export DISPLAY=:99.0
38+
- sh -e /etc/init.d/xvfb start &
39+
- sleep 3
2840

2941
script:
3042
- npm run dist
43+
- npm run e2e

appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ platform:
77
- x86
88
- x64
99

10+
cache:
11+
- node_modules
12+
1013
install:
1114
- ps: Install-Product node LTS $env:platform
1215
- npm config set msvs_version 2015
@@ -16,3 +19,4 @@ build: off
1619

1720
test_script:
1821
- '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER && npm run dist"'
22+
- '%BASH% -lc "cd $APPVEYOR_BUILD_FOLDER && npm run e2e"'

e2e/app.e2e-spec.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

e2e/app.po.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

e2e/common/spectron-utils.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {Application} from 'spectron';
2+
import * as path from 'path';
3+
4+
const SpectronApplication = require('spectron').Application;
5+
const chaiAsPromised = require('chai-as-promised');
6+
const chai = require('chai');
7+
8+
chai.should();
9+
chai.use(chaiAsPromised);
10+
11+
const platformToExtension = {
12+
'win32': 'exe',
13+
'linux': 'AppImage',
14+
'darwin': 'dmg'
15+
};
16+
17+
export class SpectronUtils {
18+
public static app = new SpectronApplication({
19+
// Your electron path can be any binary
20+
// i.e for OSX an example path could be '/Applications/MyApp.app/Contents/MacOS/MyApp'
21+
// But for the sake of the example we fetch it from our node_modules.
22+
path: `build-artifacts/ElectronAngularNativeApp.${platformToExtension[process.platform]}`,
23+
args: [path.join(__dirname, '../..')],
24+
});
25+
26+
static describe(desc: string, describeFunction: (app: Application) => void) {
27+
28+
describe(desc, function () {
29+
this.timeout(20000);
30+
31+
before(() => {
32+
return SpectronUtils.app.start();
33+
});
34+
35+
describeFunction(SpectronUtils.app);
36+
37+
after(() => {
38+
if (SpectronUtils.app && SpectronUtils.app.isRunning()) {
39+
return SpectronUtils.app.stop();
40+
}
41+
});
42+
});
43+
}
44+
}
45+
46+
chaiAsPromised.transferPromiseness = SpectronUtils.app.transferPromiseness;

e2e/sanity.e2e-spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {SpectronUtils} from './common/spectron-utils';
2+
3+
const chaiAsPromised = require('chai-as-promised');
4+
const chai = require('chai');
5+
6+
chai.should();
7+
chai.use(chaiAsPromised);
8+
9+
SpectronUtils.describe('Application launch', app =>
10+
it('shows an initial window', () => app.client.getWindowCount().should.eventually.have.at.least(1))
11+
);

e2e/tsconfig.e2e.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"module": "commonjs",
77
"target": "es5",
88
"types": [
9-
"jasmine",
10-
"jasminewd2",
9+
"mocha",
1110
"node"
1211
]
1312
}

electron-builder.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ directories:
33
buildResources: build-resources
44
app: dist
55
productName: electron-angular-native
6+
artifactName: ${name}.${ext}
67
win:
78
icon: src/favicon.png
89
target:

0 commit comments

Comments
 (0)