Skip to content

Commit ee33350

Browse files
committed
add support for test mode detection in modulename.js via index.html
1 parent 4259d7c commit ee33350

File tree

6 files changed

+7
-0
lines changed

6 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ _This release is scheduled to be released on 2025-01-01._
1515
- [linter] re-added `eslint-plugin-import`now that it supports ESLint v9 (#3586)
1616
- [docs] Added step for npm publishing in release process (#3595)
1717
- [core] Add GitHub workflow to run spellcheck a few days before each release.
18+
- [core] Add intest flag to index.html to pass to module js for test mode detection (needed by #3630)
1819

1920
### Removed
2021

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<script type="text/javascript">
2020
window.mmVersion = "#VERSION#";
21+
window.intest = "#TESTMODE#";
2122
</script>
2223
</head>
2324
<body>

js/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const { getEnvVarsAsObj } = require(`${__dirname}/server_functions`);
1313

1414
// Get version number.
1515
global.version = require(`${__dirname}/../package.json`).version;
16+
global.intest = process.env.intest ? true : false;
1617
Log.log(`Starting MagicMirror: v${global.version}`);
1718

1819
// Log system information.

js/server_functions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ function geExpectedReceivedHeaders (url) {
109109
function getHtml (req, res) {
110110
let html = fs.readFileSync(path.resolve(`${global.root_path}/index.html`), { encoding: "utf8" });
111111
html = html.replace("#VERSION#", global.version);
112+
html = html.replace("#TESTMODE#", global.intest);
112113

113114
let configFile = "config/config.js";
114115
if (typeof global.configuration_file !== "undefined") {

tests/e2e/helpers/global-setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ exports.startApplication = async (configFilename, exec) => {
2626
} else {
2727
process.env.MM_CONFIG_FILE = configFilename;
2828
}
29+
process.env.intest = true;
2930
if (exec) exec;
3031
global.app = require("../../../js/app");
3132

tests/electron/helpers/global-setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports.startApplication = async (configFilename, systemDate = null, electronPar
1111
if (systemDate) {
1212
process.env.MOCK_DATE = systemDate;
1313
}
14+
process.env.intest = true;
1415

1516
global.electronApp = await electron.launch({ args: electronParams });
1617

@@ -39,6 +40,7 @@ exports.stopApplication = async () => {
3940
global.electronApp = null;
4041
global.page = null;
4142
process.env.MOCK_DATE = undefined;
43+
process.env.jstest = undefined;
4244
};
4345

4446
exports.getElement = async (selector) => {

0 commit comments

Comments
 (0)