# How to test code that includes ports?

**URL:** <https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/2115>\
**Category:** Learn\
**Created:** [October 3, 2018, 11:24am UTC](https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/2115 "2018-10-03T11:24:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincitygialam](https://avatars.discourse-cdn.com/v4/letter/v/97f17d/32.png) [@vincitygialam](https://discourse.elm-lang.org/u/vincitygialam)\
**Post date:** [October 3, 2018, 11:24am UTC](https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/2115/1 "2018-10-03T11:24:59Z")

</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:** ![Brian\_Carroll](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/brian_carroll/32/444_2.png) [@Brian\_Carroll](https://discourse.elm-lang.org/u/Brian_Carroll)\
**Post date:** [October 3, 2018, 11:49am UTC](https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/2115/2 "2018-10-03T11:49:02Z")

</div>

This is the main library for testing:

> **[elm-explorations/test](https://github.com/elm-explorations/test)**
>
> Write unit and fuzz tests for Elm code. Contribute to elm-explorations/test development by creating an account on GitHub.

It includes property based testing, which it calls “fuzz testing”.  
I haven’t got any suggestions for testing ports, maybe someone else will have some ideas.

Edit: updated link to 0.19 version

---

<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:** [October 13, 2018, 11:57am UTC](https://discourse.elm-lang.org/t/how-to-test-code-that-includes-ports/2115/3 "2018-10-13T11:57:43Z")

</div>

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