All Projects → gdotdesign → elm-spec

gdotdesign / elm-spec

Licence: other
End-to-end integration testing for Elm apps and components

Programming Languages

javascript
184084 projects - #8 most used programming language
elm
856 projects

Projects that are alternatives of or similar to elm-spec

Testcafe
A Node.js tool to automate end-to-end web testing.
Stars: ✭ 9,176 (+16583.64%)
Mutual labels:  testing-tools, end-to-end-testing
Cypress
Fast, easy and reliable testing for anything that runs in a browser.
Stars: ✭ 35,145 (+63800%)
Mutual labels:  testing-tools, end-to-end-testing
saloon
An E2E test seeder for enterprise web applications
Stars: ✭ 30 (-45.45%)
Mutual labels:  testing-tools
PixelTest
Fast, modern, simple iOS snapshot testing written purely in Swift.
Stars: ✭ 56 (+1.82%)
Mutual labels:  testing-tools
test junkie
Highly configurable testing framework for Python
Stars: ✭ 72 (+30.91%)
Mutual labels:  testing-tools
sandboni-core
Sandboni - Java test optimization library which reduces test execution time without compromising quality
Stars: ✭ 27 (-50.91%)
Mutual labels:  testing-tools
dredd-rack
The Dredd API blueprint testing tool for your Rack applications.
Stars: ✭ 50 (-9.09%)
Mutual labels:  testing-tools
firebase-spring-boot-rest-api-authentication
Firebase Spring Boot Rest API Authentication
Stars: ✭ 172 (+212.73%)
Mutual labels:  end-to-end-testing
cypress-example-docker-circle-workflows
Cypress + Docker + CircleCI Workflows = ❤️
Stars: ✭ 29 (-47.27%)
Mutual labels:  end-to-end-testing
lyrebird-java-client
lyrebird-java-client 是Lyrebird的一个 Java SDK,通过调用Lyrebird本身提供的API实现在Java项目中控制 Lyrebird Services
Stars: ✭ 14 (-74.55%)
Mutual labels:  testing-tools
jest-trx-results-processor
Jest results processor for exporting into TRX files for Visual Studio
Stars: ✭ 23 (-58.18%)
Mutual labels:  testing-tools
EyeJS
A JavaScript testing framework for the real world
Stars: ✭ 68 (+23.64%)
Mutual labels:  testing-tools
react-native-unit-tests
Example how to test React Native components
Stars: ✭ 79 (+43.64%)
Mutual labels:  testing-tools
ffbtools
Set of tools for FFB testing and debugging on GNU/Linux
Stars: ✭ 39 (-29.09%)
Mutual labels:  testing-tools
BadMedicine
Library and CLI for randomly generating medical data like you might get out of an Electronic Health Records (EHR) system
Stars: ✭ 18 (-67.27%)
Mutual labels:  testing-tools
qt monkey
Tool for testing Qt based applications
Stars: ✭ 39 (-29.09%)
Mutual labels:  testing-tools
baset
Testing tool for baseline strategy
Stars: ✭ 26 (-52.73%)
Mutual labels:  testing-tools
Approvals.NodeJS
Approval Tests implementation in NodeJS
Stars: ✭ 79 (+43.64%)
Mutual labels:  testing-tools
carina
Carina automation framework: Web, Mobile, API, DB etc testing...
Stars: ✭ 652 (+1085.45%)
Mutual labels:  testing-tools
testcafe-testing-library
🐂 Simple and complete custom Selectors for Testcafe that encourage good testing practices.
Stars: ✭ 68 (+23.64%)
Mutual labels:  end-to-end-testing

elm-spec

Build Status Npm Version Documentation

End-to-end testing for your Elm apps and components.

Features

  • Can test apps or separate components
  • Task based steps and assertions (allows createing custom ones easily)
  • Create composite steps from other steps
  • DOM steps and assertions (click, containsText, valueEquals, etc...)
  • Mock HTTP requests and report not mocked requests
  • before / after hooks
  • Run tests in the console (via jsdom)
  • Run tests with elm-reactor with console report
  • Run files one at a time elm-spec spec/SomeSpec.elm
  • Run tests one at a time elm-spec spec/SomeSpec.elm:2

CLI

You can install the CLI with either of the following commands:

npm install elm-spec -g or yarn global add elm-spec

elm-spec [glob pattern or file:testID] -f format

Options:
  --format, -f  Reporting format
                [choices: "documentation", "progress"] [default: "documentation"]
  --help        Show help                                               [boolean]

Adding the package

Add gdotdesign/elm-spec as a dependency to your elm-package.json.

  "dependencies": {
    "gdotdesign/elm-spec": "1.0.0 <= v < 2.0.0"
  }

And then install with elm-github-install using the elm-install command.

Quick Start

Here is an exmaple of testing a simple component:

import Spec exposing (..)

import Html.Events exposing (onClick)
import Html exposing (div, text)

type alias Model
  = String

type Msg
  = Set

init : () -> Model
init _ =
  "Empty"

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
  case msg of
    Set ->
      ( "Something", Cmd.none )

view : Model -> Html.Html Msg
view model =
  div [ onClick Set ] [ text model ]

specs : Node
specs =
  describe "Example"
    [ it "clicking on the div should change the text"
      [ assert.containsText { text = "Empty", selector = "div" }
      , steps.click "div"
      , assert.containsText { text = "Something", selector = "div" }
      ]
    ]

main =
  runWithProgram
    { subscriptions = \_ -> Sub.none
    , update = update
    , view = view
    , init = init
    } specs

And open the file in elm-reactor or run it wit the elm-spec command:

$ elm-spec spec/ExampleSpec.elm
◎ spec/ExampleSpec.elm
  Example
    ✔ clicking on the div should change the text
      Element div contains text "Empty"
      Clicked: div
      Element div contains text "Something"

1 files 1 tests:
 3 steps: 3 successfull, 0 failed, 0 errored
 0 requests: 0 called, 0 not called, 0 unhandled

Defining tests

You can define tests with the it or test functions:

it "does something"
  [ step1
  , assertion1
  , step2
  , assertion2
  ]

Each test can have an unlimited number of steps (Task Never Outcome) which are executed in sequence.

Before every test the given application is reset and a fresh DOM is created.

Defining Groups

You can define groups that can have an tests, hooks and groups. There are three functions that do the same thing: group, context, describe.

context "Something"
  [ describe "Something else"
    [ it "does something"
      [ step1
      , assertion1
      ]
    ]
  ]

Hooks

Elm-spec allows you to append and prepend steps and assertions before each test with the before and after functions.

These functions can be defined in a group and it will add it's steps to each test in that group and it's descendant groups tests (recursively).

context "Something"
  [ describe "Something else"
    [ before
      [ preparationStep1
      ]
    , after
      [ cleanupStep1
      ]
    , it "does something"
      [ step1
      , assertion1
      ]
    ]
  ]

Steps and Assertions

The following steps are available in the steps record:

{ dispatchEvent : String -> Json.Value -> String -> Step
, getAttribute : String -> String -> Task Never String
, setValue : String -> String -> Step
, getTitle : Task Never String
, clearValue : String -> Step
, getUrl : Task Never String
, click : String -> Step
}

And the following assertions are available in the assert and assert.not records:

{ attributeContains : AttributeData -> Assertion
, attributeEquals : AttributeData -> Assertion
, inlineStyleEquals : StyleData -> Assertion
, valueContains : TextData -> Assertion
, classPresent : ClassData -> Assertion
, containsText : TextData -> Assertion
, styleEquals : StyleData -> Assertion
, elementPresent : String -> Assertion
, elementVisible : String -> Assertion
, titleContains : String -> Assertion
, valueEquals : TextData -> Assertion
, titleEquals : String -> Assertion
, urlContains : String -> Assertion
, urlEquals : String -> Assertion
}

Step groups

You can define a new step that is composed of many other steps but appear as one step in the results with the stepGroup function. If any of the defined steps fails the new step fails as well.

myStep =
  stepGroup "Descripiton of the step"
    [ step1
    , assertion1
    ]

spec =
  it "does something"
    [ myStep
    , step2
    ]

Examples

You can see examples of tests written in elm-spec in here:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].