-
Notifications
You must be signed in to change notification settings - Fork 12k
How to run jasmine tests without browser ? #2013
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
by default the cli installs the karma-chrome-launcher. you could try installing a headless browser like phantomjs |
Here is how I did it.
Then I modified the
Since you want a completely headless experience, you can remove Chrome from the |
Works like a charm, thanks ! |
Change karma config file - launch PhantomJS instead of Chrome, set PhantomJS as browser. Run $ npm i --save-dev karma-phantomjs-launcher so karma knows about new launcher. This is as per angular/angular-cli#2013 This errors - http://stackoverflow.com/questions/42640317/phantomjs-error-while-running-tests-in-angular-cli/42657675#42657675 Once polyfills added, $ npm install --save intl Newly installed packages reflected in packages.json
Hi all, For me it's still not working. I've followed all these steps as well. 1. Install
|
@cbeldacap I just learned that |
@cbeldacap Same issue for me. Have you got solution now? |
@dujuanxian |
Same as @cbeldacap , added PS: target was already set to
|
@luiscvalmeida Hi Luis, finally I could solve it uncommenting some polyfills:
And it started working fine! |
@cbeldacap still doesn't work for me:
What's your angular-cli version, and node version? could you print the |
@luiscvalmeida See below: |
@luiscvalmeida Anyway, if PhantomJS is not mandatory you could go for ChromeHeadless. From yesterday (AFAIK) is available the 60th version even in Windows10. You could configure it in your
|
@cbeldacap you only need to specify PhantomJS is out of question, I need to had a bunch of polyfills (and those will end up on my final production build using the Trying now to install Chrome on my jenkins slave that runs the tests, but this slave is using CentOS and I'm having a really hard time setting this up. |
@luiscvalmeida Totally understand that. So, if you get something at installing Chrome in your Jenkins slave, please let us know here :P so we can improve our CI with more possibilities. Thanks a lot in advance |
@cbeldacap @luiscvalmeida . Same issue ,no idea which way to go anyhelp will be much appreciated stackoverflow link. |
@kkrishan replied there, but essentially @cbeldacap, I gave up on the CentOS, changed to Ubuntu server and installed Chrome in there, works like a charm, even e2e tests with protractor run in there. |
@darsana @luiscvalmeida @kkrishan I strongly recommend using ChromeHeadless instead of PhantomJS. I've installed it as a "Custom Tool" in my Jenkins and it works fine :) I've used this script to install it:
Tool home: I'm also using the new Chrome version (60 I think) which I can use locally in my Win10 machine as well. As far as I know it was ready before that version for Linux. Conclusion: I'm not using PhantomJS again. Hope it helps :) |
@darsana specifically with your problem, could it be possible that you're running more than one browser at a time? I mean, instead of running If you have several browsers in your |
@darsana You can have a customLaunchers section in your
Launch tests with Chrome: A priori your console output does not seem like an error. Just like the process is starting, but not failing. If the process is going on for some time you can have timeout problems though |
@darsana Can you please paste your AngularCLI and Node version? ( |
@darsana could not tell the reason, but some stuff started working for me when I moved to version 8.x of node. I would consider the option of updating NodeJS to i.e. 8.4, NPM to 5.x and then upgrade @angular/cli to its latest. |
This configuration worked for me:
customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: [
'--headless',
'--disable-gpu',
'--no-sandbox',
'--remote-debugging-port=9222',
]
}
},
browsers: [
'Chrome',
'ChromeHeadless',
], And simply running the following command from the app directory: ng test --browsers="ChromeHeadless" Hope somebody finds this useful, ChromeHeadless is a much better option then PhantomJS |
For more information on Chrome Headless you can check this issue inside the Karma repository. (This comment (inside the issue) shows the same solution as @mihailo-misic) |
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. |
OS: Ubuntu 14.04.3 in a docker environment, without web browser (it's actually running in Cloud9)
Version: angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: linux x64
Without any browser installed in the os, I cannot find a way to execute jasmine unit tests in spec files.
running
ng test
:No error shown even if some tests have
expect(true).toEqual(false);
Is there a way to execute these tests in a console-only environment ?
Thanks !
The text was updated successfully, but these errors were encountered: