{"id":13800589,"url":"https://github.com/bodil/purescript-test-unit","last_synced_at":"2025-07-21T10:02:45.672Z","repository":{"id":412692,"uuid":"26729548","full_name":"bodil/purescript-test-unit","owner":"bodil","description":"An asynchronous unit test runner for PureScript","archived":false,"fork":false,"pushed_at":"2022-09-03T10:21:47.000Z","size":105,"stargazers_count":88,"open_issues_count":8,"forks_count":34,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-03T06:03:16.791Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bodil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-16T22:00:19.000Z","updated_at":"2025-04-03T15:32:21.000Z","dependencies_parsed_at":"2022-08-08T05:16:31.919Z","dependency_job_id":null,"html_url":"https://github.com/bodil/purescript-test-unit","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/bodil/purescript-test-unit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodil%2Fpurescript-test-unit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodil%2Fpurescript-test-unit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodil%2Fpurescript-test-unit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodil%2Fpurescript-test-unit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bodil","download_url":"https://codeload.github.com/bodil/purescript-test-unit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bodil%2Fpurescript-test-unit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266278139,"owners_count":23904038,"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":[],"created_at":"2024-08-04T00:01:14.023Z","updated_at":"2025-07-21T10:02:45.647Z","avatar_url":"https://github.com/bodil.png","language":"PureScript","readme":"# purescript-test-unit\n\nAn asynchronous unit test runner for PureScript.\n\n* [API docs on Pursuit](http://pursuit.purescript.org/packages/purescript-test-unit/)\n\n## Usage\n\nTest-Unit tests are simply\n[Aff](https://github.com/slamdata/purescript-aff) actions, which can\neither succeed (test passed) or fail (test did not pass). The type for\nthese tests is `Test`, which is just an alias for `Aff Unit`.\n\nThe `Test.Unit.Assert` module contains a number of functions for\nmaking common assertions. The most straightforward is `assert`, which\ntakes a failure message and a boolean, and if the boolean is true, it\nproduces a `Test` which immediately succeeds. If the boolean is false,\nyou get a `Test` which fails with the provided error message.\n\nBecause tests are really just `Aff`s, you can perform any `Aff` inside\na do block, allowing you to easily test asynchronous code.\n\n```purescript\nmodule Test.Main where\n\nimport Prelude\n\nimport Test.Unit (suite, test, timeout)\nimport Test.Unit.Main (runTest)\nimport Test.Unit.Assert as Assert\n\nimport Node.FS.Aff as FS\nimport Node.Encoding (Encoding(..))\n\nmain = runTest do\n  suite \"sync code\" do\n    test \"arithmetic\" do\n      Assert.assert \"2 + 2 should be 4\" $ (2 + 2) == 4\n      Assert.assertFalse \"2 + 2 shouldn't be 5\" $ (2 + 2) == 5\n      Assert.equal 4 (2 + 2)\n      Assert.expectFailure \"2 + 2 shouldn't be 5\" $ Assert.equal 5 (2 + 2)\n  suite \"async code\" do\n    test \"with async IO\" do\n      fileContents \u003c- FS.readTextFile UTF8 \"file.txt\"\n      Assert.equal \"hello here are your file contents\\n\" fileContents\n    test \"async operation with a timeout\" do\n      timeout 100 $ do\n        file2Contents \u003c- FS.readTextFile UTF8 \"file2.txt\"\n        Assert.equal \"can we read a file in 100ms?\\n\" file2Contents\n```\n\nRun tests using [`pulp test`](https://github.com/bodil/pulp) or just\nby compiling with `--main Test.Main`.\n\n## QuickCheck\n\n[purescript-quickcheck](https://github.com/purescript/purescript-quickcheck)\ntests can be run using the functions in the `Test.Unit.QuickCheck`\nmodule. It exports two functions, `quickCheck` and `quickCheck'`,\nwhich work like their QuickCheck counterparts, except they produce\n`Test` actions so they integrate cleanly with Test-Unit.\n\n```purescript\nmodule Test.Main where\n\nimport Prelude\n\nimport Test.Unit (test)\nimport Test.Unit.Main (runTest)\nimport Test.Unit.QuickCheck (quickCheck)\n\nimport Test.QuickCheck (Result(), (===))\n\ntheCommutativeProperty :: Int -\u003e Int -\u003e Result\ntheCommutativeProperty a b = (a + b) === (b + a)\n\nmain = runTest do\n  test \"the commutative property\" do\n    quickCheck theCommutativeProperty\n```\n\n## Output Formats\n\nThe `Test.Unit.Main.runTest` function will default to simple output of\ntest results using `console.log` (the\n`Test.Unit.Output.Simple.runTest` test runner). If you're running on\nan ANSI colour capable terminal, it will use the\n`Test.Unit.Output.Fancy.runTest` test runner, which gets a little more\ncolourful.\n\nAdditionally, if `Test.Unit.Main.runTest` notices the word `tap` or\n`--tap` on its command line, it will pick the\n`Test.Unit.Output.TAP.runTest` test runner, which outputs test results\nusing the [TAP](https://testanything.org/) format. A number of TAP\nconsumers are\n[available on NPM](https://www.npmjs.com/package/tape#pretty-reporters)\nto transform the test output. For instance, you could install the\n[tap-spec](https://github.com/scottcorgan/tap-spec) and run your tests\nlike this: `pulp test tap | tap-spec`.\n\nYou can also specify your own test runner using the\n`Test.Unit.Main.runTestWith` function, which takes a test runner as\nits first argument. So, if you want to force the TAP test runner,\ninstead of `main = runTest do ...` you could use `main = runTestWith\nTest.Unit.Output.TAP.runTest do ...`. You could also supply your own\ncustom test runner - study one of the existing test runners to learn\nhow.\n\n## Licence\n\nCopyright 2014 Bodil Stokke\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as\npublished by the Free Software Foundation, either version 3 of the\nLicense, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this program. If not, see\n\u003chttp://www.gnu.org/licenses/\u003e.\n","funding_links":[],"categories":["Testing"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodil%2Fpurescript-test-unit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbodil%2Fpurescript-test-unit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodil%2Fpurescript-test-unit/lists"}