I'm currently in the process of setting up a unit test for my app.component. I've imported all the necessary components, but I keep encountering an error that's puzzling me. I activated "preserveSymlinks": true in my angular.json file, but the issue persists. How can I resolve this?
The error: Error: inject() must be called from an injection context
https://i.sstatic.net/tjH6H.jpg
Here is a snippet of my ts file:
import { Component } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { LoginService } from 'is-common';
import { CookieService } from 'ngx-cookie';
import { Api } from 'is-common';
// More code follows...
This is how I set up my Test:
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import { Api } from 'is-common';
import { LoginService } from 'is-common';
import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('AppComponent', () => {
// Code for testing the component...
My tsconfig.app.json configuration looks like this:
{
"extends": "./tsconfig.json",
// More compiler options and configurations...
}