DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

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

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
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. JavaScript Testing with Latest Firefox and Chrome on AppVeyor

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.

Ariya Hidayat user avatar by
Ariya Hidayat
·
Sep. 17, 15 · Tutorial
Like (1)
Save
Tweet
Share
4.50K Views

Join the DZone community and get the full member experience.

Join For Free

building 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:

appveyor

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:

outdated

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 :

updated

there you go: we have ie 11, firefox 40, and chrome 45 running our test!

AppVeyor unit test Continuous Integration/Deployment JavaScript

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

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: