Code Monkey home page Code Monkey logo

Comments (5)

twolfson avatar twolfson commented on July 20, 2024

This is likely caused by the same issue in #40. We need to wrap all files to provide the proper paths for require and module.paths to load against

https://github.com/twolfson/karma-electron/blob/6.1.1/lib/node-integration-iframe.mustache.js#L36

Please see README for setting up preprocessors and client.useIframe

https://github.com/twolfson/karma-electron/tree/6.1.1#getting-started

from karma-electron.

jushar avatar jushar commented on July 20, 2024

First of all, thanks for your great work on issue #40.

I migrated the test project to version 6.3.0 and added preprocessors and client.useIframe as you suggested. However, I'm still experiencing the same problem.

You can review all my changes to a default Angular installation here: https://github.com/Jusonex/karma-electron-testapp/compare/ddbab1e...master

I also added a require("sqlite3") line that demonstrates the problem in a more practical manner. Since sqlite3 contains native modules, it has to be loaded as webpack external.
You can reproduce the problem by just running npm test and opening the dev tools.

from karma-electron.

twolfson avatar twolfson commented on July 20, 2024

Okay, let's start from the beginning to I fully understand the issue

What is the behavior you're seeing on launch? Are tests running? What's the expected behavior?

from karma-electron.

jushar avatar jushar commented on July 20, 2024

What is the behavior you're seeing on launch?

21 06 2019 10:01:44.822:INFO [karma-server]: Karma v4.0.1 server started at http://0.0.0.0:9876/
21 06 2019 10:01:44.823:INFO [launcher]: Launching browsers CustomElectron with concurrency unlimited
karma-electron: `--show` is now deprecated. Please use `browserWindowOptions.show` instead
21 06 2019 10:01:44.832:INFO [launcher]: Starting browser Electron
21 06 2019 10:01:49.666:WARN [karma]: No captured browser, open http://localhost:9876/
21 06 2019 10:01:49.985:INFO [Electron 5.0.4 (Node 12.0.0)]: Connected on socket CdMl_yYqQ550D6QAAAAA with id 18121251
Electron 5.0.4 (Node 12.0.0) ERROR
  {
    "message": "Uncaught Error: Cannot find module 'sqlite3'\nRequire stack:\n- C:\\Dev\\karma-electron-repro\\testapp\\node_modules\\electron\\dist\\resources\\electron.asar\\renderer\\init.js\nat internal/modules/cjs/loader.js:662:5\n\nundefined",
    "str": "Uncaught Error: Cannot find module 'sqlite3'\nRequire stack:\n- C:\\Dev\\karma-electron-repro\\testapp\\node_modules\\electron\\dist\\resources\\electron.asar\\renderer\\init.js\nat internal/modules/cjs/loader.js:662:5\n\nundefined"
  }

Are tests running?

No, because it errors before tests are executed.

What's the expected behavior?

I expect the error message to not appear and tests run successfully. In ng serve/webpack-dev-server mode, using modules from the node_modules folder works perfectly fine (assuming webpack externals are set up correctly, but that's unrelated to this issue).

from karma-electron.

twolfson avatar twolfson commented on July 20, 2024

Ah, okay. It sounds like that could be us but it could also be a configuration error or a missing plugin

The repo has too much content for me to quickly and easily verify that the issue is karma-electron. Can you create a minimal version which only has karma-electron, your testing framework (e.g. jasmine), and is reproducing the error?

from karma-electron.

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.