Comment on page

Adding Elm Tests

Elm is a functional language that compiles to JavaScript. This guide covers the nuances of how to add webpage tests and unit tests for Elm contents.

Webpage Tests

Because Elm compiles to JavaScript, webpage tests are an especially good match.
To start, make sure that you have Elm running and accessible publicly (e.g. elm-reactor -a ). Then, create a new webpage test, and enter the URL you'd like to use (for example {{localhost:8000}}/Todo.elm , note the 8000 port number).
Click Screenshot to save a picture of your web page (this make take a moment if you haven't already built your project):
You can also lock the test to a specific element using the Element field if necessary.
Save your webpage test, and you're done!

Unit Tests

When adding a unit test for Elm, you should first add **/tests* as a new hidden file glob to prevent users from seeing the blank tests structure. The test code will be reset each run, so learners cannot cheat on their project.
You can then add a unit test as shown here. Only the advanced option is currently available for Elm, so you have to write the complete test, for example:
module Tests exposing (..)
import Test exposing (..)
import Expect
all : Test
all =
describe "An Elm test"
[ describe "Unit test examples"
[ test "Addition" <|
\() ->
Expect.equal (10 + 20) 30
You must call the module Tests!