-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(): readyNotice as function #3
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,8 +153,9 @@ function initCtx(options) { | |
|| !isFileFound(targetSvc) && options.svc + ' is not found on disk' | ||
|| !options.logPath && 'options.logPath is expected to be a path' | ||
|| 'string' != typeof options.logPath && 'options.logPath is expected to be a path' | ||
|| !options.readyNotice && 'options.readyNotice must be a string' | ||
|| 'string' != typeof options.readyNotice && 'options.readyNotice must be a string' | ||
|| !options.readyNotice && 'options.readyNotice must be either a string or a function' | ||
|| ['string', 'function'] | ||
.indexOf(typeof options.readyNotice) && 'options.readyNotice must be either a string or a function' | ||
|| !Array.isArray(options.args) && 'options.args must be an array' | ||
|| 'number' != typeof options.timeout && 'options.timeout must be a number' | ||
|| 'number' != typeof options.slow && 'options.slow must be a number' | ||
|
@@ -183,7 +184,7 @@ function initCtx(options) { | |
, " - logPath - string, optional - path to logfile. default: './e2e.log'" | ||
, " - timeout - integer, optional - timeout for server setup, default: " + defaults.timeout | ||
, " - slow - integer, optional - slow bar indicator for server setup, default: " + defaults.timeout | ||
, " - readyNotice - string, optional - message to expect on service output that" | ||
, " - readyNotice - string or function, optional - message to expect on service output that" | ||
, " indicates the service is ready. default: " + defaults.readyNotice | ||
, " - args - array, optional, argumnets to be concatenated to the running command" | ||
, " - term_code - string, optional, the termination message to send to the child, default: " + defaults.term_code | ||
|
@@ -235,10 +236,11 @@ function initCtx(options) { | |
@param {string} ctx.sut - system under test - path to the script that | ||
runs the target server | ||
@param {string} ctx.logPath - path to log file | ||
@param {string} ctx.readyNotice - output line expected on stdout of | ||
the started target service that indicates that the service is running | ||
@param {string|function} ctx.readyNotice - either output line expected on stdout of | ||
the started target service that indicates that the service is running or a function that will | ||
check that the service is up | ||
@param {mocha.Test} test - the test context that implements .timetout(n), .slow(n) .... | ||
@param {callback} done - callback | ||
@param {function} done - callback | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not any function. an err-1st callback - hence |
||
@returns {undefined} | ||
*/ | ||
function setup(ctx, test, done) { | ||
|
@@ -284,14 +286,21 @@ function setup(ctx, test, done) { | |
child.stdout.on('data', (data) => { | ||
data = data.toString() | ||
writeLog(data) | ||
|
||
if (~data.indexOf(ctx.readyNotice)) { | ||
ctx.console.log('service started: %s', ctx.args.join(' ')) | ||
done() | ||
done = null | ||
} | ||
}) | ||
|
||
if ('function' == typeof ctx.readyNotice) { | ||
ctx.readyNotice(done) | ||
done = null | ||
} else { | ||
child.stdout.on('data', (data) => { | ||
if (done && ~data.indexOf(ctx.readyNotice)) { | ||
ctx.console.log('service started: %s', ctx.args.join(' ')) | ||
done() | ||
done = null | ||
} | ||
}) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
child.on('exit', (e) => { | ||
child.exitted = true | ||
ctx.console.log('\n\nservice termination ended', e || 'OK') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "e2e-helper", | ||
"version": "0.9.4", | ||
"version": "0.10.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its fully compatible with prev versions. |
||
"description": "end-to-end test helper, with facilitators for mocha", | ||
"main": "lib", | ||
"repository": { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace lines 187 and 188 with: