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 I Stopped WordPress Comment Spam

    I love almost every part of being a tech blogger:  learning, preaching, bantering, researching.  The one part about blogging that I absolutely loathe:  dealing with SPAM comments.  For the past two years, my blog has registered 8,000+ SPAM comments per day.  PER DAY.  Bloating my database...

  • By
    Create Namespaced Classes with MooTools

    MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does.  Many developers create their classes as globals which is generally frowned up.  I mostly disagree with that stance, but each to their own.  In any event...

Incredible Demos

  • By
    Implementing Basic and Fancy Show/Hide in MooTools 1.2

    One of the great parts of MooTools is that the library itself allows for maximum flexibility within its provided classes. You can see evidence of this in the "Class" class' implement method. Using the implement method, you can add your own methods to...

  • By
    Duplicate the jQuery Homepage Tooltips Using Dojo

    The jQuery homepage has a pretty suave tooltip-like effect as seen below: Here's how to accomplish this same effect using Dojo. The XHTML The above HTML was taken directly from the jQuery homepage -- no changes. The CSS The above CSS has been slightly modified to match the CSS rules already...

Discussion

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