Access Intern Command Line Arguments

By  on  

SitePen's excellent client side testing tool, Intern, comes with an excellent command line utility to run tests and customize how those tests are run.  The options provided are great but what if I want to make the command line more dynamic?  What if I want to add custom command line arguments, available to tests, to pass along important information like sensitive credentials (which you don't want hard-coded in config files) or you simply want to allow overwriting of values within the static config file?  It's actually quite easy:

define(['intern'], function(intern) {
	
	if(intern.args.someCustomArg != undefined) {

		/* use the custom command line arg */

	}
});

The intern module provides you the provided arguments via the args property.  From there you can pick off the argument values as you wish.  So what do I pass in via the command line?

  • Login credentials for the test to use
  • The domain I want to test (local dev, staging, production)
  • Select browsers I want to test (i.e. I don't want to run all of them cited in the config)

What you could add is specific to your app, but be glad it's so easy to do!

Recent Features

  • By
    How to Create a RetroPie on Raspberry Pi – Graphical Guide

    Today we get to play amazing games on our super powered game consoles, PCs, VR headsets, and even mobile devices.  While I enjoy playing new games these days, I do long for the retro gaming systems I had when I was a kid: the original Nintendo...

  • By
    Serving Fonts from CDN

    For maximum performance, we all know we must put our assets on CDN (another domain).  Along with those assets are custom web fonts.  Unfortunately custom web fonts via CDN (or any cross-domain font request) don't work in Firefox or Internet Explorer (correctly so, by spec) though...

Incredible Demos

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!