Running Meteor with Velocity test without Chrome popup

In my quest to gather knowledge on how to use Velocity, I came across a snippet that mentioned a shell variable to set the browser speed used to launch Karma in PhantomJS, as was shown when creating a Chrome popup every time I launch my application in DEV mode. I shrugged at that time, but after I tested in my two applications, I can say that it is an annoying pain for the tests to take place in a pop-up window.

Does anyone know if tests can be run so that they run in PhantomJS and not in Chrome popups? I thought the variable was something like VELOCITY_BROWSER = PhantomJS, but this does not seem to work. Also, is there a way to configure Meteor to just set this as the default, so I don’t need to create a variable every time, for example, in a config or something like that?

+5
source share
2 answers

I found an answer for those who found this, and also wondered how to prevent a Karma popup.

I use the sanjo: jasmine test suite that Karma uses for client integration tests. You can set the default browser in PhantomJS by simply adding this to your environment when starting the meteor:

JASMINE_BROWSER=PhantomJS 

Or, if you just want to disable integration tests with clients, just add this:

 JASMINE_CLIENT_UNIT=0 

So, for example, you can run your application, for example JASMINE_BROWSER=PhantomJS meteor , and you will no longer receive a popup. What I did was created by meteor.sh in my application root folder, which I use to run with these environment variables:

 #!/bin/sh JASMINE_BROWSER=PhantomJS meteor 

This is just for convenience, so I won’t need to remember a variable to do this. This should work on any * nix based OS. You can also make an alias if you wish. It would look like this:

 alias meteor=JASMINE_BROWSER=PhantomJS meteor 

I can sit out a bit in the syntax, but I think it should work.

To use PhantomJS, you need to install it, so run it in the terminal:

 npm install -g phantomjs 

Or if you are working on a Mac (you will need a brew ):

 brew install phantomjs 

Hope this helps someone in the future.

+9
source

In sanjo: jasmine 0.17.0 on Windows, PhantomJS has some problems with the meteor autoupdate function. You may have trouble running the tests again when you change the application code.

If you want to stick to the Chrome window, you can hide it using the chrome command-line options, but you need to update karma-chrome-launcher\index.js to enable them:

 return [ '--user-data-dir=' + this._tempDir, '--no-default-browser-check', '--no-first-run', '--disable-default-apps', '--disable-popup-blocking', '--disable-translate', '--window-position=-800,0', // <-- added '--window-size=800,600' // <-- added ].concat(flags, [url]) 

A window will appear, but it will be created behind the scenes, and somehow fortunately did not even steal the keyboard focus.

0
source

Source: https://habr.com/ru/post/1212196/


All Articles