Parallel CasperJS runner, BDD flow, module-based tests, API helpers
Source: lib/conjure/index.js
- exports.Conjure
- exports.create
- exports.extendConjure
- exports.extendAsyncHelpers
- exports.extendSyncHelpers
- Conjure
- Conjure.createContext
- Conjure.prototype.isRunning
- Conjure.prototype.test
- Conjure.prototype.run
- Conjure.prototype.popStatus
- Conjure.prototype.pushStatus
- helpers.async.click
- helpers.async.then
- helpers.async.thenOpen
- helpers.async.assertSelText
- helpers.async.each
- helpers.async.openHash
- helpers.async.openInitUrl
- helpers.async.selectorExists
- helpers.async.selectorMissing
- helpers.async.sendKeys
- helpers.sync.assertType
- helpers.sync.require
- helpers.sync.url
Reference to Conjure.
Create a new Conjure.
Parameters:
{object} requireCasper
Casper-landrequire()
Return:
{object}
Extend Conjure.prototype.
Parameters:
{object} ext
Return:
{object}
Merge result.
Extend the object that includes functions like
selectorExists()
.
Parameters:
{object} ext
Return:
{object}
Merge result.
Extend the object that includes functions like
url()
.
Parameters:
{object} ext
Return:
{object}
Merge result.
Add BDD globals and init configuration.
Usage:
var conjure = require('conjure').create();
conjure.set('exitOnError', false);
Configuration:
{string} baseUrl
Of target test server.[http://localhost:8174]
{string} initPath
Wait for this relative path to load before starting tests.[/]
{string} initSel
Wait for this selector (oninitPath
) before starting tests.[body]
{object} test
CasperJS test API of the currentit()
{object} casperConfig
Native CasperJScreate()
settings.
Default casperConfig
:
{
exitOnError: true,
logLevel: 'debug',
pageSettings: {
loadImages: false,
loadPlugins: false,
XSSAuditingEnabled: true,
verbose: true,
onError: function(self, m) { self.die('CasperJS onError: ' + m, 1); },
onLoadError: function(self, m) { self.die('CasperJS onLoadError: ' + m, 1); }
}
}
To modify casperConfig
:
get() + set()
from a test script.- Or apply globally using a
--bootstrap
module.
Properties:
{object} conjure
Allhelpers
functions bound tothis
.{object} console
LongCon
instance{object} flow
Bddflow
instance{object} utils
Native CasperJSutils
module{object} colorizer
Native CasperJScolorizer
module{boolean} running
True after Conjure.prototype.run executes
Parameters:
{function} requireCasper
CasperJS-env require()
See:
Go: TOC
Build a context object that includes:
- All enumerable keys from the parent.
- Where functions are bound to the parent.
Parameters:
{object} parent
{string | array} pluck
Key(s) from parent to pluck.{string | array} omit
Key(s) from parent to omit.
Return:
{object}
Check if
run()
has been called.
Return:
{boolean}
Go: TOC | Conjure.prototype
Run the suite/root
describe()
.
Perform last-minute init based on collected configuration. Silently add an initial describe() to verify initial URL/selector.
Parameters:
{string} name
{function} cb
Go: TOC | Conjure.prototype
Run collected BBD layers.
Go: TOC | Conjure.prototype
Decrement the current stack depth for trace logs.
Go: TOC | Conjure.prototype
Increment the current stack depth for trace logs and emit a status event with the name of the depth change source.
All args match Conjure.prototype.status.
Go: TOC | Conjure.prototype
click() alternative that uses jQuery selectors and first waits for a match.
Usage:
this.conjure.click('body'); // jQuery click
this.conjure.click('body', true); // native CasperJS click
Parameters:
{string} sel
{boolean} [nativeClick=false]
UsethenClick()
instead of jQuery'sclick()
Go: TOC | helpers.async
then()
alternative that with access to the same API asit()
.
Usage:
this.conjure.then(function() {
var validate = this.conjure.require('./lib/validation.js');
this.test.assert(validate.activationCode(this.casper.fetchText('.act-code')));
});
Parameters:
{function} cb
{boolean} [lastStep=true]
Use false to prevent stack trace pop.- Ex. Use false in all-but-last-call if a helpers needs to call it multiple time
Go: TOC | helpers.async
thenOpen()
alternative that with access to the same API asit()
. Alternative tothenOpen()
that resolves relative paths tobaseUrl
config.
Usage:
// Equivalent:
this.conjure.thenOpen('/login');
this.conjure.thenOpen('login');
this.conjure.thenOpen('http://localhost:8000/login');
Parameters:
{mixed} args*
OriginalthenOpen()
arguments
See:
Go: TOC | helpers.async
assertTextExists()
alternative that uses jQuery selectors.
Usage:
this.conjure.assertSelText('.username', 'user47');
Parameters:
{string} sel
{string | regexp} text
Go: TOC | helpers.async
casper.each()
alternative executes the callback inside the customthen()
. Callback receives the context of the enclosingthen()
.
Usage:
var memberAreas = ['download', 'stats', 'collection'];
this.conjure.each(memberAreas, function(area, idx, list) {
this.conjure.thenOpen('/#' + area);
this.conjure.assertSelText('.promote-acct', /Your free trial expires in/);
});
Parameters:
{array} list
{function} cb
Receives (listItem).
Go: TOC | helpers.async
Append a fragment ID to the current URL.
Usage:
this.conjure.openHash('inbox');
this.conjure.openHash('inbox', '.msg-actions'); // Then wait for a selector match
Parameters:
{string} hash
Without leading '#'.{string} [sel]
Optional selector to wait for after navigation.
Go: TOC | helpers.async
Re-open the initial URL.
Go: TOC | helpers.async
Alternative to
waitForSelector()
to use jQuery selector support, ex. ':first' syntax.
Usage:
this.conjure.selectorExists('.inbox');
this.conjure.selectorExists('.inbox', true); // Expect selector absence
this.conjure.selectorExists('.inbox', false); // Default
this.conjure.selectorExists('.inbox', false, false); // Skip stack trace pop
this.conjure.selectorExists('.inbox', false, true); // Default
Parameters:
{string} sel
{boolean} [negate]
Use true if selector is not expected to match.{boolean} [lastStep=true]
Use false to prevent stack trace pop.- Ex. Use false in all-but-last-call if a helpers needs to call it multiple time
Go: TOC | helpers.async
Negated
selectorExists()
.
Usage:
this.conjure.selectorMissing('.inbox');
this.conjure.selectorMissing('.inbox', false); // Skip stack trace pop
this.conjure.selectorMissing('.inbox', true); // Default
Parameters:
{string} sel
{boolean} [lastStep=true]
Use false to prevent stack trace pop.- Ex. Use false in all-but-last-call if a helpers needs to call it multiple time
Go: TOC | helpers.async
sendKeys()
alternative that first waits for a selector to exist.
Usage:
this.conjure.sendKeys('.username', 'user47');
Parameters:
{string} sel
{string} keys
Go: TOC | helpers.async
assertType()
alternative that outputs the actual type on mismatch.
Usage:
// assertion error message: 'username should be a string'
this.conjure.assertType(val, 'string', 'username');
// assertion error message: 'subject should be a string'
this.conjure.assertType(val, 'string');
Parameters:
{mixed} val
{string} expected
Ex. 'number'{string} [subject=none]
Ex. 'user ID'
Go: TOC | helpers.sync
require()
a CasperJS module or any file relative to--root-dir
.
Usage:
// Equivalent:
this.conjure.require('lib/validation');
this.conjure.require('lib/validation.js');
this.conjure.require('./lib/validation');
this.conjure.require('./lib/validation.js');
Parameters:
{string} name
Ex. 'casper' or./relative/path/module.js
- For local file: prefix with leading
./
- Ex. './foo' with
--root-dir
is/path/to/proj
loads/path/to/proj/foo.js')
- For local file: prefix with leading
Return:
{mixed}
Go: TOC | helpers.sync
Resolve a relative URL to the
baseUrl
config.
Usage:
// Equivalent:
this.conjure.url('/login');
this.conjure.url('login');
Parameters:
{string} relUrl
Return:
{string}
Go: TOC | helpers.sync
—generated by apidox—