{"_id":"@async-fn/bun","_rev":"2-17bd205ca7360775b96d6c80c13b4ad5","name":"@async-fn/bun","dist-tags":{"latest":"1.8.0"},"versions":{"1.7.0":{"name":"@async-fn/bun","version":"1.7.0","keywords":["bun","async-testing","unit-testing","mock","mocking","test","testing","tdd","bdd","asynchronous"],"author":{"name":"Team: Igniter from Houston Inc. Consulting"},"license":"MIT","_id":"@async-fn/bun@1.7.0","maintainers":[{"name":"jansav","email":"janne.savolainen@live.fi"},{"name":"iku-turso","email":"mikko.aspiala@gmail.com"}],"homepage":"https://github.com/team-igniter-from-houston-inc/async-fn#readme","bugs":{"url":"https://github.com/team-igniter-from-houston-inc/async-fn/issues"},"dist":{"shasum":"7880223e046ec4f688167742b176ad007bf1024d","tarball":"https://registry.npmjs.org/@async-fn/bun/-/bun-1.7.0.tgz","fileCount":11,"integrity":"sha512-wdZQ6XiDahqrq5/oZd/i2c/pzqQqggRXwtSQB8OPEqemZhHwnznc46IFpxnj+t4draN7bTZwD3Lt0o59Cb1oFA==","signatures":[{"sig":"MEUCIQDxVowW45LyZEDCgi6dbn+KCki2x5gjWsELMGDsLRLVKAIgMjHtvE8VUvXbNPakmMv3KunuEJx7XFuV9/mVZG9hCfQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":63844},"main":"build/index.mjs","type":"module","types":"./src/asyncFnForBun.d.ts","module":"build/index.mjs","exports":{".":{"types":"./src/asyncFnForBun.d.ts","import":"./build/index.mjs","default":"./build/index.mjs"}},"gitHead":"536260e4337562a27cb1361d8fa3fc5dc83c9a93","scripts":{"test":"bun test","build":"webpack --config=./webpack.config.cjs"},"_npmUser":{"name":"iku-turso","email":"mikko.aspiala@gmail.com"},"repository":{"url":"git+https://github.com/team-igniter-from-houston-inc/async-fn.git","type":"git"},"_npmVersion":"lerna/9.0.7/node@v22.14.0+arm64 (darwin)","description":"Additional methods to bun:test mock to introduce \"late resolve\" of promises returned by mock functions. This allows tests that read chronologically, like a story.","directories":{},"_nodeVersion":"22.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@async-fn/core":"^1.7.0"},"peerDependencies":{"bun":">= 1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bun_1.7.0_1777204070587_0.12664035722195388","host":"s3://npm-registry-packages-npm-production"}},"1.8.0":{"name":"@async-fn/bun","version":"1.8.0","description":"Additional methods to bun:test mock to introduce \"late resolve\" of promises returned by mock functions. This allows tests that read chronologically, like a story.","main":"build/index.mjs","module":"build/index.mjs","type":"module","exports":{".":{"types":"./src/asyncFnForBun.d.ts","import":"./build/index.mjs","default":"./build/index.mjs"}},"types":"./src/asyncFnForBun.d.ts","repository":{"type":"git","url":"git+https://github.com/team-igniter-from-houston-inc/async-fn.git"},"keywords":["bun","async-testing","unit-testing","mock","mocking","test","testing","tdd","bdd","asynchronous"],"author":{"name":"Team: Igniter from Houston Inc. Consulting"},"license":"MIT","scripts":{"build":"webpack --config=./webpack.config.cjs","test":"bun test"},"devDependencies":{"@async-fn/core":"^1.8.0"},"peerDependencies":{"bun":">= 1.0.0"},"publishConfig":{"access":"public"},"gitHead":"225950de9b78aa4e1a8c137a5838aa355a279f09","_id":"@async-fn/bun@1.8.0","bugs":{"url":"https://github.com/team-igniter-from-houston-inc/async-fn/issues"},"homepage":"https://github.com/team-igniter-from-houston-inc/async-fn#readme","_nodeVersion":"22.14.0","_npmVersion":"lerna/9.0.7/node@v22.14.0+arm64 (darwin)","dist":{"integrity":"sha512-If2THqtb8nJ/WXO99FVSHUPRGbNTKBsd5dWiCXAHHNTnW04G4p6q8H0XTwQn9JLhb+yOQvaGi5veHQoPe+HEZA==","shasum":"b5c381a0f623cd09e8789e78ae35cffe439d4e8a","tarball":"https://registry.npmjs.org/@async-fn/bun/-/bun-1.8.0.tgz","fileCount":11,"unpackedSize":63992,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCp/FgRAOa91vcAzz2VxFtVSgm2gnmchpHe7Jz9j2UJqwIgUxpuPFoDehJRCGWXM09LeM0vNAqyCDwjgxVtOJCrOjA="}]},"_npmUser":{"name":"iku-turso","email":"mikko.aspiala@gmail.com"},"directories":{},"maintainers":[{"name":"jansav","email":"janne.savolainen@live.fi"},{"name":"iku-turso","email":"mikko.aspiala@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bun_1.8.0_1777874408027_0.801837682643421"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-26T11:47:50.529Z","modified":"2026-05-04T06:00:08.327Z","1.7.0":"2026-04-26T11:47:50.752Z","1.8.0":"2026-05-04T06:00:08.182Z"},"bugs":{"url":"https://github.com/team-igniter-from-houston-inc/async-fn/issues"},"author":{"name":"Team: Igniter from Houston Inc. Consulting"},"license":"MIT","homepage":"https://github.com/team-igniter-from-houston-inc/async-fn#readme","keywords":["bun","async-testing","unit-testing","mock","mocking","test","testing","tdd","bdd","asynchronous"],"repository":{"type":"git","url":"git+https://github.com/team-igniter-from-houston-inc/async-fn.git"},"description":"Additional methods to bun:test mock to introduce \"late resolve\" of promises returned by mock functions. This allows tests that read chronologically, like a story.","maintainers":[{"name":"jansav","email":"janne.savolainen@live.fi"},{"name":"iku-turso","email":"mikko.aspiala@gmail.com"}],"readme":"# @async-fn/bun\n\n**asyncFn** for bun provides additional methods to the `mock` from `bun:test` to introduce \"**late resolve**\" for the promises returned.\n\nThis simplifies async unit testing by allowing tests that read chronologically, **like a story**, and do not require excessive test setup to know beforehand how async mocks are supposed to behave in each scenario.\n\n## How to install\n\n```\n$ bun add --dev @async-fn/bun\n```\n\n## Examples\n\n### Late resolve for calls to a mock to make tests read like a story\n\n```javascript\nimport asyncFn from '@async-fn/bun';\n\nit('given called, a result can be resolved *after* the mock is called', async () => {\n  const mockFunction = asyncFn();\n  const promise = mockFunction();\n\n  // Note how we resolve the returned promise *after* it is called.\n  // This permits us to write our tests so that they read like a story.\n  await mockFunction.resolve('some-value');\n\n  const actual = await promise;\n  expect(actual).toBe('some-value');\n});\n```\n\n### Late resolve for multiple calls to a mock\n\n```javascript\nimport asyncFn from '@async-fn/bun';\n\nit('given called multiple times, the results can be resolved *after* the mock was called', async () => {\n  const mockFunction = asyncFn();\n\n  const promise = Promise.all([mockFunction(), mockFunction(), mockFunction()]);\n\n  await mockFunction.resolve('some-first-value');\n  await mockFunction.resolve('some-second-value');\n  await mockFunction.resolve('some-third-value');\n\n  const actual = await promise;\n\n  expect(actual).toEqual([\n    'some-first-value',\n    'some-second-value',\n    'some-third-value',\n  ]);\n});\n```\n\n### Late rejection\n\n```javascript\nimport asyncFn from '@async-fn/bun';\n\nit('can be rejected with a rejection', () => {\n  const mockFunction = asyncFn();\n  const promise = mockFunction();\n\n  mockFunction.reject('some-rejection');\n\n  return expect(promise).rejects.toBe('some-rejection');\n});\n```\n\n### The other stuff `mock` does\n\n```javascript\nimport asyncFn from '@async-fn/bun';\n\nit('does what bun:test mock does', () => {\n  const mockFunction = asyncFn();\n\n  mockFunction('some-argument', 'some-other-argument');\n\n  expect(mockFunction).toHaveBeenCalledWith(\n    'some-argument',\n    'some-other-argument',\n  );\n});\n```\n\n## More examples\n\nCheck out the [unit tests](https://github.com/team-igniter-from-houston-inc/async-fn/blob/master/packages/core/test-utils/itWorksAsAsyncFn.js).\n\n## Availability\n\nasyncFn is also available for [jest](https://www.npmjs.com/package/@async-fn/jest), [vitest](https://www.npmjs.com/package/@async-fn/vitest) and [sinon](https://www.npmjs.com/package/@async-fn/sinon).\n","readmeFilename":"README.md"}