Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

No test found after updating karma-sinon-chai to >= v2.0.1 #79

Closed
lana-k opened this issue May 5, 2020 · 2 comments
Closed

No test found after updating karma-sinon-chai to >= v2.0.1 #79

lana-k opened this issue May 5, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@lana-k
Copy link

lana-k commented May 5, 2020

Environment:

  • OS: Linux Mint 18.3
  • Node v10.20.1
  • karma v5.0.4
  • karma-chrome-launcher v3.1.0
  • karma-mocha v2.0.1
  • karma-sinon-chai v2.0.2
  • Angular/Karma Test Explorer v1.1.0
  • Test Explorer UI v2.18.0

Steps to reproduce:

  • update karma-sinon-chai to >=v2.0.1
  • reload tests in Test Explorer UI panel
    Expected result: tests are displayed in the panel
    Actual result: no tests found

Reason:

angular-karma_test-explorer in out/core/karma/karma-runner.js passes strange template:

const fakeTestPatternForSkippingEverything = "$#%#";

This template is used by karma runner as a filter with grep argumet. See out/core/integration/karma-http-client.js:

  config.clientArgs = [`--grep=${tests}`];

But there was a bug about grep is not working with karma run if it uses karma-sinon-chai:
karma-runner/karma-mocha#192. So, --grep=$#%# was actually ignored and all tests were found and displayed in the Test Explorer UI panel.
But the bug was fixed on karma-sinon-chai in v2.0.1: https://github.com/kmees/karma-sinon-chai/commit/0c4ae586ef9bffc9529f1f58c1b0a4627608004c/. That's why after updating there was no tests found (because grep is working now and it filtered all tests):

[23:38:59] INFO: Listening to AngularReporter events on port 9999
[23:39:18] INFO: Test loading completed - No tests found

How to fix:

In karma-runner.js replace

const fakeTestPatternForSkippingEverything = "$#%#";

with

const fakeTestPatternForSkippingEverything = "";

Important note:

The proposed solution works only for Angular/Karma Test Explorer v1.1.0. Since v1.2.0 with modified karma-runner.js there is this problem:
https://gyazo.com/d4e13223cdad5a9de2863f30b89b9454

@lana-k lana-k added the bug Something isn't working label May 5, 2020
@Raagh
Copy link
Owner

Raagh commented May 5, 2020

Hi @lana-k thank you for commenting. Currently, only karma-jasmine is supported(which is the default for Angular). The weird pattern you mention is the way the test explorer can load all tests without running them. In karma-jasmine when you pass in a pattern that is not matched, it skips all tests so they can be read without running them, which is a great behavior for the load functionality. On run, we pass in the correct grep which runs the specific test and skips all others. It would be nice to support other types of framework, would you like to submit a pull request that works with sinon-chai and jasmine?

@Raagh Raagh closed this as completed Jun 18, 2020
@skaempfer
Copy link

Hi @Raagh, I came across this issue while investigating the possible use of your test explorer in a tech setup including Aurelia, TypeScript, Webpack, Karma, Mocha and Chai. When switching Mocha with Jasmine it works smoothly.
My question: Are you aware of blockers that prevent supporting Mocha as well as Jasmine tests (besides the actual work of implementing support)? If you are not aware of show stoppers I hope I can find some time working on supporting Mocha as well. I am completly new to extension development though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants