{"id":16228537,"url":"https://github.com/poppa/pest","last_synced_at":"2026-01-21T19:34:40.489Z","repository":{"id":66864635,"uuid":"309511694","full_name":"poppa/pest","owner":"poppa","description":"A Pike Unit Test Framework","archived":false,"fork":false,"pushed_at":"2022-06-22T08:58:22.000Z","size":157,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-14T03:31:27.085Z","etag":null,"topics":["pike","unit-testing-framework"],"latest_commit_sha":null,"homepage":"","language":"Pike","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/poppa.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":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-02T22:35:47.000Z","updated_at":"2022-08-03T07:40:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"86534549-d7b7-4b50-8619-b401e632eb8b","html_url":"https://github.com/poppa/pest","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/poppa%2Fpest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poppa%2Fpest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poppa%2Fpest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poppa%2Fpest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poppa","download_url":"https://codeload.github.com/poppa/pest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247779796,"owners_count":20994572,"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":["pike","unit-testing-framework"],"created_at":"2024-10-10T12:55:43.103Z","updated_at":"2026-01-21T19:34:40.482Z","avatar_url":"https://github.com/poppa.png","language":"Pike","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pest - A simple Pike unit test framework\n\nThis unit test framework is just in its infancy. Although it is, on its surface,\nheaviliy inspired by [Jest](https://jestjs.io/), I have no intentions of making\na Jest implementation in Pike. Jest has more than 1,100 contributors and\nprobably a couple of 100,000 lines of code.\n\n## Howto use\n\nClone this repository and symlink it into your `PIKE_MODULE_PATH` as\n`Pest.pmod` (or point to it with the Pike `-M` argument).\n\nCreate a directory named `test` (or call it what ever you like). Create a\n_test-runner file_ in this directory (it can be called whatever), but for the\nsake of this example lets call it `run-tests.pike`, which only needs to\ninherit `Pest.Main`.\n\n```pike\n# test/run-test.pike\ninherit Pest.Main;\n```\n\nBy default `Pest.Main` will scan for files ending in `*.spec.pike`, but what\nfile names to scan for can be given as option to `Pest.Main` via the\n`-f|--file` option, which takes a `glob`. You can also choose to run specific\ntests based on their description by passing the `-t|--test` option, which also\ntakes a `glob`.\n\nYou can also pass the `-v|--verbose` option to `Pest.Main` to ge a more verbose\ntest report output.\n\n### `Pest.Main` options\n\nSo these are the default options to `Pest.Main`:\n\n```\n-f|--file     glob    What files to treat as test files.\n-t|--test     glob    What tests to run (matching test description)\n-v|--verbose          More verbose test result output\n```\n\nOk, so now lets add a test-suite file to the `test` directory.\n\n```pike\n# test/readme.spec.pike\n\nimport Pest;\n\n// A test suite file must have a main method\nint main() {\n\n  // ... that of the time of writing serves no great purpose\n  describe(\"This is a namespace/block\", lambda () {\n    test(\"Expect some stuff to be 'truthy'\", lambda () {\n      expect(true)-\u003eto_be_truthy();\n      expect(1)-\u003eto_be_truthy();\n      expect(\"a\")-\u003eto_be_truthy();\n    });\n\n    test(\"Expect some stuff to be 'falsy'\", lambda () {\n      expect(false)-\u003eto_be_falsy();\n      expect(0)-\u003eto_be_falsy();\n      expect(UNDEFINED)-\u003eto_be_falsy();\n    });\n\n    test(\"Expect some stuff to be the same (by reference)\", lambda () {\n      mapping a = ([]);\n      mapping b = a;\n\n      expect(a)-\u003eto_be(b);\n    });\n\n    test(\"Expect some stuff to be the same (by value)\", lambda () {\n      mapping a = ([ \"index\": 1, \"value\": \"one\" ]);\n      mapping b = ([ \"index\": 1, \"value\": \"one\" ]);\n\n      expect(a)-\u003eto_equal(b);\n    });\n\n    test(\"Expect some callback to have been called\", lambda () {\n      void call_it(function cb) {\n        cb();\n      };\n\n      function my_callback = fn(lambda() {});\n      call_it(my_callback);\n      call_it(my_callback);\n\n      expect(my_callback)-\u003eto_have_been_called();\n      expect(my_callback)-\u003eto_have_been_called_n_times(2);\n    });\n\n  });\n}\n```\n\nThe result of running `test/run-test.pike` should give an output like:\n\n```\n$~: pike __dev__/run.pike\nTest suites: 1\nTests: 5\n\nRunning tests in \"/path/to/project/test/readme.spec.pike\"\n\nDone\n\n------------------------------------------------------------------------------\nRan 5 tests in 1 test-suite\n5 tests succeeded, 0 tests failed\nRan all tests in 0.02100 seconds\n------------------------------------------------------------------------------\n```\n\nNow, lets imagine a test fails (I mean it's just theoretical thougt), then\nthe output would look something like:\n\n```\nTest suites: 1\nTests: 5\n\nRunning tests in \"/path/to/project/test/readme.spec.pike\"\n\nDone\n\n==============================================================================\n1 test failed in \"/path/to/project/test/readme.spec.pike\"\n\n  @test: Expect some stuff to be 'falsy' (/path/to/project/test/readme.spec.pike:17)\n\n    Expected: \"undefined\"\n    Received: 1\n\n      15:     test(\"Expect some stuff to be 'falsy'\", lambda () {\n      16:       expect(false)-\u003eto_be_falsy();\n      17:       expect(1)-\u003eto_be_falsy();\n        : -----------------^^^^^^^^^^^\n      18:       expect(UNDEFINED)-\u003eto_be_falsy();\n      19:     });\n\n------------------------------------------------------------------------------\nRan 5 tests in 1 test-suite\n4 tests succeeded, 1 test failed\nRan all tests in 0.03000 seconds\n------------------------------------------------------------------------------\n```\n\n**_Screenshot of output_**\n![Screen shot](./shot.png)\n\n### Skip tests\n\nIf you want to skip certain tests or all tests in a certain `describe()`-block\nyou can prefix those `test()`s and `describe()`s with `skip-\u003e`:\n\n```pike\nskip-\u003edescribe(\"Not yet ready...\", lambda() { ... });\n\ndescribe(\"Some other tests\", lambda () {\n  // Skip for now, network stuff prohibits this from succeeding.\n  skip-\u003etest(\"Yadda\", lambda() {});\n});\n```\n\n## Limitations\n\n- Atm all tests and test-suites are run synchronously.\n- These are the implemented methods on `expect(expr)`\n\n  - `-\u003eto_be_truthy()`: Checks that a value is \"defined\", which in Pike terms\n    pretty much is anything not `0`.\n  - `-\u003eto_be_falsy()`: The inverse of the above.\n  - `-\u003eto_equal(x)`: Checks that the arguments equals eachother by value.\n  - `-\u003eto_be(x)`: Checks that the arguments are the same by reference.\n    For primitive types this is the same as `-\u003eto_equal()`.\n  - `-\u003eto_have_been_called()`: Checks that a function has been called. The\n    function given to `expect()` must be of type `Pest.Fn` (can be created\n    via the \"factory method\" `Pest.fn(callback)`).\n  - `-\u003eto_have_been_called_n_times(n)`: Same as above except it checks if the\n    function was called exactly `n` times.\n  - `-\u003eto_throw(string|void)`: Expect the expression to throw an\n    error. If a string is given as argument that should be the message of the\n    thrown error. **NOTE!** `expect()` must be given a `lambda () {}` wrapping\n    the expression for this to work:\n\n    ```pike\n    expect(lambda() { throwing_expr(); })-\u003eto_throw();\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoppa%2Fpest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoppa%2Fpest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoppa%2Fpest/lists"}