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
    CSS @supports

    Feature detection via JavaScript is a client side best practice and for all the right reasons, but unfortunately that same functionality hasn't been available within CSS.  What we end up doing is repeating the same properties multiple times with each browser prefix.  Yuck.  Another thing we...

  • By
    CSS vs. JS Animation: Which is Faster?

    How is it possible that JavaScript-based animation has secretly always been as fast — or faster — than CSS transitions? And, how is it possible that Adobe and Google consistently release media-rich mobile sites that rival the performance of native apps? This article serves as a point-by-point...

Incredible Demos

Discussion

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