karma-runner / karma-runner/karma

'Stop' always exits the process, does not respect overriden done parameter

Open
#3,395 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Expected behaviour

When programatically using karma, stop should respect overriden `done` argument of the server.

### Actual behaviour

Stop always exits the current process:

https://github.com/karma-runner/karma/blob/c67b90ab34ac8c3bc873a1861383cb561ad24de2/lib/middleware/stopper.js#L13-L14

### Environment Details

- Karma version (output of `karma --version`): `4.4.1`
- Relevant part of your `karma.config.js` file `n/a`

### Steps to reproduce the behaviour

1. `mkdir tmp`
1. `cd tmp`
1. `npm init --yes`
1. `npm i karma karma-chrome-launcher`
1. `touch index.js`
1. Add this to index.js:
```js
const { Server, stopper } = require("karma");
const server = new Server({ singleRun: false, autoWatch: false, browsers: ['ChromeHeadless'] }, () => console.log("Karma exiting"));
server.on("browsers_ready", () => {
stopper.stop({}, () => {
console.log('stop done!');
});
});
server.start()
```
1. Run `node index.js`

I would expect `'Karma exiting'` and `'stop done!'` to be logged in the console. Instead, the process exits.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.