Karma No binary form ChromeHeadless

Error while running ng test with karma:

Karma v6.4.1 server started
Launching browsers ChromeHeadless with concurrency unlimited
Starting browser ChromeHeadless
No binary for ChromeHeadless browser on your platform.

Solution: The solution to fix No binary for ChromeHeadless browser on your platform issue is to add the following code at the top of the file in karma.conf.js:

const process = require("process");
process.env.CHROME_BIN = require("puppeteer").executablePath();

The karma.conf.js file will look like this:

const process = require("process");
process.env.CHROME_BIN = require("puppeteer").executablePath();

module.exports = function (config) {
......
};