diff --git a/README.md b/README.md index 68f35c1..2d07d8c 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,45 @@ as you _really_ should be following the [principle of least privilege](https://e > Help Wanted summarizing the language features! > for now see: http://elm-lang.org/docs/syntax +## Testing +Ready to start testing? +Simply follow these 3 steps: + +1) ``` npm i -g elm-test``` + +2) ``` elm test init ``` + This will set up your test environment and give you 7 dummy tests in your newly created test folder + +3) Run ```elm test``` or the **very nice** ```elm test --watch``` which will re-run your tests as you write them + +The general format of the tests are: +```elm +describe "Dummy test" + [ test "dummy test description" <| + \() -> + Expect.equal actualValue expectedValue + ] +``` +For example: +``` elm +all : Test +all = + describe "My first test" + [ test "Addition test works correctly" <| + \() -> + Expect.equal (2 + 2) 4 + , test "Our subtraction function works correctly" <| + \() -> + -- here we are pretending we have a subtract function that takes 2 arguments + Expect.equal (subtract 10 5) 5 + ] +``` + +More info on testing can be found [here](https://medium.com/@_rchaves_/testing-in-elm-93ad05ee1832#.3i3ibxcxz) and [here](http://package.elm-lang.org/packages/elm-community/elm-test/2.1.0) + +### Circle CI + +To set up your elm project on Circle CI, copy over our ```circle.yml``` and ```circle-dependencies.sh``` and follow the instructions on [our Circle CI tutorial](https://github.com/dwyl/learn-circleci) ## Reading diff --git a/circle-dependencies.sh b/circle-dependencies.sh new file mode 100644 index 0000000..81a0c5d --- /dev/null +++ b/circle-dependencies.sh @@ -0,0 +1,13 @@ +# Installs sysconfcpus so we can make elm compile faster +# and limit the CPUS that elm uses to compile. +# See: https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142 +# and https://github.com/JamesHageman/whistlet-elm/blob/1bc50446987e3bcf92a9710698ae417652d7517f/circle-deps.sh +export INSTALL_PATH="$HOME/dependencies" + +if [ ! -d $INSTALL_PATH/sysconfcpus/bin ]; then + git clone https://github.com/obmarg/libsysconfcpus.git + cd libsysconfcpus + ./configure --prefix=$INSTALL_PATH/sysconfcpus + make && make install + cd .. +fi diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..f9f5c95 --- /dev/null +++ b/circle.yml @@ -0,0 +1,17 @@ + +machine: + node: + version: 6.0.0 + +general: + artifacts: + - "test" + +test: + pre: + - sh circle-dependencies.sh + - npm i -g elm + +# using sysconfcpus to speed up elm compiler # See: https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142 + override: + - ~/dependencies/sysconfcpus/bin/sysconfcpus -n 2 npm test