# Plugin QUnit tests are not running as part of rake qunit:test

**URL:** <https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577>\
**Category:** Development\
**Created:** [2017年三月20日 20:29 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577 "2017-03-20T20:29:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2017年三月20日 20:29 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577/1 "2017-03-20T20:29:06Z")

</div>

It is my understanding that running `rake qunit:test` should run all of the qunit tests in Discourse, including those for any installed plugins. However, when I run the task in the docker development environment it only runs the core discourse tests (1980 of them).

When I run exactly the same command using my native mac development environment, it picks up the tests for the plugins (e.g. the ‘poll’ plugin), which results in more than 1980 tests, and I have no idea what’s causing this difference.

This exact same problem seems to occur in the Discourse Travis build - looking at [this recent log](https://travis-ci.org/discourse/discourse/jobs/213117530), it shows

```plaintext
Time: 151618ms, Total: 1980, Passed: 1980, Failed: 0

```

So it’s not running the qunit tests for all the core plugins, even though it’s running their rspec tests.

I’ve tried investigating further but don’t really know where to look. I’m guessing there must be some kind of regex/filter which locates all the qunit test files?

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [2017年三月20日 21:27 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577/2 "2017-03-20T21:27:47Z")

</div>

> [@Plugin RSpec "get" problems](https://meta.discourse.org/t/plugin-rspec-get-problems/57256/7):
>
> You’ll need to run the plugin specs with LOAD\_PLUGINS=1 rspec plugins/babble/spec or rake plugin:spec["babble"]

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2017年三月20日 21:28 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577/3 "2017-03-20T21:28:46Z")

</div>

RSpec tests are working fine, it’s the QUnit ones that aren’t working. I’ve tried putting LOAD\_PLUGINS=1 before the rake command, but no luck ☹

I don’t think it’s a typo, since it’s an issue on Discourse’s own travis builds.

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [2017年三月21日 14:26 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577/4 "2017-03-21T14:26:02Z")

</div>

It sounds like something that we might have disabled due to random test failures which are unfortunately more common on travis than I’d like. If we can figure out how to run them again I’d be happy to reintroduce them!

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2017年三月21日 14:34 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577/5 "2017-03-21T14:34:08Z")

</div>

That makes sense, but I can’t see any logic that disables/enables them… running `rake qunit:test` on my mac runs the plugin tests, running it in docker doesn’t…

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2017年七月11日 21:17 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577/6 "2017-07-11T21:17:11Z")

</div>

I’ve been doing a lot of experimenting with QUnit today, and have had another look at this issue.

# discourse\_dev

The issue was indeed with the LOAD\_PLUGINS environment variable. When using the `bin/docker/rake` script, the LOAD\_PLUGINS variable doesn’t get passed through to the container, hence why I couldn’t get it working with the `discourse_dev` image.

# discourse\_test

I also experimented with the `discourse_test` image. It is my understanding that the `discourse_test` image is used to test `master` before merging into `tests-passed` (according to [this](https://meta.discourse.org/t/running-our-test-suite-inside-a-docker-container/16670)). In its default configuration:

```plaintext
docker run -it --rm discourse/discourse_test

```

it does not seem to run any plugin tests at all (either rspec or qunit). I am assuming that’s how [broken core plugin tests](https://github.com/discourse/discourse/pull/4968) managed to end up in tests-passed. I managed to get it to run both qunit and rspec plugin tests by running

```plaintext
docker run -e "LOAD_PLUGINS=1" -it --rm discourse/discourse_test

```

Maybe that’s something that could be used internally to make sure core plugins get tested properly? Or alternatively the `LOAD_PLUGINS` variable could be set in the Dockerfile?

# Travis

Travis is currently running plugin rspec tests, but not qunit tests. I made a PR for turning on plugin qunit tests here:

[https://github.com/discourse/discourse/pull/4971](https://github.com/discourse/discourse/pull/4971)

[Running that](https://travis-ci.org/davidtaylorhq/discourse/jobs/252569023) currently results in 11 qunit failures from a number of plugins: (Cakeday, Canned Replies, Details, and Spoiler)

> **QUnit Fails**
>
> ```plaintext
> Module Failed: Acceptance: Cakeday
> Test Failed: Anniversary emoji
> Assertion Failed: Error: Unhandled request in test environment: /t/11.json?track_visit=true&forceLoad=true&_=1499806929081 (GET)
> Expected: true, Actual: false    
> Assertion Failed: TypeError: undefined is not an object (evaluating '$posterIcons[0].title')
> Expected: true, Actual: false
> Test Failed: User is not logged in
> Assertion Failed:
> phantomjs://webpage.evaluate():49
> Module Failed: Acceptance: Canned Replies
> Test Failed: Inserting canned replies
> Assertion Failed: Error: Unhandled request in test environment: /canned_replies?_=1499806929085 (GET)
> Expected: true, Actual: false    
> Assertion Failed: ReferenceError: Can't find variable: equal
> Expected: true, Actual: false
> Test Failed: Editing a canned reply
> Assertion Failed: Error: Unhandled request in test environment: /canned_replies?_=1499806929088 (GET)
> Expected: true, Actual: false    
> Assertion Failed: Error: Element .reply-selector #canned-replies-combobox not found.
> Expected: true, Actual: false
> Test Failed: Creating a new canned reply
> Assertion Failed: Error: Unhandled request in test environment: /canned_replies?_=1499806929091 (GET)
> Expected: true, Actual: false    
> Assertion Failed: ReferenceError: Can't find variable: equal
> Expected: true, Actual: false
> phantomjs://webpage.evaluate():49
> Module Failed: Acceptance: Details Button
> Test Failed: details button
> Assertion Failed: it should contain the right output
> Expected: Before
> [details=Summary]
> some text in between
> [/details]
> After, Actual: Before 
> [details=Summary]
> some text in between
> [/details]
> After
> phantomjs://webpage.evaluate():49
> Module Failed: Acceptance: Spoiler Button
> Test Failed: spoiler button
> Assertion Failed: ReferenceError: Can't find variable: ok
> Expected: true, Actual: false
> 
> ```

These are legitimate fails, which I can reproduce running the tests suite locally. I’ve already [fixed](https://github.com/discourse/discourse/pull/4968) all but one of the “discourse-details” tests, and the “Spoiler” test should be an easy fix. The others may need more investigation.

Edit: [discourse-details PR here](https://github.com/discourse/discourse/pull/4972) and [spoiler alert PR here](https://github.com/discourse/discourse-spoiler-alert/pull/30)

---

<div class="post-metadata">

**Author:** ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)\
**Post date:** [2017年七月17日 18:24 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577/7 "2017-07-17T18:24:30Z")

</div>

> [@david](#):
>
> Maybe that’s something that could be used internally to make sure core plugins get tested properly? Or alternatively the LOAD\_PLUGINS variable could be set in the Dockerfile?

@sam (I think discourse\_test is your creation?), what do you think about loading plugins for the tests-passed pipeline?

The [plugin qunit tests](https://travis-ci.org/discourse/discourse/jobs/254507190) are now all fixed, but today [many core plugin rspec tests](https://travis-ci.org/discourse/discourse/jobs/254507188#L7282) were broken by the removal of the old markdown engine, yet the commit still ended up in tests-passed. (fails are in `poll`, `discourse-details` and `discourse-narrative-bot`).

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2017年七月17日 18:26 UTC](https://meta.discourse.org/t/plugin-qunit-tests-are-not-running-as-part-of-rake-qunit-test/59577/8 "2017-07-17T18:26:45Z")

</div>

I will have a look at this today… honestly I do not think the community can help out too much here, we have to plug this stuff in to our CI pipeline (we don’t really trust travis cause it is flaky and slow)… having a look at it later today.
