以下js函数在任何代码块中都可访问
c('print to console'); // same as console.log(), but prints it out more neatly
// (and clear of the progress bar)
dir(); // returns the absolute directory of the file where this step is
g('variable', 'new value'); // set global variable
g('variable'); // get global variable
getGlobal('variable'); // get global variable
getLocal('variable'); // get local variable
getPersistent('variable'); // get persistent variable
const packageName = i('package-name'); // require()'s (imports) the given nodejs package,
// sets persistent var 'packageName' to it (auto-camelCased),
// and returns it
const myPkg = i('myPkg', 'package-name'); // same, but sets the name of the persistent var
i('myPkg', './path/to/file.js'); // works with js files too
i('myPkg', '../path/to/file.js');
i('myPkg', '/Users/Shared/tests/file.js');
l('variable', 'new value'); // set local variable
l('variable'); // get local variable
log('text to log'); // logs a piece of text to the report for this step
runInstance; // represents the test runner "thread" that's
// running this step and branch (see RunInstance)
runInstance.runner; // represents the test runner (see Runner)
runInstance.tree; // represents the whole tree (see Tree)
runInstance.currBranch; // represents the current branch (see Branch)
runInstance.currStep; // represents the current step (see Step)
// These objects can be used to dynamically view, create, and/or edit tests at runtime
setGlobal('variable', 'new value'); // set global variable
setLocal('variable', 'new value'); // set local variable
setPersistent('variable', 'new value'); // set persistent variable