{"repo":"EmandM/ts-mock-imports","free":true,"listed":false,"github":"https://github.com/EmandM/ts-mock-imports","clone":"git clone https://github.com/EmandM/ts-mock-imports.git","description":"Intuitive mocking library for Typescript class imports","language":"TypeScript","stars":111,"topics":["mock","mock-imports","typescript","sinon","sinon-stub","mock-class","es6-classes","typescript-library","es6-import","dependency-injection"],"license":"MIT","category":"dev-tools","readme_excerpt":"Typescript Mock Imports Intuitive mocking for Typescript imports. About ts-mock-imports leverages the ES6 import syntax to mock out imported code with stub versions of the imported objects. This allows ES6 code to be easily unit-tested without the need for an explicit dependency injection library. ts-mock-imports is built on top of sinon. Sinon stub documentation Mocked classes take all of the original class functions, and replace them with noop functions (functions returning undefined ) while maintaining type safety. This library needs to be run on TypeScript 2.6.1 or later. - Typescript Mock Imports - Intuitive mocking for Typescript imports. - About - Installation - Usage - API - ImportMock - MockManager (and MockStaticManager) - OtherManager - Limitations - TypeError: Cannot set property TestClass of # which has only a getter - InPlaceMockManager - InPlaceMockManager API - Contributing - Test - Releasing Installation ts-mock-imports is built on top of Sinon and TypeScript. Ensure you have both installed. Install the library Usage src/foo.ts src/bar.ts test/bar.spec.ts API ImportMock mockClass(module: , importName?: string ): MockManager module: The module containing the class you would like to mock. Both the source file and test file need to use the same path to import the mocked module. I.e. Cannot use 'src/index' to import into the .spec.ts file and then use 'src/foo' to import into bar.ts . Both files need to use either 'src/foo' or 'src/index' . importName: What the c","default_branch":null,"files":null,"tree":[],"storefront":"/r/EmandM","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/EmandM/ts-mock-imports/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}