Skip to content

Commit

Permalink
Add grep option to karma testing (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Sep 22, 2023
1 parent 1ed3aeb commit e21d141
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,16 @@ To open in a browser and leave the browser open (to review UI components, debug,

```
karma start --browsers Chrome --single-run=False --debug --auto-watch
```

See also https://glebbahmutov.com/blog/debugging-karma-unit-tests/

To run for single test file you can use the `grep` option:

```
karma start --single-run --grep 'CpsiMapview.factory.Layer'
```

## Production Builds

```
Expand Down
9 changes: 9 additions & 0 deletions karma-conf.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ module.exports = function(config) {
'/CpsiMapview': '/base/app'
},

// the following works to limit the tests run
// see https://github.com/karma-runner/karma-mocha/issues/192
// also https://stackoverflow.com/questions/38876237/karma-start-passing-parameters
client: {
mocha: {
grep: config.grep
}
},

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'expect', 'sinon'],
Expand Down

0 comments on commit e21d141

Please sign in to comment.