-
Notifications
You must be signed in to change notification settings - Fork 12k
karma jsdom launcher hangs #11561
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
Comments
Two and a half months later, I revisit this defect. I am not able to reproduce it. Closing this issue. |
Verified with Angular CLI: 6.2.4 |
I am facing this issue. $ ng new karma-jsdom-demo
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS
$ cd karma-jsdom-demo
$ yarn add jsdom karma-jsdom-launcher -D
$ vi src/karma.conf.js
// edit karma.conf.js as shown below @@ -7,7 +7,7 @@ module.exports = function (config) {
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
- require('karma-chrome-launcher'),
+ require('karma-jsdom-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
@@ -25,7 +25,7 @@ module.exports = function (config) {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
- browsers: ['Chrome'],
+ browsers: ['jsdom'],
singleRun: false
}); $ yarn test My environment: $ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 7.1.4
Node: 10.12.0
OS: darwin x64
Angular: 7.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.11.4
@angular-devkit/build-angular 0.11.4
@angular-devkit/build-optimizer 0.11.4
@angular-devkit/build-webpack 0.11.4
@angular-devkit/core 7.1.4
@angular-devkit/schematics 7.1.4
@ngtools/webpack 7.1.4
@schematics/angular 7.1.4
@schematics/update 0.11.4
rxjs 6.3.3
typescript 3.1.6
webpack 4.23.1 |
Have moved on w/ using Jest as my headless browser test runner. |
@catull I would appreciate if you reopen this issue for those who are still using Karma. |
@kimamula Sure, do not expect assistance from me though. I found a more suitable solution with Jest. |
Thanks! |
Don't know if they also support Edge on Windows. |
@filipesilva @mgechev any tip to fix this bug? |
@tiaguinho I'm not very sure myself actually. I suppose the starting point is to figure out what's happening. It's start by trying to strip down the the karma config in a CLI project in order to not have any CLI specific stuff, then add a basic test and karma-jsdom, to see if that work. Once that works I'd add back the CLI stuff. See what breaks then. Try to get some logs or karma events or something that tells me where things go wrong. I've never used karma-jsdom myself so it's hard to imagine what's going wrong. |
I've found a fix, but it's a bit hacky. The problem is something to do with the way JSDom performs synchronous requests, which are used for loading My hack is to force JSDom to treat all scripts as asynchronous. In theory this could break your application; but at least for Angular apps, it doesn't seem to matter. Here is the hack:
Please let me know if this works for you. |
Thanks, @andrewpmontgomery this hack will help a lot of people. |
No, it isn't an Angular CLI issue. The problem lies in karma-jsdom-launcher. Most other karma launchers (e.g. karma-chrome-launcher, karma-phantomjs-launcher) use Node's JSDom isn't without blame. It really ought to use async/await to handle synchronous XHR, but that would require major refactoring. I'm exploring the possibility of adding a runtime argument to JSDom which would force all requests to be asynchronous, then making karma-jsdom-launcher use that option. I don't know when or if I'll be able to do that, or whether such a change would even be welcomed by JSDom's maintainers. In the meantime, anyone with urgent requirements is advised to use my hack above. (I use a postinstall script to patch the file.) |
@andrewpmontgomery thank you for sharing your findings! Let's close the issue here and move it to the attention of the maintainers of If there's something on our side, feel free to open another issue with details. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report
Area
Versions
Angular CLI: 6.0.8
Node: 10.6.0
OS: linux x64 (Linux Mint)
Angular: 6.0.9
Npm: 6.1.0 and 6.2.0
Reproduction steps
ng new appWithJsdom
cd appWithJsdom
npm install
npm install karma-jsdom-launcher jsdom --save-dev
The log given by the failure
Then
ng test
displays build statements in CLI:The the console is cleared, nothings happens.
Ctrl-c eventually leads me back to the console.
This is repeatable.
No other user is connected to the desktop, no other
node
instances are running concurrently.Can't really run too many processes on it anyway.
When I use 'Chrome' or 'ChromeHeadless', the browser pops up etc, runs the tests all green.
Eveidently, I have the Chrome browser installed locally.
Desired functionality
I need a way to run the UI tests in a build process.
Tried PhantomJS - no luck.
Would like to use
jsdom
as test browser for builds - as it does headless mode with minimal effort.Can't install a browser on the build server.
Though
puppeteer
and ChromeHeadless, the karma launcher fails with not finding libX11.so ...The text was updated successfully, but these errors were encountered: