Previously we were adding `/assets/discourse/tests/core_plugin_tests.js` to the test html all the time. This works in development mode, but fails silently when using testem via the `ember test` CLI, because there is no proxy running. This commit makes a few changes to fix this, and make it more useful: - Only renders the plugin `<script>` when in development mode, or when `LOAD_PLUGINS=1` (matching core's behavior) - Only loads plugin translations based on the same logic - When running via testem, and the above conditions are met, testem is configured to proxy `core_plugin_tests.js` through to a rails server. (port based on the `UNICORN_PORT` env variable) - Adds a descriptive error if the plugin `<script>` fails to load. This can happen if the rails server hasn't been started - Updates the logic for testem browsers. Ember CLI always launches testem in "CI" mode, and we don't really want 3 browsers opening by default. Our CI explicitly specifies the 3 browsers at runtime
67 lines
1.8 KiB
JavaScript
67 lines
1.8 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);
|
|
}
|
|
|
|
reportMetadata(tag, metadata) {
|
|
if (tag === "summary-line") {
|
|
process.stdout.write(`\n${metadata.message}\n`);
|
|
} else {
|
|
this._tapReporter.reportMetadata(...arguments);
|
|
}
|
|
}
|
|
|
|
report(prefix, data) {
|
|
this._tapReporter.report(prefix, data);
|
|
}
|
|
|
|
finish() {
|
|
this._tapReporter.finish();
|
|
}
|
|
}
|
|
|
|
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: process.env.CI,
|
|
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 || process.env.EMBER_CLI ? "--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/discourse/tests/plugin-tests.js": {
|
|
target,
|
|
},
|
|
};
|
|
}
|