UNPKG

sinsunsan-ng-bullet-workspace

Version:

Angular library which drastically improves execution time of your component's unit tests. This fork fix a problem in the original ng-bullet #48. Error messages in the test execution

1 lines 5.27 kB
{"version":3,"file":"sinsunsan-ng-bullet-workspace.mjs","sources":["../../../projects/ng-bullet/src/testing.ts","../../../projects/ng-bullet/public_api.ts","../../../projects/ng-bullet/sinsunsan-ng-bullet-workspace.ts"],"sourcesContent":["import { ComponentFixture, TestBed, getTestBed } from '@angular/core/testing';\n\nimport { Type } from '@angular/core';\n\n/**\n * Reconfigures current test suit to prevent angular components re-compilation after every test run.\n * Forces angular test bed to re-create zone and all injectable services by directly\n * setting _instantiated variable to false after every test run.\n * Cleanups all the changes and reverts test bed configuration after suite has finished.\n *\n * @param configureAction an optional delegate which can be used to configure test bed for the current test suite\n * directly in the configureTestSuite call (you don't need extra BeforeAll in this case)\n */\nexport const configureTestSuite = (configureAction?: () => void) => {\n const testBedApi: any = getTestBed();\n const originReset = TestBed.resetTestingModule;\n\n beforeAll(() => {\n TestBed.resetTestingModule();\n TestBed.resetTestingModule = () => TestBed;\n });\n\n // https://github.com/topnotch48/ng-bullet-workspace/issues/38\n if (configureAction) {\n beforeAll((done: DoneFn) => {\n (async function() {\n configureAction();\n await TestBed.compileComponents();\n }().then(done).catch(done.fail));\n });\n }\n\n afterEach(() => {\n testBedApi._activeFixtures.forEach((fixture: ComponentFixture<any>) => fixture.destroy());\n // reset ViewEngine TestBed\n testBedApi._instantiated = false;\n // reset Ivy TestBed\n testBedApi._testModuleRef = null;\n });\n\n afterAll(() => {\n TestBed.resetTestingModule = originReset;\n TestBed.resetTestingModule();\n });\n};\n\n/**\n * A wrapper class around ComponentFixture, which provides useful accessros:\n * component - to access component instance of current the fixture\n * element - to access underlying native element of the current component\n * detectChanges - to run change detections using current fixture\n * resolve - to resolve a type using current fixture's injector\n */\nexport class TestCtx<T> {\n constructor(public fixture: ComponentFixture<T>) { }\n\n public get component() { return this.fixture.componentInstance; }\n\n public get element(): HTMLElement { return this.fixture.debugElement.nativeElement; }\n\n public detectChanges() { this.fixture.detectChanges(); }\n\n public resolve(component: Type<any>) { return this.fixture.debugElement.injector.get(component); }\n}\n\n/**\n * Creates TestCtx instance for the Angular Component which is not initialized yet (no ngOnInit called)\n * Use case: you can override Component's providers before hooks are called.\n *\n * @param component - type of component to create instance of\n * **/\nexport const createTestContext = <T>(component: Type<T>) => {\n const fixture = TestBed.createComponent<T>(component);\n const testCtx = new TestCtx<T>(fixture);\n return testCtx;\n};\n\n/**Same as @function createTestContext, but waits till fixture becomes stable */\nexport const createStableTestContext = async <T>(component: Type<T>) => {\n const testCtx = createTestContext(component);\n testCtx.detectChanges();\n await testCtx.fixture.whenStable();\n testCtx.detectChanges();\n return testCtx;\n};\n","/*\n * Public API Surface of easy-testing library\n */\n\nexport * from './src/testing';\n\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;AAIA;;;;;;;;;MASa,kBAAkB,GAAG,CAAC,eAA4B;IAC3D,MAAM,UAAU,GAAQ,UAAU,EAAE,CAAC;IACrC,MAAM,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAE/C,SAAS,CAAC;QACN,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC7B,OAAO,CAAC,kBAAkB,GAAG,MAAM,OAAO,CAAC;KAC9C,CAAC,CAAC;;IAGH,IAAI,eAAe,EAAE;QACjB,SAAS,CAAC,CAAC,IAAY;YACrB,CAAC;gBACC,eAAe,EAAE,CAAC;gBAClB,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC;aACnC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;SAClC,CAAC,CAAC;KACJ;IAEH,SAAS,CAAC;QACN,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,OAA8B,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;;QAE1F,UAAU,CAAC,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