The Angular 6 test command using npm has encountered a failure

I've been encountering a disconnect error while attempting to run Angular test cases. With over 1500 test cases written, it appears that the sheer volume may be causing this issue. Is there a way to resolve the disconnect error when running such a large number of test cases?

Here is the specific error message I receive during execution:

26 02 2021 10:36:47.160:DEBUG [Chrome 88.0.4324.150 (Linux x86_64)]: Disconnected during run, waiting 910000ms for reconnecting.
26 02 2021 10:36:47.160:DEBUG [Chrome 88.0.4324.150 (Linux x86_64)]: EXECUTING -> EXECUTING_DISCONNECTED
26 02 2021 10:51:57.169:WARN [Chrome 88.0.4324.150 (Linux x86_64)]: Disconnected (0 times)reconnect failed before timeout of 910000ms (ping timeout)
26 02 2021 10:51:57.170:DEBUG [Chrome 88.0.4324.150 (Linux x86_64)]: EXECUTING_DISCONNECTED -> DISCONNECTED

I have attempted to increase the wait time but to no avail.

The command I used to run the tests was:

ng test --code-coverage --watch=false --browsers=Chrome

Below is my Karma configuration file:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma'),
    ],
    client: {
      config: {
        browserConsoleLogOptions: true,
      },
      captureConsole: true,
      mocha: {
        bail: true
      },
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage'),
      reports: ['html', 'lcovonly'],
      fixWebpackSourcePaths: true
    },

    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: ['Chrome'],
    captureTimeout: 210000,
    browserDisconnectTolerance: 3, 
    browserDisconnectTimeout : 910000,
    browserNoActivityTimeout : 910000,
    singleRun: false
  });
};

If anyone has a solution for executing a large number of test cases in an Angular application, I would greatly appreciate your help. Thank you!

Answer №1

Give this a try.

Make sure to globally install version 6.2.9 of @angular/cli and create a new Angular 6 project. Run npm test on the new project and check if it functions as expected. If it works, examine the contents of karma.conf.js and package.json, as well as the version numbers in package.json. If it doesn't work, there may be an issue with your system.

For reference, you can find the versions of @angular/cli here: Angular CLI versions

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Guide on transferring information obtained from a service to an Angular datatable

Recently, I started working on Angular 4 and encountered an issue while trying to display data from an Angular service in JSON format using angular-datatable. Despite trying various options, I am unable to get the data to display within the columns of the ...

Error with CUSTOM_ELEMENTS_SCHEMA in Angular unit testing

Struggling with Unit tests for a new project that requires fixing. I added the "CUSTOM_ELEMENTS_SCHEMA" to prevent Angular from deeply inspecting child components, but now I'm encountering an error that I can't quite figure out. Unexpected value ...

Instructions on enabling Angular 2 to detect dynamically added routerLink directive

As illustrated in this Plunker, I am dynamically injecting HTML into one of my elements, which can be simplified as follows: @Component({ selector: 'my-comp', template: `<span [innerHTML]="link"></span>`, }) export class MyCo ...

The command "tsc" was not found in this bash session

Currently, I am using a MAC and attempting to set up TypeScript. I followed the installation process by running sudo npm install -g typescript and received the following output: Password: /Users/<myuserid>/node/bin/tsc -> /Users/<myuserid& ...

Typescript PDFjs encountering loading issues with corrupt files

In my Vue.js application, I have the following TypeScript class: /** Taken from https://github.com/VadimDez/ng2-pdf-viewer/blob/master/src/app/pdf-viewer/pdf-viewer.component.ts */ import { Component, Vue } from 'vue-property-decorator'; import ...

Error in TypeScript: Typography type does not accept 'string' type as valid

As I attempt to implement the Typography component from material-ui using TypeScript, I encounter a perplexing error message TypeScript is throwing an error: Type 'string' is not assignable to type 'ComponentClass<HTMLAttributes<HTMLE ...

What specific category does the enum object fall under?

How can I create a wrapper class for a collection of elements in an enumeration? export class Flags<ENUMERATION> { items = new Set<ENUMERATION>(); enu; // what type ? constructor(enu) { // what type ? ...

What is the best way to delegate the anonymous function logic contained within the subscribe() method?

Imagine you have a code block similar to this: constructor(private _http: HttpClient) { this.fetchUsers(5); } employees: any[] = []; fetchUsers(count: number) { this._http.get(`https://jsonplaceholder.typicode.com/users`).subscribe( ...

Troubleshooting issues with @HostListener in Angular2 RC1

Created a custom attribute directive called myOptional specifically for use with form inputs, to indicate that certain fields are optional. This is achieved by adding a class to the input and then displaying the optional text through css pseudo element ::a ...

Guide to redirecting to an ASP application using POST data from Angular 5

I'm currently working on integrating a payment gateway into my Angular application. This particular payment gateway is built using ASP. The instructions provided by the payment gateway provider instruct me to submit a form as a POST request to a spec ...

The issue at hand is that the component is not recognized as an NgModule

I am encountering an issue with my NgModule configuration: @NgModule({ imports: [ CommonModule ], exports: [ SP21LoadingBar ], declarations: [SP21LoadingBar] }) export class SP21LoadingBarModule { } When I run the CLI, ...

When I utilize a component to create forms, the React component does not refresh itself

One of the components I am working with is a form handling component: import React, { useState } from "react"; export const useForm = (callback: any, initialState = {}) => { const [values, setValues] = useState(initialState); const onCha ...

What is the process for generating an array of objects using two separate arrays?

Is there a way to efficiently merge two arrays of varying lengths, with the number of items in each array being dynamically determined? I want to combine these arrays to create finalArray as the output. How can this be achieved? My goal is to append each ...

In Visual Studio Code, beautification feature splits HTML attributes onto separate lines, improving readability and code organization. Unfortunately, the print width setting does not apply

I have done extensive research and tried numerous solutions, When using Angular and formatting HTML with Prettier, it appears quite messy as it wraps each attribute to a new line, for example: <button pButton class="btn" ...

Limit access to a menu following authentication

Within the sidebar section, there are 4 rubrics available (Administration, Marché, Portefeuille, Déconnexion). https://i.sstatic.net/O8zpH.png Upon user authentication, I want the Portefeuille rubric to remain hidden. To achieve this, I have implement ...

What makes it impossible to use var instead of let in ngFor?

My understanding is that in JavaScript, we typically use var and let for variable declarations. The main difference between the two is that var is scoped to the current function, while let is scoped to the current block. Therefore, theoretically I should b ...

The sorting feature is not performing as anticipated

I'm dealing with an array of objects fetched from the backend. When mapping and sorting the data in ascending and descending order upon clicking a button, I encountered some issues with the onSort function. The problem lies in the handling of uppercas ...

Using an Angular if statement to validate the current route

I have a modal component that needs to display specific data depending on whether the user came from '/tabs/tab1' or '/tabs/tab2'. The issue is that both sets of data are currently being displayed in the modal component HTML, and the if ...

Having trouble deploying my MEAN stack application on Heroku due to a MongoNetworkError: unable to establish a connection to the

Encountering difficulty connecting to MongoDB for application deployment, receiving error message "MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017". What are potential issues ca ...

There is an error in the TypeScript code where it is not possible to assign a string or

I'm struggling to resolve a typescript error. Upon checking the console log, I noticed that the regions returned by Set are an array of strings, which aligns perfectly with the region type in my state. Why isn't this setup working as expected? S ...