feat: init electron e2e code source
This commit is contained in:
22
e2e/electron/jasmine.js
Normal file
22
e2e/electron/jasmine.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const Jasmine = require("jasmine");
|
||||||
|
const { SpecReporter } = require("jasmine-spec-reporter");
|
||||||
|
|
||||||
|
const jasmine = new Jasmine();
|
||||||
|
jasmine.loadConfig({
|
||||||
|
showColors: true,
|
||||||
|
defaultTimeoutInterval: 15000,
|
||||||
|
spec_dir: "e2e/electron",
|
||||||
|
spec_files: ["./**/*-spec.ts"],
|
||||||
|
helpers: ["./**/*-helper.ts"],
|
||||||
|
random: false,
|
||||||
|
seed: null,
|
||||||
|
stopSpecOnExpectationFailure: false,
|
||||||
|
});
|
||||||
|
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||||
|
|
||||||
|
require("ts-node").register({
|
||||||
|
project: require("path").join(__dirname, "./tsconfig.json"),
|
||||||
|
});
|
||||||
|
jasmine.env.clearReporters();
|
||||||
|
jasmine.addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
||||||
|
jasmine.execute();
|
||||||
35
e2e/electron/src/app.e2e-spec.ts
Normal file
35
e2e/electron/src/app.e2e-spec.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import * as path from 'path';
|
||||||
|
import { Application } from 'spectron';
|
||||||
|
|
||||||
|
describe('A simple test to verify a visible window is opened with a title', () => {
|
||||||
|
// Init local app
|
||||||
|
let app = new Application({
|
||||||
|
path: path.join(__dirname, '../../../node_modules/.bin/electron'),
|
||||||
|
args: [path.join(__dirname, '../../../dist/build/main.js')],
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
// Init local app and wait until window loaded
|
||||||
|
await app.start();
|
||||||
|
await app.client.waitUntilWindowLoaded();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
if (app && app.isRunning()) {
|
||||||
|
// Wait 1 second and then stop local app
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
|
await app.stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows an initial window', async () => {
|
||||||
|
// Checking there is one visible window
|
||||||
|
expect(await app.browserWindow.isVisible()).toEqual(true);
|
||||||
|
// Please note that getWindowCount() will return 2 if `dev tools` are opened.
|
||||||
|
expect(await app.client.getWindowCount()).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have expected title', async () => {
|
||||||
|
expect(await app.client.getTitle()).toEqual('ElectronAngularQuickStart');
|
||||||
|
});
|
||||||
|
});
|
||||||
9
e2e/electron/tsconfig.json
Normal file
9
e2e/electron/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../out-tsc/e2e",
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es5",
|
||||||
|
"types": ["jasmine", "jasminewd2", "node"]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user