All Projects β†’ eeue56 β†’ elm-html-test

eeue56 / elm-html-test

Licence: BSD-3-Clause License
Test elm-html in Elm!

Programming Languages

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

Projects that are alternatives of or similar to elm-html-test

drevops
πŸ’§ + 🐳 + βœ“βœ“βœ“ + πŸ€– + ❀️ Build, Test, Deploy scripts for Drupal using Docker and CI/CD
Stars: ✭ 55 (-19.12%)
Mutual labels:  test
google-datastore-emulator
Google Datastore Emulator wrapper to nodejs
Stars: ✭ 17 (-75%)
Mutual labels:  test
teuton
Infrastructure test, mainly useful for sysadmin teachers and making contests
Stars: ✭ 22 (-67.65%)
Mutual labels:  test
rasa-train-test-gha
A GitHub action to run easily rasa train and rasa test in the CIs.
Stars: ✭ 26 (-61.76%)
Mutual labels:  test
pytest-coverage-comment
Comments a pull request with the pytest code coverage badge and full report
Stars: ✭ 32 (-52.94%)
Mutual labels:  test
system-checks
βš™ Checks and shows Linux system info - Distro name, IP, running processes and etc. Official site - system-checks.org
Stars: ✭ 35 (-48.53%)
Mutual labels:  test
ng2-quiz
A general purpose quiz application developed in angular (updated to angular 8) that can be used for multiple purpose.
Stars: ✭ 90 (+32.35%)
Mutual labels:  test
telegram-test
Module for offline testing telegram bots
Stars: ✭ 13 (-80.88%)
Mutual labels:  test
cargo-testify
Watches changes in a rust project, runs test and shows friendly notification
Stars: ✭ 76 (+11.76%)
Mutual labels:  test
zent-kit
[DEPRACATED] React η»„δ»ΆεΊ“εΌ€ε‘θ„šζ‰‹ζžΆ
Stars: ✭ 28 (-58.82%)
Mutual labels:  test
expectest
Crate provides matchers and matcher functions for unit testing.
Stars: ✭ 25 (-63.24%)
Mutual labels:  test
cypress-angularjs-unit-test
Unit test Angularjs code using Cypress.io test runner
Stars: ✭ 23 (-66.18%)
Mutual labels:  test
brutal
A code-first approach to automate the writing of unit tests.
Stars: ✭ 54 (-20.59%)
Mutual labels:  test
fastify-example
Example webapp with Fastify
Stars: ✭ 18 (-73.53%)
Mutual labels:  test
mongo-mysql
Mongo vs Mysql Test Performance in Nodejs
Stars: ✭ 87 (+27.94%)
Mutual labels:  test
ansible-role-test-vms
DEPRECATED - A Vagrant configuration to test Ansible roles against a variety of Linux distributions.
Stars: ✭ 42 (-38.24%)
Mutual labels:  test
twilio mock
Mock Twilio gem for Ruby
Stars: ✭ 26 (-61.76%)
Mutual labels:  test
Example
Example collections of PocoAndroid, Unity3d demo game and etc...
Stars: ✭ 17 (-75%)
Mutual labels:  test
nala
🦁 Nala - A delightful test framework for C projects.
Stars: ✭ 58 (-14.71%)
Mutual labels:  test
ngx-zombie-compiler
Fast JiT compiler for Angular testing
Stars: ✭ 15 (-77.94%)
Mutual labels:  test

elm-html-test

Test views by writing expectations about Html values. Build Status

import Html
import Html.Attributes exposing (class)
import Test exposing (test)
import Test.Html.Query as Query
import Test.Html.Selector exposing (text, tag)


test "Button has the expected text" <|
    \() ->
        Html.div [ class "container" ]
            [ Html.button [] [ Html.text "I'm a button!" ] ]
            |> Query.fromHtml
            |> Query.find [ tag "button" ]
            |> Query.has [ text "I'm a button!" ]

These tests are designed to be written in a pipeline like this:

  1. Call Query.fromHtml on your Html to begin querying it.
  2. Use queries like Query.find, Query.findAll, and Query.children to find the elements to test.
  3. Create expectations using things like Query.has and Query.count.

These are normal expectations, so you can use them with fuzz just as easily as with test!

Querying

Queries come in two flavors: Single and Multiple.

This is because some queries are expected to return a single result, whereas others may return multiple results.

If a Single query finds exactly one result, it will succeed and continue with any further querying or expectations. If it finds zero results, or more than one, the test will fail.

Since other querying and expectation functions are written in terms of Single and Multiple, the compiler can help make sure queries are connected as expected. For example, count accepts a Multiple, because counting a single element does not make much sense!

If you have a Multiple and want to use an expectation that works on a Single, such as Query.has, you can use Query.each to run the expectation on each of the elements in the Multiple.

Selecting elements by Html.Attribute msg

Ordinary Html.Attribute msg values can be used to select elements using Test.Html.Selector.attribute. It is important when using this selector to understand its behavior.

  • Html.Attributes.class and Html.Attributes.classList will work the same as Test.Html.Selector.classes, matching any element with at least the given classes. This behavior echoes that of element.querySelectorAll('.my-class') from JavaScript, where any element with at least .my-class will match the query.

  • Html.Attributes.style will work the same way as Test.Html.Selector.styles, matching any element with at least the given style properties.

  • Any other String attributes and properties like title, or Bool attributes like disabled will match elements with the exact value for those attributes.

  • Any attributes from Html.Events, or attributes with values that have types other than String or Bool will not match anything.

The example below demonstrates usage

import Html
import Html.Attributes as Attr
import Test exposing (test, describe)
import Test.Html.Query as Query
import Test.Html.Selector exposing (attribute, text)

tests =
    describe "attributes"
        [ test "the welcome <h1> says hello!" <|
            \() ->
                Html.div [] [ Html.h1 [ Attr.title "greeting" ] [ Html.text "Hello!" ] ]
                    |> Query.fromHtml
                    |> Query.find [ attribute <| Attr.title "greeting" ]
                    |> Query.has [ text "Hello!" ]
        , test "the .Hello.World div has the class Hello" <|
            \() ->
                Html.div
                    [ Attr.classList
                        [ ( True, "Hello" )
                        , ( True, "World" )
                        ]
                    ]
                    |> Query.fromHtml
                    |> Query.find
                        [ attribute <|
                            Attr.classList [ ( True, Hello ) ]
                        ]
        , test "the header is red" <|
            \() ->
                Html.header
                    [ Attr.style
                        [ ( "backround-color", "red" )
                        , ( "color", "yellow" )
                        ]
                    ]
                    |> Query.fromHtml
                    |> Query.find
                        [ attribute <|
                            Attr.style [ ( "backround-color", "red" ) ]
                        ]
        ]

Releases

Version Notes
5.1.2 Fix bug with mapped and lazy views
5.1.1 Fix children
5.1.0 Add filtermap
5.0.1 Fix bug with lazy views
5.0.0 Allow querying by attributes
4.1.0 Query styles
4.0.0 Allow custom events
3.0.0 Allow events to be testable
2.0.0 Better support for events by @rogeriochaves
1.1.0 Support for events by @rogeriochaves
1.0.0 Initial release
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].