I need to spy on the public property in angular service. But this property doesn't have getter or setter, therefore, I couldn't spy on that property.
Always get or set is required to use that SpyOn
. If I don't provide it, it is set as 'get'. Is there any other way to mock or spy on public property without getter or setter? And why are those methods not available? Am I using an anti-pattern by exposing a public property from service?
This is the code with the public variable that I need to mock:
@Injectable()
export class StudentService {
public students = [];
.................
}