Skip to content

This project is configured to run parallel tests in an Angular application using Karma and the karma-parallel`plugin.

Notifications You must be signed in to change notification settings

NashTech-Labs/Parallel_Testing_in_Angular_using_karma

Repository files navigation

Parallel Testing in Angular using Karma

This project is configured to run parallel tests in an Angular application using Karma and the karma-parallel plugin.

Prerequisites

Ensure you have the following installed:

Installation

Clone the repository and install dependencies:

npm install

Configuration

The Karma configuration (karma.conf.js) includes the karma-parallel plugin for running tests in parallel. The key configurations are:

parallelOptions: {
  executors: 4, // Defaults to cpu-count - 1
  shardStrategy: 'round-robin'
},

browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
  ChromeHeadlessNoSandbox: {
    base: 'ChromeHeadless',
    flags: ['--disable-gpu', '--no-sandbox']
  }
},
  • executors: Number of parallel processes (default: CPU count - 1).
  • shardStrategy: Defines how tests are distributed.
    • 'round-robin': Distributes tests evenly across executors.
    • 'description-length': Uses test description length for distribution.
    • 'custom': Allows defining a custom strategy.
  • ChromeHeadlessNoSandbox: Runs tests in headless Chrome with necessary flags.

Running Tests

To execute tests in parallel mode, run:

ng test --watch=false --browsers=ChromeHeadlessNoSandbox

Troubleshooting

  • Ensure all dependencies are installed correctly.
  • If tests are failing due to resource constraints, reduce the executors count in karma.conf.js.
  • Use logLevel: config.LOG_DEBUG in karma.conf.js for debugging issues.

About

This project is configured to run parallel tests in an Angular application using Karma and the karma-parallel`plugin.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages