Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"karma run" re-runs preprocessors for unmodified files #2829

Closed
segrey opened this issue Sep 19, 2017 · 7 comments · Fixed by JetBrains/ring-ui#516, Narshe1412/nuarca-sql#25 or karronoli/redpen#10

Comments

@segrey
Copy link
Contributor

segrey commented Sep 19, 2017

Expected behaviour

Running tests via "karma run" should not run preprocessors for unmodified files.

Actual behaviour

Running tests via "karma run" always runs preprocessors for all files (including unmodified ones).

Environment Details

  • Karma version (output of karma --version): 1.7.1
  • Relevant part of your karma.config.js file: see steps to reproduce

Steps to reproduce the behaviour

  1. Open https://github.com/babel/karma-babel-preprocessor/tree/v7.0.0 and update "karma" dependency to 1.7.1
  2. Run karma server: ./node_modules/karma/bin/karma start
  3. Run karma tests: ./node_modules/karma/bin/karma run
    Output:
...
19 09 2017 16:30:15.693:DEBUG [karma]: Refreshing all the files / patterns
19 09 2017 16:30:15.696:DEBUG [preprocessor.babel]: Processing "/home/segrey/samples/karma-babel-preprocessor/test/hello.js".
19 09 2017 16:30:15.728:DEBUG [preprocessor.babel]: Processing "/home/segrey/samples/karma-babel-preprocessor/test/generator.spec.js".
19 09 2017 16:30:15.735:DEBUG [preprocessor.babel]: Processing "/home/segrey/samples/karma-babel-preprocessor/test/hello.spec.js".
19 09 2017 16:30:15.741:DEBUG [preprocessor.babel]: Processing "/home/segrey/samples/karma-babel-preprocessor/test/generator.js".
...

Expected behaviour: unmodified files are not processed

@segrey
Copy link
Contributor Author

segrey commented Sep 19, 2017

This issue is relevant for WebStorm users, since it uses "karma run" for each test run. Related WebStorm issue: https://youtrack.jetbrains.com/issue/WEB-28736.

@S-K-A
Copy link

S-K-A commented Jan 25, 2018

2 Months later. It would be nice if this could be worked on (or around ;-) ). Either here or for JetBrains karma integration.
We are not able to use latest WebStorm Versions when it comes to unit testing.
Most of the developers are forced to keep the 2017.1.4 Version to be able to run tests locally, because this is the last one working correctly.

@johnjbarton
Copy link
Contributor

I wonder why you think unmodified files should not be preprocessed? In any case, the preprocessor plugin, not karma-runner, is responsible for preprocessing. Please ask about it on karma-babel-preprocessor.

@segrey
Copy link
Contributor Author

segrey commented Jan 25, 2018

@johnjbarton Correct, karma-babel-preprocessor is responsible for processing. However, I'm not sure it should be responsible for caching its response, e.g. checking file's last modified date. Or should it be?
Currently, fileList.refresh() does two things: re-globs all patterns and preprocesses all matched files. Why can the preprocessing of unmodified files be needed?

@maksimr
Copy link
Contributor

maksimr commented Jan 26, 2018

@johnjbarton could you explain why karma should run preprocessors for unmodified files?

Thanks

@johnjbarton
Copy link
Contributor

karma does not know anything about what the preprocessor does. How can it know whether a file needs to be preprocessed when another file is changed?

@johnjbarton johnjbarton reopened this Jan 26, 2018
@segrey
Copy link
Contributor Author

segrey commented Jan 28, 2018

@johnjbarton Right, it's probably relevant for karma watcher as well, not only "karma run" command. Because fileList.changeFile(filePath) runs preprocessor for a changed file only (here), not for files dependent on the changed file. So, this issue is about synchronizing behavior of karma watcher and "karma run" to preprocess the same set of files for the same changed files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants