Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma Unit test cases not working with CustomDynamicNodeComponent #89

Open
arun007sivan opened this issue Sep 19, 2024 · 8 comments
Open

Comments

@arun007sivan
Copy link

arun007sivan commented Sep 19, 2024

While writing unit test case for Angular 18 component which extends CustomDynamicNodeComponent , its throwing NullInjectorError even after providing mock ComponentEventBusService. How can we resolve this issue ?

image

@arun007sivan
Copy link
Author

describe('TargetComponent', () => {
  let component: TargetComponent;
  let fixture: ComponentFixture<TargetComponent>;
  let componentEventBusService: jasmine.SpyObj<MockComponentEventBusService>;
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [BrowserAnimationsModule, VflowModule],
      providers: [
        {
          provide: ActivatedRoute,
          useValue: {},
        },
        {
          provide: 'ComponentEventBusService',
          useClass: MockComponentEventBusService,
        },
        provideHttpClient(withInterceptorsFromDi()),
        provideHttpClientTesting(),
      ],
    }).compileComponents();

    fixture = TestBed.createComponent(TargetComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });
  it('should create', () => {
    expect(component).toBeTruthy();
  });
});

adding test case here.

@artem-mangilev
Copy link
Owner

Hi! I'll see how to fix this during the next month

@artem-mangilev
Copy link
Owner

artem-mangilev commented Oct 5, 2024

Decided to make that service as optional dependency, so you don't need to pass it to providers. Also wrote similar test to make sure CustomDynamicNodeComponent and CustomNodeComponent works without providers: cd129f6

I will release this during October.

UPD: published a pre-minor 0.13.0-0, so you may check here

@arun007sivan
Copy link
Author

Ok thanks for the quick response, i will check & revert back.

@artem-mangilev
Copy link
Owner

I released 0.13 with the fix, did you manage to check if this DI error disappear?

@arun007sivan
Copy link
Author

arun007sivan commented Nov 6, 2024

Image

Now its expecting HandleService

@artem-mangilev
Copy link
Owner

artem-mangilev commented Nov 8, 2024

Sorry, will be fixed in 0.14.2

UPD: in 0.15.0 as I already started doing this version

@artem-mangilev
Copy link
Owner

@arun007sivan Hi! Could you please check with this function?

@artem-mangilev artem-mangilev moved this from 0.16.0 to 1.0 in ngx-vflow Dec 8, 2024
@artem-mangilev artem-mangilev moved this from 1.0 to Done in ngx-vflow Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants