Comments (11)
Yea, it should definitely be possible. Try the following set up:
- Define a custom launcher which extends ours but sets a
--show
flag- Documented here: https://github.com/twolfson/karma-electron/tree/5.1.1#launcher-configuration
- No need for the
userDataDir
setting
- Launch Karma in continuous mode
karma start --no-single-run
- Electron should launch Karma window with "DEBUG" button in upper right
- Click "DEBUG" button and window should open up where you can open Chrome DevTools and get to debugging manually
from karma-electron.
@rr326 You're super close but missing 1 final step. We need to refresh the page with DevTools open so it doesn't ignore the debugger
call. Here's an example screenshot from one of my repos:
from karma-electron.
How do I set a manual breakpoint? My normal process is to run a test, if it fails, put in a debugger
line in the code in the appropriate place, and then play around. When running my multiple karma tests with the above setup, the Karma window opens and I can click the Debug button, but the tests have already failed and the breakpoint is already past.
How do I do this, or is there a better way?
from karma-electron.
Duh - of course. I had figured that out when I was debugging in Chrome but forgot and thought my problem was electron related. Thank you - works perfectly.
from karma-electron.
Is it possible to set karma to load the debug page by default on run without requiring me to click on the debug button? Using sauce labs launcher is practically impossible for me to debug even with screenshots enabled because all that's visible in the screenshots is the initial browsers-list page :/
from karma-electron.
I think it should be possible to set the parent window location to the debug page via:
window.parent.location = '/debug.html';
However, that will prob kill any feedback from the browser to Karma's Node.js core (Karma uses websockets to talk back to a live server with 1 parent page creating new child pages for running tests which communicate via cross-frame methods)
A few other solutions might be:
- Explore getting off of our
client.useIframe: false
flag by seeing ifwebviews
can replaceiframes
in Karma- Initially skipped due to trying to minimize friction with Karma library
- Explore using
client.runInParent
- Didn't exist as an option at the time of creation
- Also weary of side-effects due to leaky tests
Also, I'm curious -- Sauce Labs doesn't seem to list Electron as a supported browser/application. Is there any reason you're using their launcher?
from karma-electron.
My main dev machine is a Chromebook, so running electron non-headless won't work (unless I use a high-resource Ubuntu desktop provided by Crouton on an alternate vt but that has other issues which I like to avoid).
When I debug Node.js apps, I run them with node --inspect-brk
then I can open chrome://insect
in a Chrome OS tab and inspect the Node app. It would be great to do the same with the Electron processes (while they are headless). Do you know if this is currently possible?
from karma-electron.
Coincidentally, I saw that ChromeHeadless
(from karma-chrome-launcher
) specifies --remote-debugging-port=9222
so I'm guessing everything will work if we do the same. Going to take a shot at it...
from karma-electron.
Also, in the future, please open a separate issue for such things @trusktr. This isn't the same as the original question
from karma-electron.
Okay, so --remote-debugging-port=9222
is a no go. The reason is that Karma automatically cleans up its iframe/child window contexts whenever a test suite completes. We can navigate to http://localhost:9222/ but there won't be a child context with the proper hooks for us to run
karma-chrome-launcher
agrees on this topic in an issue that you (@trusktr) even opened:
karma-runner/karma-chrome-launcher#179
If you'd like to try this out yourself, add it as a flag in our launcher configuration and run karma
in continuous mode:
https://github.com/twolfson/karma-electron/tree/6.0.0#launcher-configuration
One other option I thought of was accessing http://localhost:9876/debug.html from a browser. However, due to being karma-electron
, we're leveraging Node.js' require
so we need to be in an Electron browser for that to work. At that point, we should be using the debugger flow in this document
tl;dr We need to be in an Electron window to get the proper require
bindings
from karma-electron.
Locking this issue to avoid continuing the unrelated thread here
from karma-electron.
Related Issues (20)
- `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
- Consider migrating this great work to @web/test-runner. 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-electron.