Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

newman-cheerio

node v4.9.1
version: 1.0.0
endpointsharetweet
require('newman').run({ // pass a collection that fetches HTML collection: { item: [{ request: 'http://httpbin.org/html', event: [{ listen: 'test', script: { type: 'text/javascript', // add a script that checks whether heading H1 is present in HTML exec: [ 'tests["response body received"] === !!responseBody;', 'var html = cheerio(responseBody);', 'console.log("Heading H1: " + html.find("h1").text());', // log it 'tests["html has h1 heading"] = !!html.find("h1").text();' ] } }] }] }, abortOnFailure: true // ensures run stops abruptly when any error occurs. }) // log all runtime console to real console .on('console', function (e, args) { console.log.apply(console, args.messages); }) // on complete mark the same .once('done', function (e) { console.log('run complete ' + (e ? 'with' : 'without') + ' errors'); e && console.log(e); // log error });
Loading…

1 comment

  • posted 8 years ago by 57b0cf62d7f6d81300bdd0e0
    qweqwewq

sign in to comment