Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"chai-match": "^1.1.1",
"chalk": "^2.4.2",
"cookie": "^0.4.0",
"json-colorizer": "^2.2.2",
"jsonpath-plus": "^1.0.0",
"openapi-schema-to-json-schema": "^2.2.0",
"superagent": "^5.1.0",
Expand Down
19 changes: 17 additions & 2 deletions src/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const { parse: parseUrl } = require('url');
const chalk = require('chalk');
const request = require('superagent');
const SwaggerParser = require('swagger-parser');
const colorize = require('json-colorizer');

const agents = new Map();
const responseCache = new Map();
Expand Down Expand Up @@ -52,6 +53,16 @@ class World {
this.env = process.env.TEST_ENV || null;
this.responseVars = [];
this.userVars = [];

this.debugLogOptions = {
pretty: true,
colors: {
// Colors convention can be negotiated.
STRING_KEY: 'green',
STRING_LITERAL: 'yellow',
NUMBER_LITERAL: 'red',
},
};
}

/**
Expand Down Expand Up @@ -289,7 +300,11 @@ async function printDebug(info) {
if (this.debug.length) {
console.log('\n' + sep + '\n');
for (const line of this.debug) {
console.log(line);
try {
console.log(colorize(line, this.debugLogOptions));
} catch (error){
console.log(line);
}
}
console.log('\n' + sep + '\n');
}
Expand All @@ -304,7 +319,7 @@ async function printDebug(info) {
console.log('Url:\n');
console.log(this.req.url);
console.log('\nResponse body:\n');
console.log(res.body);
console.log(colorize(res.body, this.debugLogOptions));
console.log('\n' + sep + '\n');
}

Expand Down