0
votes

We have a legacy Angular 4 project using SystemJS. We have been asked to implement unit test cases using Jasmine and Karma. I started writing a test suite for one component. It looks something like this (pseudo code below):

beforeEach(async(() => {
         TestBed.configureTestingModule(
                    imports,
                    providers,
                    declarations etc.
                ).compileComponents();
    }));

Now if I just add a simple dummy test case to this suite, it fails with the error:

async callback was not invoked within timeout specified by jasmine.default_timeout_interval

If I remove the call to compileComponents, it starts working. On the other hand, if I use a very basic component with no providers and child components, the setup works. So I am guessing that the various imports/providers are causing it to break somehow.

Has anyone faced such an issue before?

The reason I need compileComponents is that we are using templateUrls and not inline HTMLs in our components.

Thanks

1
Does this answer your question? Angular test with `async` causing Jasmine timeout?Gecko

1 Answers

0
votes

Why do you need "async" to configure testing modules?

beforeEach(() => {
 TestBed.configureTestingModule({
     imports: [],
     declarations: [],
     providers: []
 });
 const fixture = TestBed.createComponent({{componentName}});
 fixture.detectChanges();
});