npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eunit-runner

v1.0.1

Published

Runner for eunit Elm unit tests

Downloads

2

Readme

eunit

Minimalistic unit testing framework for Elm.

Installation

In the root directory of an Elm project:

  • Run elm-package install eunit to install the eunit Elm package
  • Run npm install -g eunit-runner to install the command line test runner

Creating tests

To generate a test example run eunit init in the root directory of an Elm project to which tests should be added. Test example should be created in test/Main.elm

import Expectation exposing (eql, isTrue)
import Test exposing (it, describe, Test)
import Runner exposing (runAll)

import Html exposing (Html)

all : Test
all = describe "Arithmetic operations"
  [ describe "Addition"
    [ it "should add two positive numbers" <|
        eql (1 + 2) 3
      , it "should be commutative" <|
        eql (1 + 2) (2 + 1)
      , it "should be associative" <|
        eql ((1 + 2) + 3) (1 + (2 + 3))
    ]
    , describe "Multiplication"
    [
      it "should multiply two positive numbers" <|
        eql (2 * 3) 6
      , it "should be commutative" <|
        eql (2 * 3) (3 * 2)
      , it "should be associative" <|
        eql ((2 * 3) * 4) (2 * (3 * 4))
    ]
    , describe "Subtraction"
    [
      it "should subtract two  numbers" <|
        eql (2 - 3) -1
      , it "should be commutative?" <| -- Failing test, subtraction is not commutative!
        eql (2 - 3) (3 - 2)
      , it "should be associative?" <| -- Failing test, subtraction is not associative!
        isTrue (((2 - 3) - 4) == (2 - (3 - 4)))
    ]
  ]

main : Html msg
main =
  runAll all

Test structure should be self-explanatory, it is inspired largely by Jasmine. Some differences:

  • Test defined by it can have only one expectation
  • Available expectations are only limited to eql, isTrue, isFalse
  • There is no beforeEach and afterEach as tests are written for stateless functions and do not require setting up shared state

Running tests

In browser

Tests can be simply run in browser, just start elm-reactor in the root directory of the project and access test/Main.elm. Running tests in a browser can be a good way to debug a particular test failure.

Command line

Make sure that eunit-runner NPM package is installed globally, run eunit in the root directory of the project. You should get an output like the following one:

  EUnit test runner 
 Running test suite... 
 
  Arithmetic operations 
 
  .......xx 
 Elapsed time: 500ms 
 Passed: 7 
 FAILED: 2 
 To debug run 'elm-reactor -p 9908 ' and open http://localhost:9908/test/Main.elm in a browser for more details.