web/tests: Don’t rely on current directory.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-02-23 17:47:55 -08:00 committed by Tim Abbott
parent d8adc6de1c
commit 23fd4f95f4
5 changed files with 21 additions and 4 deletions

View File

@ -2,6 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const fs = require("fs"); const fs = require("fs");
const path = require("path");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
@ -9,7 +10,10 @@ const {mock_esm, set_global, zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const template = fs.readFileSync("templates/corporate/billing.html", "utf8"); const template = fs.readFileSync(
path.resolve(__dirname, "../../templates/corporate/billing.html"),
"utf8",
);
const dom = new JSDOM(template, {pretendToBeVisual: true}); const dom = new JSDOM(template, {pretendToBeVisual: true});
const document = dom.window.document; const document = dom.window.document;
const location = set_global("location", {}); const location = set_global("location", {});

View File

@ -2,6 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const fs = require("fs"); const fs = require("fs");
const path = require("path");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
@ -11,7 +12,10 @@ const {run_test} = require("./lib/test");
const $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const {page_params} = require("./lib/zpage_params"); const {page_params} = require("./lib/zpage_params");
const template = fs.readFileSync("templates/corporate/upgrade.html", "utf8"); const template = fs.readFileSync(
path.resolve(__dirname, "../../templates/corporate/upgrade.html"),
"utf8",
);
const dom = new JSDOM(template, { const dom = new JSDOM(template, {
pretendToBeVisual: true, pretendToBeVisual: true,
url: "http://zulip.zulipdev.com/upgrade/#billing", url: "http://zulip.zulipdev.com/upgrade/#billing",

View File

@ -34,6 +34,7 @@ require("@babel/register")({
"babel-plugin-rewire-ts", "babel-plugin-rewire-ts",
["@babel/plugin-transform-modules-commonjs", {lazy: () => true}], ["@babel/plugin-transform-modules-commonjs", {lazy: () => true}],
], ],
root: path.resolve(__dirname, "../../.."),
}); });
// Create a helper function to avoid sneaky delays in tests. // Create a helper function to avoid sneaky delays in tests.

View File

@ -2,6 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const fs = require("fs"); const fs = require("fs");
const path = require("path");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
@ -9,7 +10,10 @@ const {zrequire} = require("./lib/namespace");
const {run_test} = require("./lib/test"); const {run_test} = require("./lib/test");
const $ = require("./lib/zjquery"); const $ = require("./lib/zjquery");
const template = fs.readFileSync("templates/analytics/realm_details.html", "utf8"); const template = fs.readFileSync(
path.resolve(__dirname, "../../templates/analytics/realm_details.html"),
"utf8",
);
const dom = new JSDOM(template, {pretendToBeVisual: true}); const dom = new JSDOM(template, {pretendToBeVisual: true});
const document = dom.window.document; const document = dom.window.document;

View File

@ -2,6 +2,7 @@
const {strict: assert} = require("assert"); const {strict: assert} = require("assert");
const fs = require("fs"); const fs = require("fs");
const path = require("path");
const {JSDOM} = require("jsdom"); const {JSDOM} = require("jsdom");
@ -11,7 +12,10 @@ const $ = require("./lib/zjquery");
const {page_params} = require("./lib/zpage_params"); const {page_params} = require("./lib/zpage_params");
const noop = () => {}; const noop = () => {};
const template = fs.readFileSync("templates/corporate/upgrade.html", "utf8"); const template = fs.readFileSync(
path.resolve(__dirname, "../../templates/corporate/upgrade.html"),
"utf8",
);
const dom = new JSDOM(template, {pretendToBeVisual: true}); const dom = new JSDOM(template, {pretendToBeVisual: true});
const document = dom.window.document; const document = dom.window.document;
const location = set_global("location", {}); const location = set_global("location", {});