Comments (9)
Alright, second PR is open: electron/electron#8890
Since this issue is not specific to our repo at all, we are going to close it. Thanks for the bug report and finding that edge case =)
from karma-electron.
Packages versions:
electron: 1.6.2
karma: 1.5.0
karma-electron: 5.1.1
karma-jasmine: 1.1.0
karma-ng-html2js-preprocessor: 1.0.0
angular: 1.6.2
angular-mocks: 1.6.2
from karma-electron.
Thanks for the detailed bug report. I'm not sure what would cause this so we'll definitely need to triage. I'll perform a triage by the end of the weekend
from karma-electron.
We have successfully reproduced the error. We were able to reproduce with something as simple as:
var electron = require('electron');
console.log(electron);
My hunch is this is an issue in Karma's serializer due to Electron using some native modules but I'll keep on digging
from karma-electron.
Okay, we've traced down the source of this issue. electron
is using a Proxy
constructor for its remote functions:
https://github.com/electron/electron/blob/v1.6.3/lib/renderer/api/remote.js#L170-L190
Proxies cannot be serialized without causing a TypeError
:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString
new Proxy(function x () {}, {}).toString()
// VM594:1 Uncaught TypeError: Function.prototype.toString is not generic
// at Proxy.toString (<anonymous>)
// at <anonymous>:1:33
Unfortunately, proxies can't be detected either (due to them being proxies -- intentionally transparent). However, we can detect them having serialization issues and provide a fallback.
case 'function':
try {
return obj.toString().replace(/\{[\s\S]*\}/, '{ ... }')
} catch (err) {
if (err instanceof TypeError) {
return 'Proxy(function ' + (obj.name || '') + '(...) { ... })';
} else {
throw err;
}
}
which yields:
Object{clipboard: Object{availableFormats: Proxy(function remoteMemberFunction(...) { ... }), has: Proxy(function remoteMemberFunction(...) { ... }),
Our plan of action is 2 part:
- Add a
try/catch
to Karma so it falls back when encountering proxies - Add
toString
logic to Electron'sProxy
wrapper
new Proxy(function x () {}, {get: function () { return function () { return x.toString() }; }}).toString()
// "function x() {}"
from karma-electron.
As a workaround for you, you should be able to use a fork of Karma with the patched serializer (which it seems you're already doing). This can be formalized by a git+ssh
URL but whatever works for you
https://docs.npmjs.com/files/package.json#git-urls-as-dependencies
from karma-electron.
Okay, 1 PR down -- Karma karma-runner/karma#2595. 1 PR to go
from karma-electron.
Finally got the repo locally bootstrapped. Took a lot longer than I expected because I missed the quick bootstrap notes again:
from karma-electron.
Great! Thanks for being quick to react, I will look forward for your PR's to be merged and released.
from karma-electron.
Related Issues (20)
- How to use with karma-babel? HOT 27
- `electron` did show not nothing happen then HOT 1
- Can't import nodejs modules in an angular-cli project (Typescript) HOT 1
- Errors without stack traces coming from karma-electron? HOT 5
- running with ndb for debugging? HOT 2
- Unable to open Electron window using --show HOT 3
- Electron 5 nodeIntegration HOT 12
- Custom launcher `require` mechanism doesn't work HOT 4
- Module paths are messed up HOT 5
- Error: Karma plugin is meant to be used from within Angular CLI and will not work correctly outside of it HOT 1
- How to configure NODE_PATH for the Electron instance? HOT 24
- [feature] option like 'require', but for renderer processes. HOT 1
- Karma times out when using Electron 9 and client.useIframe = false HOT 20
- Non-context aware native modules in renderer will cause specs to error HOT 3
- [questions] Is Electron 12 supported? HOT 16
- electron V12.0.4---------require is not defined HOT 3
- ES Modules HOT 2
- "require is not defined" after update to karma-electron 7 / electron 12 HOT 12
- Regardless of the `browserWindowOptions.show` value, a window always opens. HOT 12
- sqlite3 stalls with nodeIntegration true contextIsolation false HOT 12
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-electron.