I'm encountering an issue with my pipeline, where a front-end unit test is failing in the pipeline but passes locally when running the 'yarn test' command.
Below is my test file:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MyComponent } from './my.component';
import { SharedModule } from 'src/app/shared/shared.module';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
describe('BsGapRepoComponent', () => {
let component: MyComponent;
let fixture: ComponentFixture<BsGapRepoComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [MyComponent],
imports: [SharedModule, NoopAnimationsModule]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
My component file :
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-compo',
templateUrl: './my.component.html',
styleUrls: ['./my.component.css']
})
export class myComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
It's worth noting that this is a new component.
Here is the failure log from GitLab:
PhantomJS 2.1.1 (Linux 0.0.0) MyComponent should create FAILED
TypeError: undefined is not an object (evaluating 'this.get_container_ul()[0].className') thrown
TypeError: undefined is not an object (evaluating 'this.get_container_ul()[0].className') thrown
PhantomJS 2.1.1 (Linux 0.0.0): Executed 112 of 185 (1 FAILED) (0 secs / 1 min 25.792 secs)
PhantomJS 2.1.1 (Linux 0.0.0) MyComponent should create FAILED
TypeError: undefined is not an object (evaluating 'this.get_container_ul()[0].className') thrown
TypeError: undefined is not an object (evaluating 'this.get_container_ul()[0].className') thrown
PhantomJS 2.1.1 (Linux 0.0.0) MyComponent should create FAILED
TypeError: undefined is not an object (evaluating 'this.get_container_ul()[0].className') thrown
TypeError: undefined is not an object (evaluating 'this.get_container_ul()[0].className') thrown
I am using Angular v8.
Thank you.