# Напишите тесты на приёмку и тесты компонентов для кода Ember в Discourse

**URL:** https://meta.discourse.org/t/write-acceptance-tests-and-component-tests-for-ember-code-in-discourse/49167
**Category:** Developer Guides
**Tags:** testing, ember, tutorial, code
**Created:** [24.Август.2016 20:48:02 UTC](https://meta.discourse.org/t/write-acceptance-tests-and-component-tests-for-ember-code-in-discourse/49167 "2016-08-24T20:48:02Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [31.Январь.2017 21:53:50 UTC](https://meta.discourse.org/t/write-acceptance-tests-and-component-tests-for-ember-code-in-discourse/49167/2 "2017-01-31T21:53:50Z")

</div>

My prior experience in writing qunit tests was based on the other howto

> [@Developing Discourse Plugins - Part 6 - Add acceptance tests](https://meta.discourse.org/t/beginner-s-guide-to-creating-discourse-plugins-part-6-acceptance-tests/32619):
>
> Previous tutorial: [Developing Discourse Plugins - Part 5 - Add an admin interface](https://meta.discourse.org/t/developing-discourse-plugins-part-5-add-an-admin-interface/31761) Did you know that Discourse has two large test suites for its code base? On the server side, our Ruby code has a test suite that uses [rspec](https://rspec.info/). For the browser application, we have a [qunit](https://qunitjs.com/) suite that has [ember-testing](https://guides.emberjs.com/release/testing/testing-application/) included. Assuming you have a development environment set up, if you visit the http://localhost:3000/tests URL you will start running the JavaScript test suite in your browser. One fun aspect is that …

i.e. “acceptance” was simply

```plaintext
acceptance("Purple Tentacle", { loggedIn: true });

```

I have seen in other plugins where the test code contained “fake” JSON to test against. I wasn’t sure if that would be as good as testing against “real” data, so I wanted to avoid doing it that way.

The six tests passed, but I got a couple of rather angry looking “unhandled request” errors.

After finding an example of some “setup” code, I tried it and it solved the errors.

> <https://github.com/Mittineague/discourse-newpage/blob/master/test/javascripts/acceptance/discourse-newpage-test.js.es6#L7-L18>

It works, but I’m not really sure why, nor why it’s needed for some but not for the majority of plugins I’ve seen that have qunit tests.

---

_[View the full topic](https://meta.discourse.org/t/write-acceptance-tests-and-component-tests-for-ember-code-in-discourse/49167)._
