Access Intern Command Line Arguments
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!