{"id":14917,"library":"sinon-stub-framework","title":"Sinon Stub Framework (Sinon Re-export)","description":"This package, `sinon-stub-framework`, is a minimalistic wrapper that directly re-exports the entire `sinon` library. Its primary function appears to have been to provide the `sinon` package under an alternative name, possibly for historical or specific project reasons. Currently at version 1.0.4, the package has not seen updates in approximately five years (as of early 2026), suggesting it is effectively abandoned. There is no unique functionality, API, or release cadence separate from `sinon` itself, which is a mature and actively maintained library for test spies, stubs, and mocks. Users are strongly advised to install and use `sinon` directly instead of this wrapper to ensure they receive the latest features, bug fixes, and security updates.","status":"abandoned","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/Tedc0819/stub-framework","tags":["javascript","sinonjs"],"install":[{"cmd":"npm install sinon-stub-framework","lang":"bash","label":"npm"},{"cmd":"yarn add sinon-stub-framework","lang":"bash","label":"yarn"},{"cmd":"pnpm add sinon-stub-framework","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is merely a re-export of the sinon library; all its functionality comes directly from sinon.","package":"sinon","optional":false}],"imports":[{"note":"This package re-exports Sinon.js. For ESM, named imports are standard. This is equivalent to `import { stub } from 'sinon';`.","wrong":"import stub from 'sinon-stub-framework';","symbol":"stub","correct":"import { stub } from 'sinon-stub-framework';"},{"note":"The entire Sinon module is re-exported. It's generally better to use the specific named imports you need, but this allows access to all Sinon utilities. For CJS, `const sinon = require('sinon');` is the direct equivalent.","wrong":"const sinon = require('sinon-stub-framework'); // For older Node.js or CJS modules","symbol":"Sinon","correct":"import * as sinon from 'sinon-stub-framework';"},{"note":"Sinon's assertion utilities are directly available. This is equivalent to `import { assert } from 'sinon';`.","wrong":"import { sinonAssert } from 'sinon-stub-framework';","symbol":"assert","correct":"import { assert } from 'sinon-stub-framework';"}],"quickstart":{"code":"import { stub } from 'sinon-stub-framework';\n\nclass MyService {\n  fetchData(id) {\n    return Promise.resolve(`Data for ${id}`);\n  }\n  processData(data) {\n    return data.toUpperCase();\n  }\n}\n\ndescribe('MyService', () => {\n  let myService;\n  let fetchDataStub;\n\n  beforeEach(() => {\n    myService = new MyService();\n    // Stub a method to control its behavior during tests\n    fetchDataStub = stub(myService, 'fetchData');\n  });\n\n  afterEach(() => {\n    // Restore the original method after each test\n    fetchDataStub.restore();\n  });\n\n  it('should return stubbed data', async () => {\n    fetchDataStub.returns(Promise.resolve('Mocked Data'));\n    const result = await myService.fetchData(1);\n    expect(result).toBe('Mocked Data');\n    expect(fetchDataStub.calledOnceWith(1)).toBe(true);\n  });\n\n  it('should throw an error when stubbed', async () => {\n    const errorMessage = 'Network Error!';\n    fetchDataStub.throws(new Error(errorMessage));\n    await expect(myService.fetchData(2)).rejects.toThrow(errorMessage);\n    expect(fetchDataStub.calledOnceWith(2)).toBe(true);\n  });\n\n  it('should process data correctly even with stubbed dependency', () => {\n    fetchDataStub.returns(Promise.resolve('raw data'));\n    // Test another method that might rely on fetchData but we control its output\n    const processed = myService.processData('another data'); // Assuming processData doesn't call fetchData here for simplicity\n    expect(processed).toBe('ANOTHER DATA');\n  });\n});","lang":"javascript","description":"Demonstrates basic usage of Sinon stubs, showing how to replace a method's implementation, control its return values, and restore the original function after tests. This code is functionally identical to using `sinon` directly."},"warnings":[{"fix":"Migrate all imports and dependencies directly to `sinon`. Uninstall `sinon-stub-framework` and install `sinon`.","message":"This package is effectively abandoned and has not been updated in approximately five years. It only re-exports the `sinon` library, meaning it offers no unique functionality and likely contains outdated versions of `sinon` (it currently depends on `sinon@^7.0.0`, while `sinon` is at v17+).","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always use `sinon` directly to control your dependency version and benefit from the latest updates and documentation.","message":"Because this package simply re-exports `sinon`, any breaking changes or API differences between `sinon` versions will apply. However, this wrapper will *not* automatically update `sinon` to its latest major versions, potentially leaving users stuck on older, unmaintained versions of `sinon`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch to ES Module imports (`import { ... } from 'sinon';`) and use the `sinon` package directly. Ensure your project is configured for ESM.","message":"The use of `require()` for CommonJS imports in modern Node.js environments is discouraged in favor of ES Modules (`import`). While `sinon` supports both, relying on an abandoned wrapper might complicate future migration or tooling integration.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure the stub variable is correctly assigned the return value of `sinon.stub()` and that `restore()` is called only once per stub in an appropriate cleanup hook (e.g., `afterEach`). If using a `sinon.sandbox`, use `sandbox.restore()` instead.","cause":"Attempting to call `.restore()` on a stub that was not properly created or has already been restored/garbage collected.","error":"TypeError: Cannot read properties of undefined (reading 'restore')"},{"fix":"Verify that `myObject` and `myMethod` are correctly spelled and accessible at the point where `sinon.stub(myObject, 'myMethod')` is called. Ensure the method isn't being stubbed on an instance that's different from the one being tested.","cause":"Attempting to stub a method that does not exist on the object, or the object/method reference is incorrect at the time of stub creation.","error":"TypeError: myObject.myMethod is not a function"}],"ecosystem":"npm"}