Skip to content

Instantly share code, notes, and snippets.

@pjlamb12
Created May 18, 2023 21:13
Show Gist options
  • Save pjlamb12/39561a187d29f07fea2ad4232a081397 to your computer and use it in GitHub Desktop.
Save pjlamb12/39561a187d29f07fea2ad4232a081397 to your computer and use it in GitHub Desktop.
Unit Test for Component
import { FormBuilder } from '@angular/forms';
import { of } from 'rxjs';
import { DemoComponent } from './demo.component';
describe('DemoComponent', () => {
let component: DemoComponent;
let mockDeviceFulfillmentService;
const mockFormBuilder = new FormBuilder();
let mockActivatedRoute;
let mockAlertToasterService;
beforeEach(() => {
mockActivatedRoute = {
queryParams: of({}),
};
component = new DemoComponent(
mockDeviceFulfillmentService,
mockFormBuilder,
mockActivatedRoute,
mockAlertToasterService,
);
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
DeviceFulfillmentListComponent
✕ should create (5 ms)
● DeviceFulfillmentListComponent › should create
Component 'MainNavComponent' is not resolved:
- templateUrl: ./main-nav.component.html
- styleUrls: ["./main-nav.component.scss"]
Did you run and wait for 'resolveComponentResources()'?
at Function.get (../../../../node_modules/@angular/core/fesm2015/core.mjs:22659:27)
at getComponentDef (../../../../node_modules/@angular/core/fesm2015/core.mjs:1148:12)
at ../../../../node_modules/@angular/core/fesm2015/core.mjs:22468:34
at Array.forEach (<anonymous>)
at setScopeOnDeclaredComponents (../../../../node_modules/@angular/core/fesm2015/core.mjs:22463:18)
at flushModuleScopingQueueAsMuchAsPossible (../../../../node_modules/@angular/core/fesm2015/core.mjs:22114:21)
at TestBedImpl.checkGlobalCompilationFinished (../../../../node_modules/@angular/core/fesm2015/testing.mjs:24322:13)
at TestBedImpl.resetTestingModule (../../../../node_modules/@angular/core/fesm2015/testing.mjs:24138:14)
at ../../../../node_modules/@angular/core/fesm2015/testing.mjs:24495:21
at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (../../../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:412:30)
at ProxyZoneSpec.Object.<anonymous>.ProxyZoneSpec.onInvoke (../../../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:3833:43)
at _ZoneDelegate.Object.<anonymous>._ZoneDelegate.invoke (../../../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:411:56)
at Zone.Object.<anonymous>.Zone.run (../../../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:169:47)
at Object.wrappedFunc (../../../../node_modules/zone.js/bundles/zone-testing-bundle.umd.js:4333:34)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 21.427 s
Ran all test suites related to changed files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment