Integration tester.
$ npm install segmentio/integration-tester
assert(integration)
.identify(identify)
.sends('content-type', 'application/json')
.sends({ baz: 'foo' })
.expects({ users: { name: 'baz' } })
.expects(200, end);
assert(integration)
.sends('content-type', 'text/plain')
.sends('x-baz', /foo/)
.sends(/key=111/)
.sends(/type=identify/)
.expects(/success=true/)
.expects(200, done);
Initialize new Assertion with integration
.
Assert requests are n
.
Assert retries are n
.
Assert timeout is ms
, where ms
can be either a string (2s
) or a number (2000
).
Assert name is n
.
Assert endpoint is url
.
Assert request pathname is url
.
Assert the integration is valid with msg
, settings
.
Assert the integration is invalid with msg
, settings
.
Add query.
Example:
Assertion(integration)
.set('token', 'e16481cb')
.identify({ userId: 1 })
.query({ identify: true })
.query({ userid: 1 })
.expects(200, done);
Set object key
or key, value
settings.
Assert integration sends ...
// examples
sends({ baz: 'foo' });
sends(/baz=foo/);
sends('?query=string');
sends('baz=foo');
Assert integration expects ...
// examples
expects({ success: true });
expects(/success=true/);
expects('success=true');
expects(200);
End assertions with fn
.
Assert integration calls fn(err)
.
throws if the integration isn't enabled on msg
.
throws if the integration isn't disabled on msg
.
throws if the integration isn't enabled on channel
with optional msg
.
// examples
server();
client();
mobile();
throws if the integration isn't enabled on all channels.
(MIT)