{"id":31625061,"url":"https://github.com/theludd/fibble","last_synced_at":"2025-10-06T18:56:02.295Z","repository":{"id":148349602,"uuid":"576871166","full_name":"TheLudd/fibble","owner":"TheLudd","description":"Small library to insert test doubles into your tests","archived":false,"fork":false,"pushed_at":"2024-10-28T19:28:33.000Z","size":59,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T04:38:27.987Z","etag":null,"topics":["esmodules","test","testdouble"],"latest_commit_sha":null,"homepage":"","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/TheLudd.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-11T09:00:07.000Z","updated_at":"2025-06-22T14:19:53.000Z","dependencies_parsed_at":"2024-10-28T13:08:26.941Z","dependency_job_id":"9c6f656b-387e-44a3-80be-10d996b295f8","html_url":"https://github.com/TheLudd/fibble","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/TheLudd/fibble","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheLudd%2Ffibble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheLudd%2Ffibble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheLudd%2Ffibble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheLudd%2Ffibble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheLudd","download_url":"https://codeload.github.com/TheLudd/fibble/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheLudd%2Ffibble/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278663384,"owners_count":26024389,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["esmodules","test","testdouble"],"created_at":"2025-10-06T18:55:54.884Z","updated_at":"2025-10-06T18:56:02.285Z","avatar_url":"https://github.com/TheLudd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fibble\n\nFibble is a small library to insert test doubles into your test. It is heavily\ninspired by [quibble](https://github.com/testdouble/quibble) but targeted at es\nmodules only. It was also made to support [pnpm](https://pnpm.io/) which\ncreates a slightly different layout in the node_modules folder than other\npackage managers and is thus built independent of resolution algorithm.\n\n## api\n\nThere are two functions exported from fibble:\n\n- `replace(path, replacement)` - Replaces the module at `path` with the replacement.\n\n  - `path` (string) - A path to the module to replace. The path should be relative from the file you are calling `replace` in.\n  - `replacement` (object) - The object to replace the replacement to do. The\n    object should contain key that you `import` in the file you want to test.\n    If you want to stub the default export, name a key `default`.\n  - **returns** - Promise. The replacement is async so you should `await` its' completion.\n\n- `reset()` - Removes all registered replacements. All `imports` made after this call will use their native dependencies.\n\n## usage\n\n### setup\n\nThere are two modes available depending on the version of node you run. This is because node has changed their API for loaders.\n\n#### modern mode\n\nUse this with node version `18.19.0` and above.\n\n```bash\nnode --experimental-import-meta-resolve --import fibble/register [my app]\n```\n\n#### legacy mode\n\nUse this with node version `18.18.x` and below.\n\n```bash\nnode --experimental-import-meta-resolve --loader fibble/loader [my app]\n```\n\n#### non supported versons\n\nFibble does not support node version `20.0.0` - `20.5.x`.\n\n### mocha example\n\nThis example uses mocha/chai but feel free to use in your favorite test runner.\n\n```javascript\nimport { describe, beforeEach, it } from 'mocha'\nimport { expect } from 'chai'\nimport { replace, reset } from 'fibble'\n\ndescribe('my module', function(){\n  let subject\n\n  beforeEach(async () =\u003e {\n    await replace ('./path/to/module/to/replace.js', { someProperty: 'some replacement value' })\n\n    subject = await import('./module-to-test.js').default // or the property you want to test\n  })\n\n  afterEach(reset) // clear all replacements\n\n  it('contains the stubbed stuff', function() {\n    expect(subject(), ...) // to work with the replacemed module\n  })\n})\n```\n\nSetup mocha like this:\n\n```javascript\n// .mocharc.cjs\nmodule.exports = {\n  'node-option': ['experimental-import-meta-resolve', 'import=fibble/register'],\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheludd%2Ffibble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheludd%2Ffibble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheludd%2Ffibble/lists"}