mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-26 22:39:05 +00:00
Changed the interface to the shared/jasmine
This commit is contained in:
parent
a7e2483428
commit
e9b5c08700
@ -3,6 +3,9 @@
|
||||
// This file is pretty much a copy of https://github.com/electron/electron-quick-start/blob/master/main.js
|
||||
|
||||
const electron = require("electron");
|
||||
const path = require("path");
|
||||
const url = require("url");
|
||||
|
||||
// Module to control application life.
|
||||
const app = electron.app;
|
||||
// Increasing memory
|
||||
@ -10,29 +13,26 @@ const app = electron.app;
|
||||
// Module to create native browser window.
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
|
||||
const path = require("path");
|
||||
const url = require("url");
|
||||
const SPEC_PATH = path.resolve(__dirname, "../spec.js");
|
||||
|
||||
const JASMIN_FILTER_KEY = "--filter";
|
||||
const MAIN_PROCESS_KEY = "--process";
|
||||
|
||||
function getJasminFilter() {
|
||||
const filterArg = process.argv.find((arg) => arg.indexOf(JASMIN_FILTER_KEY) === 0);
|
||||
return filterArg ? filterArg.slice(JASMIN_FILTER_KEY.length + 1) : null;
|
||||
}
|
||||
|
||||
function getProcess() {
|
||||
const filterArg = process.argv.find((arg) => arg.indexOf(MAIN_PROCESS_KEY) === 0);
|
||||
return filterArg ? filterArg.slice(MAIN_PROCESS_KEY.length + 1) : 'render';
|
||||
}
|
||||
|
||||
const filter = getJasminFilter();
|
||||
const jasmine = require("realm-tests/jasmine.js")
|
||||
const filter = jasmine.getFilterFromProcess();
|
||||
const runIn = getProcess();
|
||||
|
||||
// Keep a global reference of the window object, if you don´t, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainWindow;
|
||||
|
||||
console.log("The following messages are logs from the Electron process:");
|
||||
|
||||
app.on("ready", () => {
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({
|
||||
@ -41,22 +41,23 @@ app.on("ready", () => {
|
||||
|
||||
global.options = {
|
||||
filter,
|
||||
specs: [ SPEC_PATH ],
|
||||
runIn
|
||||
};
|
||||
|
||||
// Load the index.html of the app.
|
||||
mainWindow.loadURL(url.format({
|
||||
pathname: path.join(__dirname, "index.html"),
|
||||
pathname: path.resolve(__dirname, "index.html"),
|
||||
protocol: "file:",
|
||||
slashes: true
|
||||
}));
|
||||
|
||||
if (runIn === "main") {
|
||||
console.log("Running tests in the main process.");
|
||||
const jasmine = require("./jasmine.js").execute(filter);
|
||||
jasmine.onComplete((passed) => {
|
||||
process.exit(passed ? 0 : -1);
|
||||
});
|
||||
jasmine.execute(global.options.specs, filter);
|
||||
} else if(runIn === "render") {
|
||||
console.log("Running tests in the render process.");
|
||||
} else {
|
||||
|
@ -4,9 +4,10 @@ const remote = require("electron").remote;
|
||||
|
||||
const options = remote.getGlobal("options");
|
||||
if (options.runIn === "render") {
|
||||
const jasmine = require("./jasmine.js").execute(options.filter);
|
||||
const jasmine = require("realm-tests/jasmine.js");
|
||||
jasmine.onComplete((passed) => {
|
||||
// Add a delay if this happens too fast, to allow the WebDriver to connect first.
|
||||
remote.process.exit(passed ? 0 : -1);
|
||||
});
|
||||
jasmine.execute(options.specs, options.filter);
|
||||
}
|
||||
|
@ -4,23 +4,22 @@ const Jasmine = require("jasmine");
|
||||
const JasmineConsoleReporter = require('jasmine-console-reporter');
|
||||
const path = require("path");
|
||||
|
||||
const SPEC_PATH = path.join(__dirname, "..", "spec.js");
|
||||
|
||||
const ADMIN_TOKEN_PATH = path.join(__dirname, "..", "..", "..", "object-server-for-testing", "admin_token.base64");
|
||||
const ADMIN_TOKEN_PATH = path.resolve(__dirname, "../../../../object-server-for-testing/admin_token.base64");
|
||||
process.env.ADMIN_TOKEN_PATH = ADMIN_TOKEN_PATH;
|
||||
|
||||
// console.log(require.resolve("realm-spec-helpers"));
|
||||
exports.execute = (filter) => {
|
||||
const jasmine = new Jasmine();
|
||||
const JASMIN_FILTER_KEY = "--filter";
|
||||
|
||||
jasmine.clearReporters();
|
||||
jasmine.addReporter(new JasmineConsoleReporter({
|
||||
colors: 2,
|
||||
cleanStack: 3,
|
||||
verbosity: 4,
|
||||
activity: false
|
||||
}));
|
||||
jasmine.execute([ SPEC_PATH ], filter);
|
||||
function getFilterFromProcess() {
|
||||
const filterArg = process.argv.find((arg) => arg.indexOf(JASMIN_FILTER_KEY) === 0);
|
||||
return filterArg ? filterArg.slice(JASMIN_FILTER_KEY.length + 1) : null;
|
||||
}
|
||||
|
||||
return jasmine;
|
||||
};
|
||||
const jasmine = new Jasmine({
|
||||
projectBaseDir: __dirname
|
||||
});
|
||||
|
||||
// Load the config file from the default path (${projectBaseDir}/spec/support/jasmine.json).
|
||||
jasmine.loadConfigFile();
|
||||
|
||||
module.exports = jasmine;
|
||||
module.exports.getFilterFromProcess = getFilterFromProcess;
|
||||
|
Loading…
x
Reference in New Issue
Block a user