This project is configured to run parallel tests in an Angular application using Karma and the karma-parallel
plugin.
Ensure you have the following installed:
- Node.js (Latest LTS recommended)
- Angular CLI
- Chrome browser
Clone the repository and install dependencies:
npm install
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.
To execute tests in parallel mode, run:
ng test --watch=false --browsers=ChromeHeadlessNoSandbox
- Ensure all dependencies are installed correctly.
- If tests are failing due to resource constraints, reduce the
executors
count inkarma.conf.js
. - Use
logLevel: config.LOG_DEBUG
inkarma.conf.js
for debugging issues.