karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.96k stars 1.71k forks source link

Testing fails to test certain files #2488

Open santaclauze opened 7 years ago

santaclauze commented 7 years ago

I am using Karma with a React boiler plate. Testing has been fine so far, but i encountered an issue where Karma simply skips a directory.

The directory is built in the same way as all other tested directories, the only notable difference that I was able to identify was that the length of the path seemed to enable or disable the Testing.

Expected behaviour

Test directory backoffice/app/components/bootstrap/atoms/CardDeckWrapper/tests/index.tests.js

Actual behaviour

Tests skips the file!

Steps to reproduce the behaviour

  1. Name a directory CardDeckWrapper
  2. Test --> result Test skipped
  3. Rename directory CDW
  4. Test --> result Tested

My hack right now is to create a directory with a SHORT name (that was kind of funny) FIX, in which I require() the testing files. This allows me to tests every file, but the bug not allowing Karma to go through directories with long names obviously persists.

Environment Details

kopax commented 7 years ago

I have the same bug here.

When the path is too long the .test.js file simply got ignored.

I fixed it by creating a FIX directory in every parents of my ignored tests, then by manually importing the test with require.

Could we tag this as bug ?

Environment Details

twolfson commented 7 years ago

I created a proof of concept to reproduce the issue and was unable to:

https://gist.github.com/twolfson/979d5f0975c64a790abca5003363336c

Could you provide more info about your karma.conf.js? I might have something configured differently than you which is causing the issue =/

begin-again commented 6 years ago

I've had similar problems with file names where karma simply would not load the file for testing (karma 1.71, windows 10, node 8). For instance, I had a file named app.directive.js that wouldn't get loaded until I renamed it to something without the string app in the name. I'm using simple glob patterns in my karma.conf.js file.

'app/**/*.module.js',
'app/**/*.js',
EzraBrooks commented 6 years ago

If you could submit a PR with tests on the preprocessor spec that demonstrate these pattern match failures, we could begin to diagnose this across multiple OSes - pattern matching has had some cross-compatibility issues.