# Add testing to a WebThing (programmed in JavaScript)

**URL:** <https://discourse.mozilla.org/t/add-testing-to-a-webthing-programmed-in-javascript/31055>\
**Category:** WebThings\
**Created:** [August 20, 2018, 12:11am UTC](https://discourse.mozilla.org/t/add-testing-to-a-webthing-programmed-in-javascript/31055 "2018-08-20T00:11:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaller94](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/jaller94/32/24189_2.png) [@jaller94](https://discourse.mozilla.org/u/jaller94)\
**Post date:** [August 20, 2018, 12:11am UTC](https://discourse.mozilla.org/t/add-testing-to-a-webthing-programmed-in-javascript/31055/1 "2018-08-20T00:11:20Z")

</div>

I’ve released some smaller WebThings.

> **[web things · GitLab](https://gitlab.com/webthings)**
>
> A collection of services compatible with the Web of Things

After I had initially started with the Node.js express server, I switched to the NPM package `webthing` after reading this great article.

> **[Creating Web Things with Python, Node.js, and Java – Mozilla Hacks - the Web...](https://hacks.mozilla.org/2018/05/creating-web-things-with-python-node-js-and-java/)**
>
> Discover how to build web things with Python, Node.js, or Java using the Things Framework. These languages are definitely not optimal for small embedded devices; this tutorial is intended for ...

There are many more ideas for new Things I wish to program. However, the process needs to become scalable. My biggest time sink is testing. That is why I wish to automate it.

I am looking for both unit tests of my functions that gather the values for properties, as well as some black-box tests which ensure that the Thing can be instantiated and does not fail right away (e.g. read and change some property values). For this I am most likely going to use Jest.

Are there already examples or even a framework for testing a (self-written) WebThing?  
I think this would make an awesome blog article and improve the quality of existing and new WebThings.

---

<div class="post-metadata">

**Author:** ![hobinjk](https://avatars.discourse-cdn.com/v4/letter/h/4af34b/32.png) [@hobinjk](https://discourse.mozilla.org/u/hobinjk)\
**Post date:** [August 23, 2018, 2:28pm UTC](https://discourse.mozilla.org/t/add-testing-to-a-webthing-programmed-in-javascript/31055/2 "2018-08-23T14:28:42Z")

</div>

The code we use to test all of our webthing libraries is here: [https://github.com/mozilla-iot/webthing-tester](https://github.com/mozilla-iot/webthing-tester). The webthing-node repo should contain automated tests built on this if I remember correctly. Hope it helps!

---

<div class="post-metadata">

**Author:** ![jaller94](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/jaller94/32/24189_2.png) [@jaller94](https://discourse.mozilla.org/u/jaller94)\
**Post date:** [January 30, 2019, 9:39am UTC](https://discourse.mozilla.org/t/add-testing-to-a-webthing-programmed-in-javascript/31055/3 "2019-01-30T09:39:41Z")

</div>

I started my own, experimental JavaScript library for testing Web Things via HTTP.

> **[web things / webthing-http-tester · GitLab](https://gitlab.com/webthings/webthing-http-tester)**
>
> A helper package for black-box testing Web Things
