Giter Site home page Giter Site logo

Comments (15)

codymikol avatar codymikol commented on July 3, 2024

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.

subodhkumar avatar subodhkumar commented on July 3, 2024

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.

codymikol avatar codymikol commented on July 3, 2024

Which files are karma-mocha adding?

from karma-webpack.

codymikol avatar codymikol commented on July 3, 2024

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.

subodhkumar avatar subodhkumar commented on July 3, 2024

Which files are karma-mocha adding?

karma-mocha is adding karma-mocha/src/adapter.js

from karma-webpack.

subodhkumar avatar subodhkumar commented on July 3, 2024

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.

codymikol avatar codymikol commented on July 3, 2024

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.

subodhkumar avatar subodhkumar commented on July 3, 2024

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.

Screenshot 2022-11-28 at 12 07 36 PM

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.

codymikol avatar codymikol commented on July 3, 2024

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.

subodhkumar avatar subodhkumar commented on July 3, 2024

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.

codymikol avatar codymikol commented on July 3, 2024

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.

codymikol avatar codymikol commented on July 3, 2024

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.

subodhkumar avatar subodhkumar commented on July 3, 2024

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.

codymikol avatar codymikol commented on July 3, 2024

Can you share your project or at least configurations? I may be able to point you in the right direction.

from karma-webpack.

subodhkumar avatar subodhkumar commented on July 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.