{"id":17596607,"url":"https://github.com/pauldijou/elm-ordeal","last_synced_at":"2025-04-30T05:09:24.654Z","repository":{"id":145325832,"uuid":"74281435","full_name":"pauldijou/elm-ordeal","owner":"pauldijou","description":"Test your Elm code inside Node or any major browser. Support async Task out of the box","archived":false,"fork":false,"pushed_at":"2018-06-12T10:33:08.000Z","size":74,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T05:09:19.616Z","etag":null,"topics":["elm","task","test","testing"],"latest_commit_sha":null,"homepage":null,"language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pauldijou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-20T14:55:32.000Z","updated_at":"2018-07-25T23:04:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"4bb49c33-3a5a-4c10-90ae-b082cee6bd51","html_url":"https://github.com/pauldijou/elm-ordeal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldijou%2Felm-ordeal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldijou%2Felm-ordeal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldijou%2Felm-ordeal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pauldijou%2Felm-ordeal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pauldijou","download_url":"https://codeload.github.com/pauldijou/elm-ordeal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251644842,"owners_count":21620634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elm","task","test","testing"],"created_at":"2024-10-22T08:44:50.157Z","updated_at":"2025-04-30T05:09:24.633Z","avatar_url":"https://github.com/pauldijou.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"# elm-ordeal\n\n\u003e Write unit tests in Elm, support async Task out of the box, can run directly on Node or any major browsers.\n\n**Warning** This is still a work in progress, API will probably change a bit before 1.0 release.\n\n## Install\n\n```bash\nelm-package install pauldijou/elm-ordeal\n```\n\n## Writing your first tests\n\n```elm\nport module Test exposing (..)\n\nimport Task\nimport Ordeal exposing (..)\n\nmain: Ordeal\nmain = run emit tests\n\nport emit : Event -\u003e Cmd msg\n\ntests: Test\ntests =\n  describe \"My first suite\"\n    [ test \"My very first test\" (\n      \"a\" |\u003e shouldEqual \"a\"\n    )\n    , describe \"A sub-suite\"\n      [ test \"And a sub-test\" (\n        { a = 1, b = False } |\u003e shouldEqual { a = 1, b = False }\n      )\n      , test \"Another sub-test\" (\n        True |\u003e shouldNotEqual False\n      )\n      ]\n    , xtest \"A skipped test\" (\n      \"a\" |\u003e shouldEqual \"b\"\n    )\n    , test \"My first async test\" (\n      Task.succeed 42 \n        |\u003e andTest (\\result -\u003e\n            case result of \n                Ok value -\u003e\n                    value |\u003e shouldBeGreaterThan 35\n                \n                Err str -\u003e\n                    failure str\n        )\n    )\n    , test \"My first failure\" (\n      Task.fail { a = 1, b = \"aze\" } \n        |\u003e andTest (\\result -\u003e \n            case result of \n                Ok _ -\u003e \n                    failure \"some hanlder\"\n                \n                Err {a, b} -\u003e\n                    shouldEqual \"54\" b\n        )\n    )\n    , test \"Another failure\" (\n      [\"a\",\"b\",\"c\"] |\u003e shouldContain \"d\"\n    )\n    ]\n```\n\n## Running tests\n\nThe easiest way is to use the [elm-ordeal](https://www.npmjs.com/package/elm-ordeal) CLI with Yarn or NPM.\n\n\n### Getting started\n\n```bash\n# NPM users\nnpm install --save-dev elm-ordeal\n# Yarn users\nyarn add --dev elm-ordeal\n\n# Run\nelm-ordeal your/TestFile.elm\n\n# Learn\nelm-ordeal --help\n```\n\nYou could also update your `package.json` file:\n\n```json\n{\n  \"scripts\": {\n    \"test\": \"elm-ordeal your/TestFile.elm\"\n  }\n}\n```\n\n```bash\n# Then run the added script\nnpm test\nyarn test\n```\n\n### Envs\n\nYou can run your tests on the following environments, just specify the correct CLI argument when running `elm-ordeal`. Don't forget it's up to you to locally install any browser you want to use. If you don't provide any env, it will run as Node. You can specify several envs at once of course.\n\n- Node (`--node`)\n- Chrome (`--chrome`)\n- Edge Explorer (`--edge`)\n- Firefox (`--firefox`)\n- Internet Explorer (`--ie`)\n- Opera (`--opera`)\n- Safari (`--safari`)\n\n## Combinators\n\nYou can combine tests using `Ordeal.and` or `Ordeal.or`. Here is the result of combining two tests:\n\n⮳ and       | Success | Skipped | Timeout | Failure\n------------|---------|---------|---------|--------\n**Success** | Success | Success | Timeout | Failure\n**Skipped** | Success | Skipped | Timeout | Failure\n**Timeout** | Timeout | Timeout | Timeout | Timeout\n**Failure** | Failure | Failure | Failure | Failure\n\n⮳ or       | Success | Skipped | Timeout | Failure\n------------|---------|---------|---------|--------\n**Success** | Success | Success | Success | Success\n**Skipped** | Success | Skipped | Timeout | Failure\n**Timeout** | Success | Timeout | Timeout | Failure\n**Failure** | Success | Failure | Timeout | Failure\n\nIn case of two `Failure`, `Ordeal.and` will return the first one while `Ordeal.or` will return the second one.\n\nYou can also use `Ordeal.all` and `Ordeal.any` which works on list of tests just folding them using `Ordeal.and` and `Ordeal.or` respectively.\n\n## Why? Why not just use elm-test?\n\nIt's up to you, I think `elm-test` is good but when I started writing tests in Elm, I needed to test `Task` and there was no way to do it easily using `elm-test` (not sure if there is now). In `elm-ordeal`, all tests are tasks, so they can be can synchronous or asynchronous, the package does not care.\n\n## Test\n\nYou can run the tests using `yarn install \u0026\u0026 yarn test`. Currently, the final result should be one timeout, one skipped and all other success.\n\n## Thanks\n\nA big thank to [@rtfeldman](https://github.com/gaearon) for creating [node-test-runner](https://github.com/rtfeldman/node-test-runner) which I took a lot of inspiration from.\n\n## License\n\nThis software is licensed under the Apache 2 license, quoted below.\n\nCopyright Paul Dijou ([http://pauldijou.fr](http://pauldijou.fr)).\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this project except in compliance with the License. You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauldijou%2Felm-ordeal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpauldijou%2Felm-ordeal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauldijou%2Felm-ordeal/lists"}