I've joined a project based in Angular8.
Every time I run the tests I get a different results in my local machine. When I push my branch, in the Gitlab runner, I also have different results.
This is the way that we run the tests:
ng test --no-watch --no-progress --browsers=ChromeHeadlessCI
Those are the versions that we use:
"devDependencies": {
"@angular-builders/custom-webpack": "^8.2.0",
"@angular-devkit/build-angular": "^0.803.20",
"@angular/cli": "^8.3.4",
"@angular/compiler-cli": "^8.2.14",
"@angular/language-service": "^8.2.6",
"@types/jasmine": "^2.8.16",
"@types/node": "^10.14.18",
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"codelyzer": "^5.0.1",
"eslint": "^6.7.2",
"eslint-config-google": "^0.14.0",
"jasmine-core": "^3.4.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^3.1.4",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^2.1.0",
"karma-htmlfile-reporter": "~0.3",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"karma-junit-reporter": "^1.2.0",
"protractor": "^5.4.2",
"rxjs-tslint": "^0.1.7",
"ts-node": "~7.0.1",
"tslint": "^5.20.0",
"typescript": "3.5.3",
"webpack": "^4.41.2"
}
Sometimes I understand the test errors, like :
PatientClinicTrialsComponent should create FAILED
Uncaught [object Object] thrown
I fixed that way:
if (examOrdersForPatient && examOrdersForPatient.length > 0) {
I added the if (examOrdersForPatient
to the condition, so the Test is fixed.
But then, I have some errors in other components that have already passed the tests for my colleagues, like :
MessageComponent should create FAILED
Uncaught [object Object] thrown
import { Component, OnInit, Inject, ViewEncapsulation } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { DialogData } from '../shared/DialogData';
@Component({
selector: 'envi-message',
templateUrl: './message.component.html',
styleUrls: ['./message.component.css'],
host: { '(window:resize)': 'onResize($event)' }
})
export class MessageComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<MessageComponent>,
public sanitizer: DomSanitizer,
@Inject(MAT_DIALOG_DATA) public data: DialogData) { }
ngOnInit() {
}
}
This MessageComponent has "nothing" in the code. And it passed the tests for my colleagues.
I can't understand:
- Why I get different results in local tests and Gitlab runner (when the versions are equal)
- Why my branch (on Gitlab runner) is throwing error in tests components that are ok in my colleagues tests
- Is
ng test
randomly checking the components? I mean. Is it not testing everything in each run?
I'm sorry but I could'nt find a answer for all this problems. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire