{"id":16860489,"url":"https://github.com/webpro/bron","last_synced_at":"2025-03-22T06:31:40.125Z","repository":{"id":45362701,"uuid":"190474431","full_name":"webpro/bron","owner":"webpro","description":"🏃‍♂️ Fast \u0026 tiny test runner for Node.js","archived":false,"fork":false,"pushed_at":"2022-10-08T09:21:28.000Z","size":34,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T09:04:10.758Z","etag":null,"topics":["test-framework","test-runner","testing","testing-tools"],"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/webpro.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}},"created_at":"2019-06-05T21:59:50.000Z","updated_at":"2023-09-08T17:54:32.000Z","dependencies_parsed_at":"2022-08-27T12:03:08.945Z","dependency_job_id":null,"html_url":"https://github.com/webpro/bron","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fbron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fbron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fbron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fbron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpro","download_url":"https://codeload.github.com/webpro/bron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244918500,"owners_count":20531682,"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":["test-framework","test-runner","testing","testing-tools"],"created_at":"2024-10-13T14:24:34.338Z","updated_at":"2025-03-22T06:31:35.678Z","avatar_url":"https://github.com/webpro.png","language":"JavaScript","readme":"# bron\n\n_**NOTE** Now that Node.js finally has the built-in [Node.js Test runner](https://nodejs.org/api/test.html),\nI consider bron **deprecated** (October 2022)._\n\nTiny test runner for Node.js\n\n- Single `test()` function, plus [.skip()](#skip) and [.only()](#only)\n- No magic, no implicit globals, no separate processes, no dependencies\n- Use the Node.js [built-in assert](https://nodejs.org/api/assert.html) module, or bring your own (e.g.\n  [chai](https://www.chaijs.com), [should.js](https://github.com/shouldjs/should.js))\n- Run tests in parallel (default), or serial\n- Timeouts (default: 15s)\n- Requires Node.js v12.20+\n- Written in/published as pure ES Modules\n\n[![Build Status](https://travis-ci.org/webpro/bron.svg?branch=master)](https://travis-ci.org/webpro/bron)\n[![npm version](https://badge.fury.io/js/bron.svg)](https://www.npmjs.com/package/bron)\n\n## Why?\n\nOften for small projects, test suites consist of some wrapped assertions in `test` or `it` functions. Node.js has a fine\n`assert` module built-in, while exception output is pretty since Node v12. Last but not least, if any test fails, the\nprocess should exit with a non-zero code so that CI/CD environments can act accordingly.\n\nTurns out this isn't very hard to implement, all source code of bron combined is only \u003c100 LOC. In case you need more\nfrom your test framework, I'm happy to recommend one of the more full fledged options:\n\n| Runner         | Dependencies |  Size |\n| -------------- | :----------: | ----: |\n| Bron (v1.1.0)  |      0       |    5K |\n| Tape (v4.11.0) |      32      |  265K |\n| Mocha (v6.2.0) |     116      | 1.53M |\n| Ava (v2.2.0)   |     387      | 3.68M |\n\n## Not featuring...\n\n- Extensive command-line options\n- TAP reporting\n- Fancy colors\n- Setup/teardown helpers (e.g. `beforeEach`, `after`)\n- Browser support\n\n## Installation\n\n```\nnpm install bron -D\n```\n\nAdd a `test` script to run the tests (`npm test`), e.g.:\n\n```json\n{\n  \"scripts\": {\n    \"test\": \"bron test/*.js\"\n  }\n}\n```\n\n## Usage from CLI\n\n```\nbron \u003cfile\u003e [--serial] [--timeout=ms]\n```\n\n## Writing tests\n\n### sync\n\n```js\nimport test from 'bron';\nimport { strict as assert } from 'assert';\n\nconst add = (x, y) =\u003e x + y;\n\ntest('should pass', () =\u003e {\n  assert.equal(add(1, 2), 3);\n});\n\ntest('should fail', () =\u003e {\n  assert.equal(add(1, 2), 4);\n});\n```\n\n```\n$ bron test.js\n✔ should pass\n✖ should fail\nAssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n\n3 !== 4\n\n    at /Users/lars/Projects/bron/sync.js:11:10\n    ...\n\n✖ 1 test(s) failed\n✔ 1 test(s) passed\n```\n\n### async\n\nNo magic, but know that the tests run in parallel.\n\n```js\nconst isTwoAsync = x =\u003e (x === 2 ? Promise.resolve('OK') : Promise.reject('NOT OK'));\n\ntest('should pass with resolved promise', () =\u003e {\n  assert.doesNotReject(() =\u003e isTwoAsync(2));\n});\n\ntest('should pass with rejected promise', () =\u003e {\n  assert.rejects(() =\u003e isTwoAsync(10), /NOT OK/);\n});\n```\n\n### serial\n\nAdd `--serial`:\n\n```js\nconst wait = milliseconds =\u003e new Promise(resolve =\u003e setTimeout(resolve, milliseconds));\n\ntest('should run serial (first)', async () =\u003e {\n  await wait(100);\n  assert(true);\n});\n\ntest('should run serial (last)', async () =\u003e {\n  await wait(0);\n  assert(true);\n});\n```\n\n```\n$ bron --serial\n✔ should run serial (first)\n✔ should run serial (last)\n```\n\n### promises\n\nReturn a promise, and the test will pass (resolved) or fail (rejected).\n\n```js\nconst isTwoAsync = x =\u003e (x === 2 ? Promise.resolve('OK') : Promise.reject('NOT OK'));\n\ntest('should pass with resolved promise', () =\u003e {\n  return isTwoAsync(2);\n});\n\ntest('should fail with rejected promise', () =\u003e {\n  return isTwoAsync(10);\n});\n```\n\n```\n$ bron\n✔ should pass with resolved promise\n✖ should fail with rejected promise\nNOT OK\n\n✖ 1 test(s) failed.\n✔ 1 test(s) passed.\n```\n\n### .skip\n\n```js\ntest.skip('should be skipped', () =\u003e {\n  assert.equal(1, 1);\n});\n```\n\n### .only\n\n```js\ntest.only('should pass', () =\u003e {\n  assert.equal(1, 1);\n});\n\ntest('should be skipped', () =\u003e {\n  assert.equal(1, 1);\n});\n```\n\nYou can use `.only` multiple times (each `.only` will run).\n\n## Timeout\n\nAdd `--timeout=n` (with `n` in milliseconds) to change the default value for each test (`15000`).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpro%2Fbron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpro%2Fbron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpro%2Fbron/lists"}