{"id":15674418,"url":"https://github.com/devthejo/nowtest","last_synced_at":"2025-03-30T06:13:03.878Z","repository":{"id":63662489,"uuid":"569635760","full_name":"devthejo/nowtest","owner":"devthejo","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-23T18:12:53.000Z","size":226,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T04:37:56.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devthejo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-23T09:25:39.000Z","updated_at":"2022-11-23T11:28:42.000Z","dependencies_parsed_at":"2023-01-23T05:15:41.652Z","dependency_job_id":null,"html_url":"https://github.com/devthejo/nowtest","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devthejo%2Fnowtest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devthejo%2Fnowtest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devthejo%2Fnowtest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devthejo%2Fnowtest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devthejo","download_url":"https://codeload.github.com/devthejo/nowtest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246281312,"owners_count":20752213,"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-10-03T15:44:26.656Z","updated_at":"2025-03-30T06:13:03.853Z","avatar_url":"https://github.com/devthejo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nowtest\n\nMinimalistic testing framework\n\nbased on [testnow](https://github.com/hyperkot/testnow/)\n\n```shell\n    npm install nowtest\n```\n\nThis framework doesn't have any CLI, only programmatic API.  \nIt's designed to be cross-platform and to be able to be\nintegrated with any build / CICD / deployment tools.\n\n## Setting up / describing tests\n\n```js\nconst nowtest = require(\"nowtest\");\n\nconst test = nowtest()\n\nfunction mySetImmediate(cb: () =\u003e void) {\n    return setTimeout(cb, 0);\n}\n\ntest.group(\"mySetImmediate\", () =\u003e {\n    test(\"Executes callback\", (end: test.Handler) =\u003e\n        mySetImmediate(() =\u003e end()));\n\n    test(\"May be cancelled with clearTimeout\", (end: test.Handler) =\u003e {\n        let timeoutId = mySetImmediate(\n            () =\u003e end(new Error(`Callback executed`))\n        );\n        clearTimeout(timeoutId);\n        setTimeout(() =\u003e end(), 100);\n    });\n});\n```\n\n## Executing tests\n### nodejs\n\n```js\nconst nowtest = require(\"nowtest\");\n\nconst test = nowtest()\n\nrequire(\"./mySetImmediate\");\nconst util  = require(\"util\");\n\ntest.run().then(result =\u003e {\n    console.log(util.inspect(result, true, 10, true));\n});\n```\n\nSeveral simple reporters are now built in `nowtest`. Reporter is simply a function that\ntakes test results and does something with them. Usually reporters output the results somewhere.\nRight now there are 4 simple reporter types: `plain` - using the most basic and cross-platform\n`console.log` functionality, `console` and `terminal` - are similar to `plain` for now,\n`dom` - inserts a html-formatted report as `innerHTML` into a given dom-node. The `reporter`\nexport provided by `nowtest` contains not reporters themselves, but reporter creators,\nfunctions that have optional reporter-options object as a parameter and return a reporter.\nWe could rewrite the above example using a simple built-in reporter which just logs results\nto the console:\n\n```js\nconst nowtest  = require(\"nowtest\");\nconst {reporter}  = nowtest;\n\nrequire(\"./mySetImmediate\");\n\ntest.run().then(result =\u003e {\n    reporter.plain({})(result);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevthejo%2Fnowtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevthejo%2Fnowtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevthejo%2Fnowtest/lists"}