JavaScript Testing with Latest Firefox and Chrome on AppVeyor
Testing your app on the latest versions of Chrome and Firefox is as easy as typing 'npm test' into the command line with AppVeyor.
Join the DZone community and get the full member experience.
Join For Freebuilding a web application without testing it on the major consumer browsers is crazy. fortunately, we have a few cross-browser testing services such as sauce labs , browserstack , and many more. still, for a quick sanity check on the latest stable version of google chrome and mozilla firefox , nothing beats the fantastic service provided by appveyor .
as a hosted continuous integration service, appveyor runs your application (and its tests) on windows, more precisely microsoft windows server 2012 r2. this means, we have access to the widely used web browsers: internet explorer, firefox, and chrome. due to the platform integration, ie 11 is always available. often times, firefox and chrome are a few versions behind. to solve this issue, we can always install the latest stable version of these two browsers right before running thet tests.
if you want to follow along, i have prepared a simple project at github.com/ariya/karma-appveyor . clone the repository to get the feeling of what it is doing. since it is designed to be very simple, it consists of only one test, written using mocha unit test library and executed using karma test runner:
describe("sqrt", function() {
it("should compute the square root of 4 as 2", function() {
assert.equal(math.sqrt(4), 2);
});
});
the test itself can be executed by running
npm test
. it will launch karma to run the test in the following browsers available on your system: chrome, firefox, safari, and ie. the available browsers are detected using a very nice karma plugin called
karma-detect-browsers
. if you are on os x, what you got is something like this:
to run it on appveyor, first we need to craft the configuration file that looks like:
version: "{build}"
environment:
nodejs_version: "0.12"
install:
- ps: install-product node $env:nodejs_version
- node --version
- npm --version
- npm install
test_script:
- npm test
now go to appveyor.com , sign in using your github account, create a new project and choose your repository. explicitly ask for a new build and after a while, appveyor is brewing the build as follows:
it is running the tests with ie 11, firefox 30, and chrome 41. the last two browsers are quite outdated. how do we force an upgrade?
chocolatey
to the rescue! built on top of
nuget
, chocolatey facilitates a silent install of many windows applications (hence why it is known as the "apt-get of windows"). we need to tweak our
appveyor.yml
so that chocolatey installs
firefox
and
googlechrome
package. of course, if you are living on the edge, feel free to include
firefox beta
and
chrome beta
to the mixture.
install:
- choco install firefox
- choco install googlechrome
- ps: install-product node $env:nodejs_version
- node --version
- npm --version
- npm install
test_script:
- npm test
run the build on appveyor and this time, the build log will be different :
there you go: we have ie 11, firefox 40, and chrome 45 running our test!
Published at DZone with permission of Ariya Hidayat, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
What Is Envoy Proxy?
-
Avoiding Pitfalls With Java Optional: Common Mistakes and How To Fix Them [Video]
-
Essential Architecture Framework: In the World of Overengineering, Being Essential Is the Answer
-
Building a Flask Web Application With Docker: A Step-by-Step Guide
Comments