This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/testem.js
David Taylor ef2e4f7ee0
DEV: Improve ember test (testem) output (#16401)
- Repeat failure output at end (similar to rspec)
- When running in GitHub actions, set a workflow error message
2022-04-06 22:57:52 +01:00

85 lines
2.2 KiB
JavaScript

const TapReporter = require("testem/lib/reporters/tap_reporter");
const { shouldLoadPluginTestJs } = require("discourse/lib/plugin-js");
class Reporter {
constructor() {
this._tapReporter = new TapReporter(...arguments);
}
failReports = [];
reportMetadata(tag, metadata) {
if (tag === "summary-line") {
process.stdout.write(`\n${metadata.message}\n`);
} else {
this._tapReporter.reportMetadata(...arguments);
}
}
report(prefix, data) {
if (data.failed) {
this.failReports.push([prefix, data]);
}
this._tapReporter.report(prefix, data);
}
finish() {
this._tapReporter.finish();
if (this.failReports.length > 0) {
process.stdout.write("\nFailures:\n\n");
this.failReports.forEach(([prefix, data]) => {
if (process.env.GITHUB_ACTIONS) {
process.stdout.write(`::error ::QUnit Test Failure: ${data.name}\n`);
}
this.report(prefix, data);
});
}
}
}
module.exports = {
test_page: "tests/index.html?hidepassed",
disable_watching: true,
launch_in_ci: ["Chrome"],
// launch_in_dev: ["Chrome"] // Ember-CLI always launches testem in 'CI' mode
tap_failed_tests_only: false,
parallel: 1, // disable parallel tests for stability
browser_start_timeout: 120,
browser_args: {
Chrome: [
// --no-sandbox is needed when running Chrome inside a container
process.env.CI ? "--no-sandbox" : null,
"--headless",
"--disable-dev-shm-usage",
"--disable-software-rasterizer",
"--mute-audio",
"--remote-debugging-port=4201",
"--window-size=1440,900",
"--enable-precise-memory-info",
"--js-flags=--max_old_space_size=4096",
].filter(Boolean),
Firefox: ["-headless", "--width=1440", "--height=900"],
"Headless Firefox": ["--width=1440", "--height=900"],
},
browser_paths: {
"Headless Firefox": "/opt/firefox-evergreen/firefox",
},
reporter: Reporter,
};
if (shouldLoadPluginTestJs()) {
const target = `http://localhost:${process.env.UNICORN_PORT || "3000"}`;
module.exports.proxies = {
"/assets/discourse/tests/active-plugins.js": {
target,
},
"/assets/admin-plugins.js": {
target,
},
"/assets/discourse/tests/plugin-tests.js": {
target,
},
};
}