
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
classtubber
Advanced tools
Stubs a class and returns references to methods on instances of said class
Stubs a class and returns references to methods on instances of said class
This is useful when stubbing a class before it's instanciated and you don't have access to it from the test itself. I would anticipate you'd usually use this with injectr/mockery/proxyquire.
class TestClass {
testMethod() {
// does something
}
anotherTestMethod() {
// does something else
}
}
[
stubbedTestClass,
stubReference,
] = createStubbedClass(TestClass, { testMethod: myCustomStub })
stubbedTestClass is now a stubbed function/class.
When stubbedTestClass is instanciated it will modify
the testclass property on the stubReference to be the instance.
All methods on the class will be stubbed. You can pass in your own stubs if you'd like specific behaviour. You can then access methods on the instance and assert against them. e.g. `expect(stubReference.testclass.testMethod).to.have.been.called()``
You can also make assertions against the class itself as that is a spy. This is useful for checking a class has been instanciated correctly. e.g. `expect(stubbedTestClass).to.have.been.calledWith({foo: 'bar'})``
FAQs
Stubs a class and returns references to methods on instances of said class
The npm package classtubber receives a total of 0 weekly downloads. As such, classtubber popularity was classified as not popular.
We found that classtubber demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.