tests: Remove dynamic package.json generation.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-10-06 16:04:59 -07:00
parent 4db89ac3a7
commit 8141927974
3 changed files with 6 additions and 28 deletions

View File

@@ -1,7 +0,0 @@
"use strict";
const TEST_APP_PRODUCT_NAME = "ZulipTest";
module.exports = {
TEST_APP_PRODUCT_NAME,
};

4
tests/package.json Normal file
View File

@@ -0,0 +1,4 @@
{
"productName": "ZulipTest",
"main": "../app/main/index.js"
}

View File

@@ -1,11 +1,10 @@
"use strict";
const fs = require("fs");
const path = require("path");
const rimraf = require("rimraf");
const {Application} = require("spectron");
const config = require("./config.js");
const testsPkg = require("./package.json");
module.exports = {
createApp,
@@ -19,7 +18,6 @@ module.exports = {
// Returns a promise that resolves to a Spectron Application once the app has loaded.
// Takes a Tape test. Makes some basic assertions to verify that the app loaded correctly.
function createApp() {
generateTestAppPackageJson();
return new Application({
path: path.join(
__dirname,
@@ -34,22 +32,6 @@ function createApp() {
});
}
// Generates package.json for test app
// Reads app package.json and updates the productName to config.TEST_APP_PRODUCT_NAME
// We do this so that the app integration doesn't doesn't share the same appDataDir as the dev application
function generateTestAppPackageJson() {
const packageJson = require(path.join(__dirname, "../package.json"));
packageJson.productName = config.TEST_APP_PRODUCT_NAME;
packageJson.main = "../app/main";
const testPackageJsonPath = path.join(__dirname, "package.json");
fs.writeFileSync(
testPackageJsonPath,
JSON.stringify(packageJson, null, " "),
"utf-8",
);
}
// Starts the app, waits for it to load, returns a promise
async function waitForLoad(app, t, options) {
if (!options) {
@@ -101,12 +83,11 @@ function getAppDataDir() {
}
console.log("Detected App Data Dir base:", base);
return path.join(base, config.TEST_APP_PRODUCT_NAME);
return path.join(base, testsPkg.productName);
}
// Resets the test directory, containing domain.json, window-state.json, etc
function resetTestDataDir() {
const appDataDir = getAppDataDir();
rimraf.sync(appDataDir);
rimraf.sync(path.join(__dirname, "package.json"));
}