mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 02:20:14 +08:00
DEV: Allow running theme-qunit tests via testem (#16540)
This allows `QUNIT_EMBER_CLI=1 bin/rake theme:qunit[...]` to test themes using `testem` with Ember-CLI-generated assets
This commit is contained in:
parent
3010c5fd74
commit
127ba698a7
@ -68,8 +68,20 @@ module.exports = {
|
||||
reporter: Reporter,
|
||||
};
|
||||
|
||||
if (shouldLoadPluginTestJs()) {
|
||||
const target = `http://localhost:${process.env.UNICORN_PORT || "3000"}`;
|
||||
const target = `http://localhost:${process.env.UNICORN_PORT || "3000"}`;
|
||||
|
||||
if (process.argv.includes("-t")) {
|
||||
// Running testem without ember cli. Probably for theme-qunit
|
||||
const testPage = process.argv[process.argv.indexOf("-t") + 1];
|
||||
|
||||
module.exports.proxies = {};
|
||||
module.exports.proxies[`/*/theme-qunit`] = {
|
||||
target: `${target}${testPage}`,
|
||||
ignorePath: true,
|
||||
};
|
||||
module.exports.proxies["/*/*"] = { target };
|
||||
} else if (shouldLoadPluginTestJs()) {
|
||||
// Running with ember cli, but we want to pass through plugin request to Rails
|
||||
module.exports.proxies = {
|
||||
"/assets/discourse/tests/active-plugins.js": {
|
||||
target,
|
||||
|
@ -28,6 +28,9 @@
|
||||
}
|
||||
</style>
|
||||
<%- end %>
|
||||
<%- if params['testem'] %>
|
||||
<script src="/testem.js"></script>
|
||||
<%- end %>
|
||||
</head>
|
||||
<body>
|
||||
<%- if !@suggested_themes %>
|
||||
|
@ -106,8 +106,16 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
|
||||
puts "Rails server is warmed up"
|
||||
|
||||
if ember_cli
|
||||
cmd = ["env", "UNICORN_PORT=#{unicorn_port}", "yarn", "ember", "test", "--query", query]
|
||||
cmd += ["--test-page", qunit_path.delete_prefix("/")] if qunit_path
|
||||
cmd = ["env", "UNICORN_PORT=#{unicorn_port}"]
|
||||
if qunit_path
|
||||
# Bypass `ember test` - it only works properly for the `/tests` path.
|
||||
# We have to trigger a `build` manually so that JS is available for rails to serve.
|
||||
system("yarn", "ember", "build", chdir: "#{Rails.root}/app/assets/javascripts/discourse")
|
||||
test_page = "#{qunit_path}?#{query}&testem=1"
|
||||
cmd += ["yarn", "testem", "ci", "-f", "testem.js", "-t", test_page]
|
||||
else
|
||||
cmd += ["yarn", "ember", "test", "--query", query]
|
||||
end
|
||||
system(*cmd, chdir: "#{Rails.root}/app/assets/javascripts/discourse")
|
||||
else
|
||||
cmd = "node #{test_path}/run-qunit.js http://localhost:#{port}#{qunit_path}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user