Error: Timeout - Async function did not complete within 5000ms (set by...

Discussão em 'Angular' iniciado por Mahesh Dharwad, Janeiro 3, 2025.

  1. I am getting following error when ran the unit tests in pipeline for an Angular app.


    Error: Timeout - Async function did not complete within 5000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)
    at <Jasmine>

    This error occurs in the following unit test


    it('unit test description', (done) => {
    inject([HttpClient], (http: HttpClient) => {
    // Arrange
    const e1 = http.get('/base/src/assets/e1.json');
    const e2 = http.get('/base/src/assets/e2.json');
    expect(e1).toBe(e2);
    done();
    })();
    });

    But when ran the same in local system dont see any issues. It works fine. All the tests pass without any issue.

    Node version: v16.20.2 NPM version: 8.19.4

    Package.json is


    {
    "name": "abc",
    "private": true,
    "version": "1.0.0",
    "description": "abc",
    "scripts": {
    "ng": "ng",
    "update": "npm update --registry=https://registry.npmjs.org/",
    "audit": "npm audit --registry=https://registry.npmjs.org/",
    "start": "ng serve",
    "build": "ng build --configuration production",
    "build:dev": "ng build"
    },
    "dependencies": {
    "@amplitude/analytics-browser": "~1.3.0",
    "@angular/animations": "~15.2.9",
    "@angular/cdk": "~15.2.9",
    "@angular/common": "~15.2.9",
    "@angular/compiler": "~15.2.9",
    "@angular/core": "~15.2.9",
    "@angular/forms": "~15.2.9",
    "@angular/material": "~15.2.9",
    "@angular/material-moment-adapter": "~15.2.9",
    "@angular/platform-browser": "~15.2.9",
    "@angular/platform-browser-dynamic": "~15.2.9",
    "@angular/router": "~15.2.9",
    "@azure/storage-blob": "~10.5.0",
    "@jaames/iro": "~5.5.2",
    "@ngrx/effects": "~15.4.0",
    "@ngrx/store": "~15.4.0",
    "@ngrx/store-devtools": "~15.4.0",
    "@ngx-translate/core": "~14.0.0",
    "@ngx-translate/http-loader": "~7.0.0",
    "class-transformer": "~0.5.1",
    "class-validator": "~0.14.0",
    "d3": "~7.9.0",
    "file-saver": "~2.0.5",
    "jwt-decode": "~3.1.2",
    "lodash": "~4.17.21",
    "moment": "~2.29.4",
    "moment-timezone": "~0.5.43",
    "rxjs": "~7.5.7",
    "rxjs-compat": "~6.6.7",
    "sha.js": "~2.4.11",
    "typescript-collections": "~1.3.3",
    "zone.js": "~0.11.8"
    },
    "devDependencies": {
    "@angular-devkit/build-angular": "~15.2.8",
    "@angular-eslint/builder": "15.2.1",
    "@angular-eslint/eslint-plugin": "15.2.1",
    "@angular-eslint/eslint-plugin-template": "15.2.1",
    "@angular-eslint/schematics": "15.2.1",
    "@angular-eslint/template-parser": "15.2.1",
    "@angular/cli": "~15.2.8",
    "@angular/compiler-cli": "~15.2.9",
    "@angular/language-service": "~15.2.9",
    "@types/bingmaps": "7.0.20",
    "@types/d3": "~7.4.0",
    "@types/file-saver": "~2.0.7",
    "@types/jasmine": "~4.3.4",
    "@types/lodash": "~4.14.195",
    "@types/moment-timezone": "~0.5.30",
    "@types/node": "~20.3.1",
    "@typescript-eslint/eslint-plugin": "~5.43.0",
    "@typescript-eslint/parser": "~5.43.0",
    "codelyzer": "~6.0.2",
    "concurrently": "~7.4.0",
    "eslint": "~8.28.0",
    "jasmine-core": "~4.4.0",
    "jasmine-expect": "~5.0.0",
    "jasmine-marbles": "~0.9.2",
    "jasmine-spec-reporter": "~7.0.0",
    "karma": "~6.4.3",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "karma-junit-reporter": "~2.0.1",
    "reflect-metadata": "~0.1.13",
    "tslint": "~6.1.3",
    "typescript": "~4.9.5"
    }
    }

    Following is the karma.config.json


    module.exports = function (config) {
    config.set({
    basePath: '../',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
    require('karma-jasmine'),
    require('karma-coverage'),
    require('karma-chrome-launcher'),
    require('karma-jasmine-html-reporter'),
    require('karma-coverage-istanbul-reporter'),
    require('karma-junit-reporter'),
    require('@angular-devkit/build-angular/plugins/karma'),
    ],
    client: {
    clearContext: false, // leave Jasmine Spec Runner output visible in browser,
    jasmine: {
    random: false,
    },
    },
    coverageIstanbulReporter: {
    dir: require('path').join(__dirname, '../coverage'),
    reports: ['lcov', 'json', 'cobertura'],
    fixWebpackSourcePaths: true,
    },
    reporters: ['coverage-istanbul', 'progress', 'kjhtml', 'junit'],
    junitReporter: {
    outputDir: '',
    outputFile: 'abc.xml',
    },
    files: [
    {
    pattern: 'src/assets/**/*.json',
    watched: true,
    served: true,
    included: false,
    },
    ],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['ChromeHeadless'],
    captureTimeout: 100000,
    browserDisconnectTimeout: 10000,
    browserDisconnectTolerance: 3,
    browserNoActivityTimeout: 100000,
    flags: ['--disable-gpu', '--no-sandbox'],
    singleRun: true,
    });
    };

    How can I resolve this issue?

    Continue reading...

Compartilhe esta Página