test: refactor some methods out of main.spec.ts and add rules to exclude test folders in eslint and forge
This commit is contained in:
parent
0354d645c5
commit
f54edba6fc
|
@ -39,7 +39,8 @@
|
|||
"error",
|
||||
{
|
||||
"devDependencies": [
|
||||
"src/**/*.spec.*",
|
||||
"**/*.{spec,mock}.*",
|
||||
"src/**/test/*",
|
||||
"mocks/**/*",
|
||||
"src/renderer/**/*",
|
||||
"templates/**/*",
|
||||
|
@ -138,7 +139,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"files": ["**/*.{spec,mock}.*"],
|
||||
"files": ["**/*.{spec,mock}.*", "src/**/test/*.*"],
|
||||
"rules": {
|
||||
"no-unused-expressions": "off",
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@ The testing framework of choice is [Mocha](https://mochajs.org/). Call `npm run
|
|||
|
||||
- assertion is (mainly) done by [Chai](https://www.chaijs.com/)
|
||||
- Electron specific testing is done by [Spectron](https://electronjs.org/spectron)
|
||||
- it writes its electron files into a temporary directory, so the local app installation should not be compromised
|
||||
- spies, stubs and mocks are provided by [Sinon.JS](https://sinonjs.org/)
|
||||
- HTTP server mocking is done by [nock](https://github.com/nock/nock)
|
||||
- property based testing is made possible by [fast-check](https://github.com/dubzzz/fast-check)
|
||||
|
|
|
@ -30,7 +30,8 @@ const ignoreList = [
|
|||
|
||||
/^\/node_modules\/\.cache($|\/)/,
|
||||
// test and mock files:
|
||||
/^\/src\/.*\.(spec|mock)\.(ts|js(\.map)?)/,
|
||||
/^.*\.(spec|mock)\.(ts|js(\.map)?)/,
|
||||
/^\/src\/.*\/test\/.*$/,
|
||||
// original typescript source and generated source map files:
|
||||
/^\/src\/.*\.(ts|js\.map)/,
|
||||
/^\/src\/.*\.eslintrc\.json/,
|
||||
|
|
|
@ -1,26 +1,17 @@
|
|||
import * as electron from 'electron';
|
||||
import { expect } from 'chai';
|
||||
import { Context } from 'mocha';
|
||||
import rewiremock from 'rewiremock';
|
||||
|
||||
import 'mocha';
|
||||
import { Application } from 'spectron';
|
||||
import { IApplicationContext } from './main/test/i-application-context';
|
||||
import { createApplication } from './main/test/spectron-util';
|
||||
|
||||
rewiremock.disable();
|
||||
|
||||
describe('Application @spectron', function () {
|
||||
this.timeout(20000);
|
||||
|
||||
interface IApplicationContext extends Context {
|
||||
app?: Application;
|
||||
}
|
||||
|
||||
// spectron writes its electron files into a temporary directory, the local app installation should not be compromised
|
||||
before(function (this: IApplicationContext) {
|
||||
this.app = new Application({
|
||||
path: ((electron as unknown) as { default: string }).default,
|
||||
args: ['.', '--enable-logging'],
|
||||
});
|
||||
this.app = createApplication();
|
||||
return this.app.start();
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import { Context } from 'mocha';
|
||||
import { Application } from 'spectron';
|
||||
|
||||
export interface IApplicationContext extends Context {
|
||||
app?: Application;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import electron from 'electron';
|
||||
import { Application } from 'spectron';
|
||||
|
||||
export function createApplication(): Application {
|
||||
return new Application({
|
||||
path: ((electron as unknown) as { default: string }).default,
|
||||
args: ['.', '--enable-logging'],
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue