I'm in desperate need of help with testing about 12 components that are giving me trouble. I've been stuck on this for over 15 hours and it seems like my mocks may be the issue. Let's take one component as an example to illustrate the problems.
My testing setup involves Karma and Jasmine within an Angular 10 environment.
The problematic component is called ArchivedUserStoryOverview, which has its own controller to interact with Firebase. I'm trying to mock out the observables it returns (or at least that's what I think I'm doing). It's important to note that my app runs fine without any bugs; the issues only arise during testing.
Here is the code snippet for the actual component: Archiveduserstoryoverview.component.ts
import { Component, OnInit } from '@angular/core';
import { FirebaseController } from '../../services/firebase-controller';
import { ActivatedRoute } from "@angular/router";
@Component({
selector: 'app-archiveduserstoryoverview',
templateUrl: './archiveduserstoryoverview.component.html',
styleUrls: ['./archiveduserstoryoverview.component.css']
})
export class ArchiveduserstoryoverviewComponent implements OnInit {
// Component properties here
}
// Other parts of the component omitted for brevity
And here is the test file for the component: Archiveduserstoryoverview.component.spec.ts
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ArchiveduserstoryoverviewComponent } from './archiveduserstoryoverview.component';
// Additional imports and setup for testing
describe('ArchiveduserstoryoverviewComponent', () => {
// Testing logic here
});
// Additional tests and structure omitted for brevity
At the start of my testing process, I create Userstories and Users using a data structure from the Firebase backend.
After running all tests, I encounter three errors:
I'm puzzled by the "Cannot read property 'and' of undefined" error message. It seems unrelated to the methods I stubbed or mocked.
The second error relates to a missing provider for AngularFireDatabase even though I'm completely mocking out my own controller.
The final error is more straightforward, indicating that something expected to be truthy is actually undefined.
I've spent a significant amount of time trying different mock implementations, but none seem to solve the issue. If anyone could offer assistance, I would greatly appreciate it. Feel free to ask if you need to see other files.