{"id":13524928,"url":"https://github.com/jozanza/pico-test","last_synced_at":"2025-06-26T07:06:11.135Z","repository":{"id":52719050,"uuid":"60090554","full_name":"jozanza/pico-test","owner":"jozanza","description":"⚡ PICO-8 testing framework","archived":false,"fork":false,"pushed_at":"2023-03-19T01:32:07.000Z","size":42,"stargazers_count":44,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-21T13:42:42.120Z","etag":null,"topics":["cart","pico-8","pico-test"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/jozanza.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}},"created_at":"2016-05-31T13:12:15.000Z","updated_at":"2025-03-07T15:07:34.000Z","dependencies_parsed_at":"2024-01-11T14:26:50.223Z","dependency_job_id":null,"html_url":"https://github.com/jozanza/pico-test","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"488031028f56262f2e9a752962c3c139654665f3"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jozanza/pico-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozanza%2Fpico-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozanza%2Fpico-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozanza%2Fpico-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozanza%2Fpico-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jozanza","download_url":"https://codeload.github.com/jozanza/pico-test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozanza%2Fpico-test/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261243393,"owners_count":23129611,"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":["cart","pico-8","pico-test"],"created_at":"2024-08-01T06:01:14.667Z","updated_at":"2025-06-26T07:06:11.113Z","avatar_url":"https://github.com/jozanza.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# pico-test\n\n\u003cp\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pico-test\"\u003e\n    \u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/pico-test.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/jozanza/pico-test\"\u003e\n    \u003cimg alt=\"build status\" src=\"https://travis-ci.org/jozanza/pico-test.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"http://standardjs.com/\"\u003e\n    \u003cimg alt=\"code style\"  src=\"https://img.shields.io/badge/code%20style-standard-brightgreen.svg\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e **Note:** This project is still in its initial stages, so I'd love feedback about the API and issue reports.\n\n### Intro\n\nPICO-8 is great but debugging your code in this little vm can be a chore.  \n\nIf you're tired of riddling your carts with `printh`s or have given up on test-driven development, this tool should help you out.\n\n### Installation\n\n    npm i -g pico-test\n\n\u003e **Note:** you can also download it directly from the [releases section](https://github.com/jozanza/pico-test/releases)\n\n### Usage\n\nCopy/paste the following snippet into the cart you wish to test:\n\n```lua\nfunction test(title,f)\nlocal desc=function(msg,f)\n printh('⚡:desc:'..msg)\n f()\nend\nlocal it=function(msg,f)\n printh('⚡:it:'..msg)\n local xs={f()}\n for i=1,#xs do\n  if xs[i] == true then\n   printh('⚡:assert:true')\n  else\n   printh('⚡:assert:false')\n  end\n end\n printh('⚡:it_end')\nend\nprinth('⚡:test:'..title)\nf(desc,it)\nprinth('⚡:test_end')\nend\n```\n\nNext, be sure PICO-8 is aliased properly in your terminal. You may have to do something like the following:\n\n    alias pico-8='/Applications/PICO-8.app/Contents/MacOS/pico8'\n\nLast, run Pico-8 from your terminal and pipe its output to `pico-test`.\n\n    pico-8 | pico-test\n\nEach time your run your cart, test results will be printed to `stdout`. Now, you just have to write some tests! :)\n\n### API\n\n`pico-test`'s api is will be pretty familiar if you've ever used [mocha](https://mochajs.org/). There are only 3 functions to learn: `test()`, `desc()`, and `it()`\n\n#### test(title:string, fn:function)\n\ninitiates testing, wraps around test descriptions and tests, providing the callback `fn` with two args: `desc` and `it` – the other two functions in this API.\n\n| Type     | Param | Description |\n|----------|-------|-------------|\n| String   | title | title of test suite\n| Function | fn    | callback to call with `desc` and `it`\n\n#### desc(description:string, fn:function)\n\nDescribes a set of tests. This function is applied as the first argument of the callback function passed to `test`\n\n| Type     | Param       | Description |\n|----------|-------------|-------------|\n| String   | description | description for tests to be run inside of param `fn`\n| Function | fn          | callback to call with `desc` and `it`\n\n\n#### it(message:string, fn:function)\n\nReturns one or more boolean values representing test assertions. all returned values must be `true` or your test will fail. This function is applied as the second argument of the callback function passed to `test`\n\n| Type     | Param   | Description |\n|----------|---------|-------------|\n| String   | message | message starting with \"should\"\n| Function | fn      | callback to return assertions from\n\n\n### Example\n\nHere's what it looks like in action:\n\n```lua\n-- here's an object with methods we want to test\nlocal math={\n  gt=function(a,b) return a\u003eb end,\n  lt=function(a,b) return a\u003cb end,\n  mul=function(a,b) return a*b end,\n  div=function(a,b) return a/b end\n}\n\ntest('math functions', function(desc,it)\n  desc('math.gt()', function()\n    local gt = math.gt\n    it('should return type boolean', function()\n      return 'boolean' == type(gt(1,0))\n    end)\n    it('should give same result as \u003e operator', function()\n      return gt(1,0)\n    end)\n  end)\n\n  desc('math.lt()', function()\n    local lt = math.lt\n    it('should return type boolean',function()\n      return 'boolean' == type(lt(1,0))\n    end)\n    it('should give same result as \u003c operator',function()\n      return lt(1, 0) == false\n    end)\n  end)\n\n  desc('math.mul()', function()\n    local mul = math.mul\n    it('should return type number', function()\n      local a = rnd(time())\n      local b = rnd(time())\n      return 'number' == type(mul(a,b))\n    end)\n    it('should give same result as * operator', function()\n      local x=rnd(time())\n      return\n        x*1 == mul(x,1),\n        x*2 == mul(x,2),\n        x*3 == mul(x,3)\n   end)\n  end)\n\n  desc('math.div()', function()\n    local div = math.div\n    it('should return type number', function()\n      local a = rnd(time())\n      local b = rnd(time())\n      return 'number' == type(div(a,b))\n    end)\n    it('should give same result as / operator', function()\n      local x=1+rnd(time())\n      return\n        x/1 == div(x,1),\n        x/2 == div(x,2),\n        x/3 == div(x,3)\n    end)\n  end)\n\nend)\n```\n\n### License\n\nCopyright (c) 2015 Josiah Savary. Made available under The MIT License (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjozanza%2Fpico-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjozanza%2Fpico-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjozanza%2Fpico-test/lists"}