Comments (15)
In v5 you can require all of the files you want to include in your entry point rather than pass them in via configuration. Let me know if that works for you.
from karma-webpack.
Thanks for the response. In our use case we have set all the entrypoints.
however as shared above karma-mocha is adding few files which is not configured by us. With v5 as karma-webpack as itβs not adding files in the preprocessor those files are part of bundle output causing the error.
Are you recommending to import(set in the entry section) the files added by karma-mocha by us explicitly.
from karma-webpack.
Which files are karma-mocha adding?
from karma-webpack.
Are you recommending to import(set in the entry section) the files added by karma-mocha by us explicitly.
If you mean these files are created by you and added in your mocha config, yes, this should fix your problem.
from karma-webpack.
Which files are karma-mocha adding?
karma-mocha is adding karma-mocha/src/adapter.js
from karma-webpack.
Are you recommending to import(set in the entry section) the files added by karma-mocha by us explicitly.
If you mean these files are created by you and added in your mocha config, yes, this should fix your problem.
the files are not created by us, but are added by karma-mocha
. These files used to be picked up by karma-webpack v4 here. But not anymore in v5
from karma-webpack.
Can you post the error that you're getting and configs for webpack / karma / mocha? We have integration tests for karma-mocha so I know its possible to use in v5.
from karma-webpack.
Hi @codymikol,
In our project, we construct a customTest.js
at the root level of project which has import to all the test-entry points for the project. We trigger the karma process from the root level on the customTest.js
. In our karma.config.js
we have the following entry of preprocessor
preprocessors: {'**/*.js': ['webpack']}, // include add JS files from project root
I checked the integration tests in karma-webpack
& checked how its working. I was able to simulate the error we are facing by making changes to one of the tests(link to the forked karma-webpack project with the code changes: #1, #2)
I have updated the preprocessor
entries to point to the root location of the project as we have in our project. If you could clone the forked project & execute npm run test
you will see the below error which we are getting.
This error is thrown as the js
files(#file1, #file2) added by karma-mocha
as allowed to be processed by the karma-webpack
plugin due to the updated preprocessor
pattern in karma config. However, with v5 the plugin is not allowing any new file additions as compared to v4
As the plugin is skipping the files added by karma-mocha
(or plugin which might have similar code) the following code in karma
is finding empty content for files added by karma-mocha
& causing the error while setting sha1
to undefined
Hope this conveys the issue.
I have the below followup queries.
- Is setting the
preprocessor
path at the root level a valid entry? - if Yes, should this error be a bug?
- If No,
karma-webpack
v4 used to allow it. Should this change in option be documented.
Thanks again for your time in checking & responding. Really appreciate it.
from karma-webpack.
This is trying to run the webpack preprocessor on all files in the repository including node_modules via globbing, try using a single file that specifies exactly what you want to import like the index.scenario.js file.
from karma-webpack.
So is including the files on node_modules as part of preprocessor pattern invalid?
If so, this used to work in karma-we pack v4. Also, any reason for removing add files code in v5?
from karma-webpack.
The new pattern essentially just recursively imports everything, so there shouldn't be a need to specify what those files might be
index.test.ts
requireAll('./tests/**/*/*.spec.js') -> this imports all test cases
require('./src/index.ts') -> this imports all node_modules / source code needed for your app
from karma-webpack.
note that requireAll isn't actually a node built in, I use require.context
to find and require all my test cases and alias it as requireAll
.
from karma-webpack.
The new pattern essentially just recursively imports everything, so there shouldn't be a need to specify what those files might be
index.test.ts requireAll('./tests/**/*/*.spec.js') -> this imports all test cases require('./src/index.ts') -> this imports all node_modules / source code needed for your app
Can you please explain what is new pattern you are referring here
from karma-webpack.
Can you share your project or at least configurations? I may be able to point you in the right direction.
from karma-webpack.
Updated the preprocessor pattern to include only test files to address the issue we faced. Thanks for the support
from karma-webpack.
Related Issues (20)
- 5.0 crashes on MacOS (Preprocessor, Plugin), fixed on master -> Release 5.1? HOT 8
- Trying to add karma-webpack to angular karma config HOT 2
- karma.conf.js being treated as entrypoint results in many errors from webpack 5 HOT 2
- Webpack Errors being reported twice.
- Process is not defined HOT 1
- Error during file loading or preprocessing HOT 7
- Webpack file cache isn't generated when webacpack watch option is false/nothing
- karma-webpack does not respect webpack mode = "production" HOT 3
- I have the same problem. HOT 1
- Issue with Webpack 5 unable to find file 404 (works with webpack 4) HOT 1
- Don't warn overriding [name].js to [name].js
- Figure out a publishing Github Workflow
- Ensure all project dependencies have no auditing issues
- Provide a migration path from karma-webpack
- Update the README.md
- Release 5.0.1 HOT 6
- Support Node >= 10 in 5.0.2 HOT 1
- Webpack `optimization` configuration is not supported anymore HOT 3
- Webpack configuration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karma-webpack.