fix(tests): simplify tests
This commit is contained in:
parent
72828b860f
commit
8dc7cfecf9
@ -5,24 +5,27 @@ const base = require("./webpack.base.config");
|
||||
// Test files are scattered through the whole project. Here we're searching
|
||||
// for them and generating entry file for webpack.
|
||||
|
||||
const e2eDir = jetpack.cwd("tests");
|
||||
const testsDir = jetpack.cwd("tests");
|
||||
const tempDir = jetpack.cwd("temp");
|
||||
const entryFilePath = tempDir.path("e2e_entry.js");
|
||||
const entryFilePath = tempDir.path("testsInit.js");
|
||||
|
||||
const entryFileContent = e2eDir
|
||||
const testsImports = testsDir
|
||||
.find({ matching: "*.test.js" })
|
||||
.reduce((fileContent, path) => {
|
||||
const normalizedPath = path.replace(/\\/g, "/");
|
||||
return `${fileContent}import "../tests/${normalizedPath}";\n`;
|
||||
return `${fileContent}require("../tests/${normalizedPath}");\n`;
|
||||
}, "");
|
||||
|
||||
let entryFileContent = testsDir.read('init.js')
|
||||
entryFileContent = entryFileContent.replace('//TESTS', testsImports)
|
||||
|
||||
jetpack.write(entryFilePath, entryFileContent);
|
||||
|
||||
module.exports = env => {
|
||||
return merge(base(env), {
|
||||
entry: entryFilePath,
|
||||
output: {
|
||||
filename: "e2e.js",
|
||||
filename: "tests.js",
|
||||
path: tempDir.path()
|
||||
}
|
||||
});
|
@ -1,29 +0,0 @@
|
||||
const merge = require("webpack-merge");
|
||||
const jetpack = require("fs-jetpack");
|
||||
const base = require("./webpack.base.config");
|
||||
|
||||
// Test files are scattered through the whole project. Here we're searching
|
||||
// for them and generating entry file for webpack.
|
||||
|
||||
const srcDir = jetpack.cwd("src");
|
||||
const tempDir = jetpack.cwd("temp");
|
||||
const entryFilePath = tempDir.path("specs_entry.js");
|
||||
|
||||
const entryFileContent = srcDir
|
||||
.find({ matching: "*.spec.js" })
|
||||
.reduce((fileContent, path) => {
|
||||
const normalizedPath = path.replace(/\\/g, "/");
|
||||
return `${fileContent}import "../src/${normalizedPath}";\n`;
|
||||
}, "");
|
||||
|
||||
jetpack.write(entryFilePath, entryFileContent);
|
||||
|
||||
module.exports = env => {
|
||||
return merge(base(env), {
|
||||
entry: entryFilePath,
|
||||
output: {
|
||||
filename: "specs.js",
|
||||
path: tempDir.path()
|
||||
}
|
||||
});
|
||||
};
|
@ -102,8 +102,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"pretest": "webpack --config=build/webpack.app.config.js --env=test --display=none && webpack --config=build/webpack.e2e.config.js --env=test --display=none",
|
||||
"test": "mocha temp/e2e.js --require @babel/core/lib --require source-map-support/register",
|
||||
"pretest": "webpack --config=build/webpack.app.config.js --env=test --display=none && webpack --config=build/webpack.tests.config.js --env=test --display=none",
|
||||
"test": "mocha temp/tests.js --require @babel/core/lib --require source-map-support/register",
|
||||
"start": "node build/start.js",
|
||||
"prebuild": "webpack --config=build/webpack.app.config.js --env=production",
|
||||
"build": "electron-builder",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import electron from "electron";
|
||||
import { Application } from "spectron";
|
||||
|
||||
const beforeEach = function() {
|
||||
const startApplication = function() {
|
||||
this.timeout(30000);
|
||||
this.app = new Application({
|
||||
path: electron,
|
||||
@ -13,7 +13,7 @@ const beforeEach = function() {
|
||||
return this.app.start();
|
||||
};
|
||||
|
||||
const afterEach = function() {
|
||||
const stopApplication = function() {
|
||||
this.timeout(30000);
|
||||
if (this.app && this.app.isRunning()) {
|
||||
return this.app.stop();
|
||||
@ -21,7 +21,7 @@ const afterEach = function() {
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export default {
|
||||
beforeEach,
|
||||
afterEach
|
||||
export {
|
||||
startApplication,
|
||||
stopApplication
|
||||
};
|
@ -1,12 +0,0 @@
|
||||
import { expect } from "chai";
|
||||
import testUtils from "./utils";
|
||||
|
||||
describe("application launch", () => {
|
||||
before(testUtils.beforeEach);
|
||||
after(testUtils.afterEach);
|
||||
|
||||
it("index page loaded", async function() {
|
||||
const { app } = this
|
||||
await app.client.waitForExist('#index-window')
|
||||
});
|
||||
});
|
@ -2,20 +2,10 @@ const expect = (is) => {
|
||||
if(!is)
|
||||
throw new Error('expected not done');
|
||||
}
|
||||
import testUtils from "./utils";
|
||||
|
||||
const {pool} = require('../src/background/mysql')
|
||||
const forBigTable = require('../src/background/forBigTable')
|
||||
|
||||
describe("big table for check", () => {
|
||||
before(testUtils.beforeEach);
|
||||
after(testUtils.afterEach);
|
||||
|
||||
it("runned", async function() {
|
||||
const { app } = this
|
||||
await app.client.waitForExist('#index-window')
|
||||
});
|
||||
|
||||
let sphinx;
|
||||
|
||||
it("init", function() {
|
||||
|
13
tests/init.js
Normal file
13
tests/init.js
Normal file
@ -0,0 +1,13 @@
|
||||
import {startApplication, stopApplication} from "../tests/application";
|
||||
|
||||
describe("application", () => {
|
||||
before(startApplication);
|
||||
after(stopApplication);
|
||||
|
||||
it("check start", async function() {
|
||||
const { app } = this
|
||||
await app.client.waitForExist('#index-window')
|
||||
});
|
||||
|
||||
//TESTS
|
||||
});
|
@ -1,18 +1,9 @@
|
||||
import { expect } from "chai";
|
||||
import testUtils from "./utils";
|
||||
|
||||
const mysql = require('mysql')
|
||||
const config = require('../src/background/config')
|
||||
|
||||
describe("sphinx", () => {
|
||||
before(testUtils.beforeEach);
|
||||
after(testUtils.afterEach);
|
||||
|
||||
it("runned", async function() {
|
||||
const { app } = this
|
||||
await app.client.waitForExist('#index-window')
|
||||
});
|
||||
|
||||
let sphinx;
|
||||
|
||||
it("init", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user