{"id":16153391,"url":"https://github.com/gigabyte5671/micro-test-runner","last_synced_at":"2026-02-07T22:02:46.202Z","repository":{"id":65968076,"uuid":"603602891","full_name":"Gigabyte5671/micro-test-runner","owner":"Gigabyte5671","description":"A minimal JavaScript test runner.","archived":false,"fork":false,"pushed_at":"2024-12-03T20:21:59.000Z","size":930,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T06:21:33.639Z","etag":null,"topics":["integration-testing","javascript","library","test","testing","unit-testing"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/micro-test-runner","language":"TypeScript","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/Gigabyte5671.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":"2023-02-19T02:28:18.000Z","updated_at":"2024-12-03T20:00:14.000Z","dependencies_parsed_at":"2024-10-28T03:34:42.976Z","dependency_job_id":null,"html_url":"https://github.com/Gigabyte5671/micro-test-runner","commit_stats":{"total_commits":25,"total_committers":1,"mean_commits":25.0,"dds":0.0,"last_synced_commit":"63884df599209a39bbe958dd7cab1fb48da55fac"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gigabyte5671%2Fmicro-test-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gigabyte5671%2Fmicro-test-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gigabyte5671%2Fmicro-test-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gigabyte5671%2Fmicro-test-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gigabyte5671","download_url":"https://codeload.github.com/Gigabyte5671/micro-test-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251639616,"owners_count":21619803,"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":["integration-testing","javascript","library","test","testing","unit-testing"],"created_at":"2024-10-10T01:11:48.049Z","updated_at":"2026-02-07T22:02:46.172Z","avatar_url":"https://github.com/Gigabyte5671.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micro Test-Runner\n\n![node tests](https://github.com/gigabyte5671/micro-test-runner/actions/workflows/node-tests.yml/badge.svg?branch=main) ![npm](https://img.shields.io/npm/dt/micro-test-runner) ![npm bundle size](https://img.shields.io/bundlephobia/min/micro-test-runner)\n\nA minimal JavaScript test runner.\n\n[Package](https://www.npmjs.com/package/micro-test-runner) • [Demo](https://micro-test-runner.zakweb.dev/)\n\n\u003cbr\u003e\n\n## Installation\n\n```bash\nnpm install micro-test-runner\n```\n\nInclude Micro Test-Runner in your project with:\n```javascript\nimport test from 'micro-test-runner';\n\n// Or\n\nconst test = require('micro-test-runner');\n```\n\n\u003cbr\u003e\n\n## Overview\n\n![overview flow diagram](https://micro-test-runner.zakweb.dev/flow-diagram.svg)\n\n\u003cbr\u003e\n\n## Usage\n\nCreate a new test-runner with:\n```javascript\nconst testRunner = test(yourFunction);\n```\n\n\u003cbr\u003e\n\nIf your function requires a specific context (`this`), chain the `.context` method:\n```javascript\nclass YourClass {\n    public static c = 17;\n    \n    public static yourFunction (a, b) {\n        return a + b + this.c;             // `this` is used by yourFunction.\n    }\n}\n\n// ...\n\ntestRunner.context(YourClass);\n```\n\n\u003cbr\u003e\n\nSpecify the arguments to pass into your function:\n```javascript\ntestRunner.with(arg1, arg2, arg3, etc...);\n```\n\n\u003cdetails\u003e\n    \u003csummary\u003eAdvanced\u003c/summary\u003e\n\nYou can chain `.with` methods to run your function multiple times with different arguments:\n```javascript\ntestRunner.with(arg1, arg2)    // Test 1.\n          .with(argA, argB)    // Test 2.\n          .with(argX, argY)    // Test 3.\n```\n\u003c/details\u003e\n\n\u003cbr\u003e\n\nOptionally, specify the number of times to run the test:\n```javascript\ntestRunner.times(5);    // Run the test 5 times.\n```\n\n\u003cdetails\u003e\n    \u003csummary\u003eAdvanced\u003c/summary\u003e\n\nIf you chained multiple `.with` methods, `.times(n)` will run the test `n` times for each set of arguments.\n\u003c/details\u003e\n\n\u003cbr\u003e\n\nFinally, specify the results you expect your function to return from each test:\n```javascript\ntestRunner.expect(result1, result2, result3, etc...);\n```\n\n\u003cdetails\u003e\n    \u003csummary\u003eAdvanced\u003c/summary\u003e\n\nIf a function is passed as an expected result, it will be evaluated on the value that the candidate returned for that particular test. This function should then return a boolean indicating whether the value was correct or not. For example:\n```javascript\ntestRunner.expect(result1, result2, (value) =\u003e value typeof 'number');\n```\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n## Results\n\nCalling `.expect` will run the test(s), returning `true` if your function passes, `false` if not.\n```javascript\nconst outcome = await testRunner.expect(result1, result2);\n```\n\nAlternately, if you'd like Micro Test-Runner to log the results for you, you can chain the `.logging()` method.\n```javascript\nimport test from 'micro-test-runner';\n\ntest(yourFunction)                                    // Test `yourFunction`...\n    .times(3)                                         // 3 times...\n    .logging('Function Name', 'warn', ['✅', '❌'])  // Logging the outcome...\n    .with('Hello', 'world!')                          // With these arguments...\n    .expect('Hello world!');                          // And expect these results.\n```\nThis method takes 4 arguments:\n1. The name of the test.\n2. `(Optional)` The severity used to log the test's failure. There are 3 options for this argument:\n   - `'log'` - Logs test results to the console.\n   - `'warn'` - Same as `'log'`, but failures will appear as warnings.\n   - `'error'` - Same as `'log'`, but failures will throw an error.\n3. `(Optional)` Icons used to visually indicate the outcome of the test.\n4. `(Optional)` Log the performance of each test run in the desired format:\n   - `'average'` - The average of all runs.\n   - `'table'` - A table showing the performance of each individual run.\n\n\u003cbr\u003e\n\n## Examples\n\nLogging:\n\n```javascript\nimport test from 'micro-test-runner';\nimport { yourFunction } from './yourProject';\n\ntest(yourFunction)              // Test `yourFunction`...\n    .times(3)                   // 3 times...\n    .logging('Function Name')   // Logging the outcome...\n    .with('Hello', 'world!')    // With these arguments...\n    .expect('Hello world!');    // And expect these results.\n```\n\nWith result:\n\n```javascript\nimport test from 'micro-test-runner';\nimport { apiCall } from './yourProject';\n\nconst result = await test(apiCall)                   // Test your `apiCall` function...\n    .times(3)                                        // 3 times...\n    .with('https://example.com/api', '/endpoint')    // With these arguments...\n    .expect('Hello internet!');                      // And expect these results.\n\nif (result) {\n    // Your test passed.\n} else {\n    // Your test failed.\n}\n```\n\nWith result (promise):\n\n```javascript\nimport test from 'micro-test-runner';\nimport { apiCall } from './yourProject';\n\ntest(apiCall)                                        // Test your `apiCall` function...\n    .times(3)                                        // 3 times...\n    .with('https://example.com/api', '/endpoint')    // With these arguments...\n    .expect('Hello internet!')                       // And expect these results.\n    .then(result =\u003e {\n        if (result) {\n            // Your test passed.\n        } else {\n            // Your test failed.\n        }\n    });\n```\n\nPerformance Logging:\n\n```javascript\nimport test from 'micro-test-runner';\nimport { slowFunction } from './yourProject';\n\ntest(slowFunction)                               // Test `slowFunction`...\n    .times(3)                                    // 3 times...\n    .with(2, 3)                                  // With these arguments...\n    .with(4, 1)                                  // And these arguments...\n    .logging('Slow', 'log', undefined, 'table')  // Logging the outcome and performance to a table in the console...\n    .expect((value, runIndex, duration) =\u003e {     // And expect these results (verified with a function).\n        return\n            value === 5                          // Check the value returned by `slowFunction`.\n            \u0026\u0026 duration \u003c 200;                   // Check that `slowFunction` took less than 200ms.\n    });\n\n\n/* Console output...\n\n✓ Slow test passed in 1004.742ms (x̄ 160.779ms per run, over 6 runs):\n  ╭──────┬───────┬───────────────╮\n  │ Test │  Run  │ Duration (ms) │\n  ├──────┼───────┼───────────────┤\n  │ 1    │ 1     │       150.812 │\n  │      │ 2     │       184.766 │\n  │      │ 3     │       161.057 │\n  ├──────┼───────┼───────────────┤\n  │ 2    │ 1     │       162.936 │\n  │      │ 2     │       159.213 │\n  │      │ 3     │       145.887 │\n  ╰──────┴───────┴───────────────╯\n\n*/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigabyte5671%2Fmicro-test-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgigabyte5671%2Fmicro-test-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigabyte5671%2Fmicro-test-runner/lists"}