{"id":45554,"library":"ng-cache-testing-module","title":"ng-cache-testing-module","description":"Angular library (v1.1.3, stable, no recent updates) that caches TestBed configurations between tests to reduce compilation overhead and speed up test suites. Key differentiator: minimal API (single function call) vs alternatives like angular-testing-library or custom caching. Requires @angular/core, rxjs, and zone.js as peer dependencies. Ships TypeScript types.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/SimonTestNet/ng-cache-testing-module","tags":["javascript","Angular","Test","Karma","Performance","Speed","typescript"],"install":[{"cmd":"npm install ng-cache-testing-module","lang":"bash","label":"npm"},{"cmd":"yarn add ng-cache-testing-module","lang":"bash","label":"yarn"},{"cmd":"pnpm add ng-cache-testing-module","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core Angular peer dependency for TestBed and component testing","package":"@angular/core","optional":false},{"reason":"Peer dependency required by Angular's testing utilities","package":"rxjs","optional":false},{"reason":"Peer dependency required by Angular's zone system in tests","package":"zone.js","optional":false}],"imports":[{"note":"ESM-only; CommonJS require fails. Package exports named module from ESM bundle.","wrong":"const cacheTestingModule = require('ng-cache-testing-module')","symbol":"cacheTestingModule","correct":"import { cacheTestingModule } from 'ng-cache-testing-module'"},{"note":"Type-only import to avoid runtime error. Config type is exported but not used often.","wrong":"import { ICacheTestingModuleConfig } from 'ng-cache-testing-module'","symbol":"ICacheTestingModuleConfig","correct":"import type { ICacheTestingModuleConfig } from 'ng-cache-testing-module'"},{"note":"Injection token for custom config; not commonly imported directly.","wrong":"import { NG_CACHE_MODULE_CONFIG } from 'ng-cache-testing-module'","symbol":"NG_CACHE_MODULE_CONFIG","correct":"import { NG_CACHE_MODULE_CONFIG } from 'ng-cache-testing-module'"}],"quickstart":{"code":"import { cacheTestingModule } from 'ng-cache-testing-module';\nimport { TestBed } from '@angular/core/testing';\nimport { MyComponent } from './my.component';\n\ndescribe('MyComponent', () => {\n  cacheTestingModule(); // must be called at suite level, not inside beforeEach\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      declarations: [MyComponent]\n    });\n  });\n\n  it('should create', () => {\n    const fixture = TestBed.createComponent(MyComponent);\n    expect(fixture).toBeTruthy();\n  });\n});","lang":"typescript","description":"Shows basic usage of cacheTestingModule() in a Jasmine test suite to cache TestBed configuration, improving performance."},"warnings":[{"fix":"Move cacheTestingModule() to the describe callback, outside beforeEach.","message":"cacheTestingModule() must be called inside the root describe block, not inside beforeEach. Calling it inside beforeEach will not cache the module.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Replace useValue with useFactory in providers to create fresh instances each test.","message":"Shared state between tests can cause false positives or failures when using cached modules. Services with mutable state persist across tests.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Create spies inside individual it() blocks instead of shared setup.","message":"Global spies created outside of individual tests (e.g., in beforeAll or shared beforeEach) persist across cached module instances, leading to unexpected interactions.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Ensure cacheTestingModule() is called in every describe block that should use caching.","message":"Version 1.1.0 changed caching behavior: previously the module configuration was reset automatically; now you must call cacheTestingModule() explicitly in each suite.","severity":"breaking","affected_versions":">=1.1.0 <1.2.0"},{"fix":"Use the NG_CACHE_MODULE_CONFIG injection token instead of importing ICacheTestingModuleConfig.","message":"The ICacheTestingModuleConfig interface is deprecated in favor of direct injection of NG_CACHE_MODULE_CONFIG for custom caching behavior.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"search_vec":"'altern':36 'angular':6,39,57 'angular-testing-librari':38 'angular/core':46 'api':31 'cach':3,14,44 'call':34 'compil':21 'configur':16 'custom':43 'depend':52 'differenti':29 'function':33 'javascript':56 'karma':59 'key':28 'librari':7,41 'like':37 'minim':30 'modul':5 'ng':2 'ng-cache-testing-modul':1 'overhead':22 'peer':51 'perform':60 'recent':11 'reduc':20 'requir':45 'rxjs':47 'ship':53 'singl':32 'speed':24,61 'stabl':9 'suit':27 'test':4,18,26,40,58 'testb':15 'type':55 'typescript':54,62 'updat':12 'v1.1.3':8 'vs':35 'zone.js':49","created_at":"2026-06-07T12:55:34.979726+00:00","updated_at":"2026-06-07T12:55:34.979726+00:00","problems":[{"fix":"Refactor your Angular module to eliminate circular dependencies or avoid caching in that test suite.","cause":"Using cacheTestingModule() with modules that have circular dependencies causes Angular's provider resolver to fail.","error":"Error: Provider parse errors:\nCannot instantiate cyclic dependency! NGModule"},{"fix":"Ensure cacheTestingModule() is called at the top level of the describe block.","cause":"Calling cacheTestingModule() inside a nested describe or beforeEach causes the cached component to be null.","error":"TypeError: Cannot read property 'component' of null"},{"fix":"Use import { cacheTestingModule } from 'ng-cache-testing-module' instead of require().","cause":"Trying to use CommonJS require() to import the function, but the package only provides an ESM export.","error":"ReferenceError: cacheTestingModule is not defined"},{"fix":"Import the type using import type { ICacheTestingModuleConfig } from 'ng-cache-testing-module' with type-only import, or switch to NG_CACHE_MODULE_CONFIG token.","cause":"Directly importing the deprecated ICacheTestingModuleConfig interface triggers a deprecation warning.","error":"WARN: 'NG_CACHE_MODULE_CONFIG' has been deprecated and will be removed in a future version."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/SimonTestNet/ng-cache-testing-module#readme","github":"https://github.com/SimonTestNet/ng-cache-testing-module","docs":null,"changelog":null,"pypi":null,"npm":"ng-cache-testing-module","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}