karma-runner / karma-runner/karma
Inherit working directory from calling process
- Dominant language
- JavaScript
- Stars
- 12k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
### Expected behaviour
the working directory for my test runner is my actual working directory
### Actual behaviour
the working directory is /
### Environment Details
- Karma version (output of `karma --version`): 1.7.1
- karma config
```js
files: [
testIndexPath
],
plugins: [
'karma-coverage',
'karma-chrome-launcher',
'karma-jasmine',
'karma-jasmine-expect-jsx',
'karma-webpack'
],
preprocessors: {
[testIndexPath]: ['webpack']
},
//testIndex file
let context = require.context(path.resolve(process.cwd(), 'src/js/'), true, /\.js$/);
context.keys().forEach(context);
```
This is how karma-webpack is supposed to be used. However, however, when the file gets loaded by karma, process.cwd() is "/". I would expect it to inherit from the calling process, and also be settable by a configuration option.
Process.cwd() is necessary if you are trying to have a default test index file like my example, and to have it in node_modules. Otherwise I wouldn't know where to look for the code.
Is it possible to add a cwd option to allow setting of the cwd from the node api and the command line? Also, generally it makes more sense for cwd to default to inherit the calling process's cwd.
Contributor guide
Research direction
The issue names Karma's Node API and command-line interface rather than a specific file. Reproduce the cwd behavior with the supplied karma-webpack configuration, then trace how the runner is launched and configured; done means the calling process's cwd is inherited by default and an explicit cwd can be supplied through both interfaces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, developer-experience, testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100