# How to test code that includes ports?

**URL:** <https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/1546>\
**Category:** Learn\
**Created:** [July 23, 2018, 6:39pm UTC](https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/1546 "2018-07-23T18:39:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qqwy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/qqwy/32/1062_2.png) [@Qqwy](https://discourse.elm-lang.org/u/Qqwy)\
**Post date:** [July 23, 2018, 6:39pm UTC](https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/1546/1 "2018-07-23T18:39:28Z")

</div>

Hello all!

I am writing an Elm application, and I’d like to introduce some tests (written in Elm), to the codebase.

- What libraries exist for this?
- Are there options to use property-based testing in Elm?
- Some parts of the library require ports having been set up from the JavaScript-side, and interacting with them. How to test these?

---

<div class="post-metadata">

**Author:** ![alexkorban](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/alexkorban/32/3242_2.png) [@alexkorban](https://discourse.elm-lang.org/u/alexkorban)\
**Post date:** [July 23, 2018, 11:35pm UTC](https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/1546/2 "2018-07-23T23:35:30Z")

</div>

- [elm-test](https://github.com/elm-community/elm-test) allows you to write both regular unit tests and property based tests
- [elm-html-test](http://package.elm-lang.org/packages/eeue56/elm-html-test/latest) allows you to test `Html` values by checking for the presence of particular elements, counting elements and so on.
- I also found [elm-ordeal](https://github.com/pauldijou/elm-ordeal) which allows you to test tasks.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [August 2, 2018, 11:35pm UTC](https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/1546/3 "2018-08-02T23:35:35Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
