karma-runner / karma-mocha

A Karma plugin. Adapter for Mocha testing framework.
MIT License
379 stars 95 forks source link

No filtering by test name if run with karma-sinon-chai framework #192

Open segrey opened 7 years ago

segrey commented 7 years ago

Example project: https://github.com/tongrhj/karma-test/tree/cf4d63f6c91bd573adf224b626d2b96fce28488a Steps to reproduce:

  1. Start server

    ./node_modules/karma/bin/karma start
  2. Run tests

    ./node_modules/karma/bin/karma run -- '--grep=Testing the throttle function calls callback after 100ms'

    All tests are run unexpectedly.

Caused by executing karma.start() without passing config: https://github.com/kmees/karma-sinon-chai/blob/49b33ed97984dcadd87788606ca2131a7a0700da/chai-adapter.js#L17

Can be fixed on karma-sinon-chai side with

    karma.start(window.__karma__.config);

However, probably, it'd be better to make karma-mocha not dependent on correct behavior of 3rd party frameworks. For example, karma-jasmine fetches config directly from karma object: https://github.com/karma-runner/karma-jasmine/blob/v1.1.0/src/adapter.js#L324. Is it possible to implement a similar scheme for karma-mocha?

segrey commented 6 years ago

This issue also affects running single test in project generated with vue init webpack my-project command (https://youtrack.jetbrains.com/issue/WEB-32918). Please review PR: https://github.com/karma-runner/karma-mocha/pull/206 //cc @maksimr

lana-k commented 4 years ago

Proposed solution implemented in karma-sinon-chai v2.0.1: https://github.com/kmees/karma-sinon-chai/commit/0c4ae586ef9bffc9529f1f58c1b0a4627608004c