I found this topic about testing plugins (automatically), but haven’t come across any mentioning how to test themes or theme components. Are there any examples of how to use QUnit (or similar) with themes?
You can add it to a user selectable theme or use the test link on the theme admin page.
Sorry, I meant automated testing – I will amend my previous post. I was thinking of something like QUnit that some plugins already use.
No, it’s not possible to add QUnit tests to themes/components at the moment…
@david how possible would it be possible to add support for a
/test folder like plugins? we’d also have to enable the theme when the tests are run because the core tests run without any theme, right?
The other thing to consider is that we don’t make the
/qunit route available on production servers. Since themes are often developed on production servers, we may need to rethink this
This is one of the major downsides of theme components in my opinion. They are super easy to deploy which is fantastic, but testing often gets put aside.
If I understand correctly, anything that can be done with a theme component can be done with a plugin. The former is easier to deploy, while the latter allows testing.
I feel like we should consider this issue when we do the ember cli work. There is nothing impossible about having some sort of test runner for themes, and we could ship some of the basics in the discourse-theme gem to set up local testing using ember cli.
Running theme tests would require a full installation of Discourse though, right? There are so many interdependencies I don’t think we could test themes independently
Maybe the theme-cli could have some logic to pull the discourse_dev docker image and run qunit tests inside that?
The whole idea with ember cli is that we are cleanly splitting server from client. We could ship enough of the JS side of things to test the client without running a rails server. You would still need node and ember cli installed for sure, but you may get away without installing a full Discourse stack including Redis and Postgres.
It might be tricky but something we can definitely keep in mind.