# Desarrollo de plugins de Discourse - Parte 6: Añadir pruebas de aceptación

**URL:** https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619
**Category:** Developer Guides
**Tags:** testing, plugin-guides, tutorial
**Created:** [27 Agosto, 2015 21:32 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619 "2015-08-27T21:32:26Z")
**Posts on this page:** 13
**Page:** 2

<div class="post-metadata">

### Author: ![Machigatta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/machigatta/32/125064_2.png) [@Machigatta](https://meta.discourse.org/u/Machigatta)
#### Post date: [22 Noviembre, 2018 17:09 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/22 "2018-11-22T17:09:17Z")

</div>

```bash
LOAD_PLUGINS=1 QUNIT_SKIP_CORE=1 QUNIT_SINGLE_PLUGIN='discouse-humble-box' /home/ravenstorm/.rbenv/versions/2.5.3/bin/rake qunit:test
Chrome is not installed. Download from https://www.google.com/chrome/browser/desktop/index.html
rake aborted!
Command failed with status (1): [LOAD_PLUGINS=1 QUNIT_SKIP_CORE=1 QUNIT_SIN...]
/home/ravenstorm/discourse/lib/tasks/plugin.rake:117:in `block in <main>'
Tasks: TOP => plugin:qunit

```

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [22 Noviembre, 2018 17:38 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/23 "2018-11-22T17:38:45Z")

</div>

> [@Machigatta](#):
>
> Chrome is not installed

Install Chrome and then give it another try.

---

<div class="post-metadata">

### Author: ![Machigatta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/machigatta/32/125064_2.png) [@Machigatta](https://meta.discourse.org/u/Machigatta)
#### Post date: [22 Noviembre, 2018 17:56 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/24 "2018-11-22T17:56:54Z")

</div>

Oh sorry i’ve pasted an old error code which i had stored in a pastebin ☹

```bash
navigate to http://localhost:60099/qunit?qunit_single_plugin=discouse-humble-box&qunit_skip_core=1&seed=187998423095278311109560784485973475676
Tests timed out
rake aborted!
Command failed with status (124): [node /home/ravenstorm/discourse/vendor/ass...]
/home/ravenstorm/discourse/lib/tasks/qunit.rake:89:in `block in <main>'
Tasks: TOP => qunit:test
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [LOAD_PLUGINS=1 QUNIT_SKIP_CORE=1 QUNIT_SIN...]
/home/ravenstorm/discourse/lib/tasks/plugin.rake:117:in `block in <main>'
Tasks: TOP => plugin:qunit

```

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [22 Noviembre, 2018 17:59 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/25 "2018-11-22T17:59:29Z")

</div>

Try running the test in the browser as David suggested earlier. So, in your browser, when the server is running, go to `your-local-site/qunit`. Very often, for me, timeouts in the Terminal have errors in JS that I could see and fix after visiting `/qunit` on the browser.

---

<div class="post-metadata">

### Author: ![Machigatta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/machigatta/32/125064_2.png) [@Machigatta](https://meta.discourse.org/u/Machigatta)
#### Post date: [22 Noviembre, 2018 18:12 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/27 "2018-11-22T18:12:24Z")

</div>

Thats one of the problems 😃

I can’t find acceptance tests on my `/qunit`

Even after turning on all modules and filtering it with `box` and `humble` nothing is here 🙁

---

<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: [22 Noviembre, 2018 18:46 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/28 "2018-11-22T18:46:29Z")

</div>

Try renaming the folder to test/javascript **s** /acceptance - that extra **`s`** is quite important!

> <https://github.com/discourse/discourse/blob/cd0403174dd88b0d1619ee7a53b42bc600bd69d1/lib/plugin/instance.rb#L463>

You might need to do `rm -rf tmp`, and then restart your development server for the changes to take effect.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [22 Noviembre, 2018 19:20 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/29 "2018-11-22T19:20:13Z")

</div>

Do what David said above (rename the folder to `javascripts`), but ALSO, change the name of your plugin in plugin.rb to `discourse-humble-box` to match the folder name. I did these two changes, and I see tests locally:

 ![image](https://global.discourse-cdn.com/meta/original/3X/2/3/23c10be414b01abf93e3b147313ca6f6e262a566.png)

---

<div class="post-metadata">

### Author: ![Machigatta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/machigatta/32/125064_2.png) [@Machigatta](https://meta.discourse.org/u/Machigatta)
#### Post date: [22 Noviembre, 2018 19:28 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/30 "2018-11-22T19:28:29Z")

</div>

Yea i’ve seen those as well now, but these aren’t really eye-opening results tbh.

But gotta dig deeper and lookup why these errors are shown.

Thanks for the help guys.  
For example the second test case.. if i am testing it myself by hand.. it works, but running it on qunit it fails ☹

Ok, got a brief idea whats bringing me the errors and it confuses me:  
`http://localhost:9292/` in my browser has the plugin installed and working  
`http://localhost:9292/qunit` the test shows, that the plugin is not even installed

I thought these two are using the same enviroment ?  
Could this be caused by my local dev-enviroment since it’s not using docker and I’m not able to install the plugin like [Install plugins on a self-hosted site](https://meta.discourse.org/t/install-plugins-in-discourse/19157) ? It’s just sitting in the `plugins` folder like the others.

---

<div class="post-metadata">

### Author: ![Machigatta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/machigatta/32/125064_2.png) [@Machigatta](https://meta.discourse.org/u/Machigatta)
#### Post date: [30 Noviembre, 2018 17:40 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/31 "2018-11-30T17:40:32Z")

</div>

Any idea how this is possible ?

---

<div class="post-metadata">

### Author: ![jlc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jlc/32/251717_2.png) [@jlc](https://meta.discourse.org/u/jlc)
#### Post date: [19 Mayo, 2022 15:29 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/35 "2022-05-19T15:29:58Z")

</div>

Estoy intentando seguir esta guía, pero me estoy atascando justo al principio: no puedo acceder a `/qunit` en absoluto. (Esto también parece estar relacionado con [Install Discourse on Ubuntu or Debian for Development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727/), que es básicamente el enfoque que estoy usando para implementar Discourse en mi máquina local para aprender sobre desarrollo, pero esta guía es la que desencadenó mi obstáculo, así que pensé en ponerlo aquí). Intentar acceder a él da como respuesta “Esa página no existe o es privada”.

El controlador para la ruta `/qunit` ([discourse/app/controllers/qunit\_controller.rb at 166fe3bb34f99bd0baa613726486ce0f13c7a992 · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/166fe3bb34f99bd0baa613726486ce0f13c7a992/app/controllers/qunit_controller.rb#L16)) menciona que es `# solo se usa en pruebas / desarrollo no ember-cli` (el comentario antes de ese método), así que he intentado ejecutar la instancia con `RAILS_ENV=test bundle exec rails server`, pero `EmberCli.enabled?` sigue siendo `true`.

¿Qué enfoque están utilizando para ejecutar un servidor de desarrollo local de modo que podamos acceder a `/qunit` (lo que probablemente implica deshabilitar EmberCLI)? (Ciertamente puedo estar perdiéndome algo obvio).

---

<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: [19 Mayo, 2022 16:06 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/36 "2022-05-19T16:06:30Z")

</div>

El nuevo camino es `/tests`. Actualizaré el OP - ¡gracias!

---

<div class="post-metadata">

### Author: ![jlc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jlc/32/251717_2.png) [@jlc](https://meta.discourse.org/u/jlc)
#### Post date: [19 Mayo, 2022 17:43 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/37 "2022-05-19T17:43:23Z")

</div>

> [@david](#):
>
> La nueva ruta es `/tests`. Actualizaré el OP.

¡Genial, gracias! Al siguiente obstáculo:

> [@eviltrout](#):
>
> Puedes probar la prueba tú mismo visitando `http://localhost:4200/tests?module=Acceptance%3A%20Purple%20Tentacle` en tu máquina de desarrollo.

Este enlace directo a la prueba de aceptación particular da el error (con un backtrace):

```plaintext
Error: No se encontraron pruebas que coincidan con el módulo "Acceptance: Purple Tentacle".

```

De hecho, cuando busco en la lista desplegable “Módulo:”, no veo nada que coincida con “purple” o “Purple”. ¿Hay una nueva parte del sistema para registrar plugins o sus pruebas que pueda faltar aquí?

Si busco “purple” usando el cuadro de texto “Filtro:”, me lleva a la siguiente URL: `http://localhost:4200/tests?filter=purple`, lo que me da un error diferente:

```plaintext
Error: No se pudo encontrar el módulo `helpers/qunit-helpers` importado desde `discourse/plugins//acceptance/purple-tentacle-test`
    at missingModule (http://localhost:4200/assets/vendor.js:259:11)

```

¿Tienes alguna idea de lo que podría estar fuera de lugar aquí?

Como nota al margen, ¿la URL `/tests` utiliza la ruta comodín `get "*url", to: 'permalinks#show'` y, por lo tanto, `Permalink.find_by_url` para resolverla realmente? Si es así, ¿en qué punto de la inicialización de Discourse se carga el mapeo de la URL `/tests` en la base de datos?

```plaintext

```

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [2 Junio, 2022 11:06 UTC](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619/38 "2022-06-02T11:06:38Z")

</div>

> [@jlc](#):
>
> ¿Tienes alguna idea de lo que podría estar fuera de lugar aquí?

@jlc, muchas gracias por probar nuestra guía y mantenernos al día. :meow_heart:

He realizado algunos cambios en la prueba de aceptación de ejemplo del OP para reflejar algunos cambios nuevos que estamos utilizando para las pruebas de aceptación. Esencialmente, los dos cambios son

- importaciones, y
- el uso de la constante `needs` dentro de `acceptance`

Eso debería resolver la mayoría de los problemas que has mencionado. También puedes hacer uso de algunas de las opciones de `needs` aquí:

> <https://github.com/discourse/discourse/blob/711cd7c85d2e58e101fd82800954cbc94baa9003/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js#L341-L371>

¡Revisar todo el archivo qunit-helpers también sería muy útil!

[Previous page](https://meta.discourse.org/t/developing-discourse-plugins-part-6-add-acceptance-tests/32619.md?page=1)
