-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
"require is not defined" after update to karma-electron 7 / electron 12 #53
Comments
That all looks good to me =/ We run our tests against these versions so it should just work. Sanity check: Have you upgraded to the latest |
I wonder if maybe it's a side-effect of karma-webpack. The new karma-webpack has an optimization that splits common dependencies into a shared module (the older version made a big bundle for every test file, each bundle having duplicates). This is what one test file looks like: // /absoluteElementOperations.test.2135415586.js
"use strict";
(self["webpackChunklume"] = self["webpackChunklume"] || []).push([["ElementOperations.test.2135415586"],{},
/******/ __webpack_require__ => { // webpackRuntimeModules
/******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
/******/ __webpack_require__.O(0, ["commons"], () => (__webpack_exec__("./dist/core/ElementOperations.test.js")));
/******/ var __webpack_exports__ = __webpack_require__.O();
/******/ module.exports = __webpack_exports__;
/******/ }
]); It is loaded in the karma's html entrypoint like this: <script type="text/javascript" src="/absoluteElementOperations.test.2135415586.js" crossorigin="anonymous"></script> and it gives hm. 🤔 |
Yea, using |
Oh.. My.. Goodness... those above options have to be inside the browserWindowOptions: {
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
nodeIntegrationInSubFrames: true,
contextIsolation: false,
}
}, It's all working smoothly now (but still with Webpack, and the output as CommonJS). |
I still keep getting these errors, but only in debug mode with a window open, regardless if I have the proper config. In "debug mode" I set When I run tests without debug mode enabled, Any ideas? |
Shot in the dark: It sounds like something in your |
Hmm. Yeah, no idea why something would be different. This is the first file I have in // karma-augment-node-path.js
const path = require('path')
process.env.NODE_PATH = path.resolve(process.cwd(), 'node_modules') + ':' + process.env.NODE_PATH
require('module').Module._initPaths()
console.log('################################################################')
console.log('################################################################')
console.log('################################################################')
console.log('################################################################')
console.log('################################################################') When I run with
When I run with
May the disconnected error have to do with it? I think that's just the open/refreshing of the debug window, right? |
I confirm the only difference in my config is |
Ok, I found a clue, but not sure what it points to. I noticed that when I first open the debug window and subsequently open the console, I see the expected It is only after I refresh the debug window that the errors happen. All subsequent runs after the first have the error. This explains why when The combination of my mistake, plus the fact that refreshing the Electron breaks it, totally did not help because no matter what options I tried, even if they were correct, things continued to not work. The question is, why are |
(No luck updating from Electron 14.0.1 to 15.0.0. Electron 15 completely crashes on any refresh attempt with devtools saying |
^ I think the issue is in Electron itself: karma-electron has launched Electron using I don't think there is any possible option that |
Now that we discovered |
Tooling is always tricky business. This is what I have in my config:
Did I miss something in the newer karma-electron?
The text was updated successfully, but these errors were encountered: