// This is a helper to take object data and break it into rows add(data, {joiner = this.joiner, sort = this.sort} = {}) { _.forEach(sort ? _.sortBy(_.keys(data)) : _.keys(data), key => { // Do some special things for arrays if (_.isArray(data[key])) data[key] = data[key].join(joiner); // Do something special for objects if (_.isObject(data[key])) data[key] = util.inspect(data[key], {compact: true}); // Do the normal push this.push([(chalk[this.keyColor](_.toUpper(key))), data[key]]); }); }
/* istanbul ignore next */ [util.inspect.custom](depth, options) { // https://nodejs.org/docs/latest-v8.x/api/util.html#util_custom_inspection_functions_on_objects if (depth < 0) { return options.stylize("[Context]", "special"); } const inner = util.inspect(this.toJSON(), options); return `${options.stylize("Context", "special")}< ${inner} >`; }
Object.keys(labels).forEach(label => { if (savedLabels.indexOf(label) === -1) { throw new Error( `Added label "${label}" is not included in initial labelset: ${util.inspect( savedLabels, )}`, ); } });
describe(`object inspection`, () => { const pq1 = new pgp.ParameterizedQuery(`test-query $1`); const pq2 = new pgp.ParameterizedQuery(`test-query $1`, []); it(`must stringify all values`, () => { expect(tools.inspect(pq1)).toBe(pq1.toString()); expect(tools.inspect(pq2)).toBe(pq2.toString()); }); });
setDeferred(support, "inspectProxies", () => { const { safeUtil } = shared.module // Node < 6.1.0 does not support inspecting proxies. const inspected = safeUtil.inspect(dummyProxy, { depth: 1, showProxy: true }) return inspected.indexOf(PROXY_PREFIX) !== -1 && inspected.indexOf(PACKAGE_PREFIX) !== -1 })
function inspectTrunc(value, limit = 128) { const inspected = inspect(value) return inspected.length > limit ? inspected.slice(0, limit) + "..." : inspected }
function isSocket(item) { if (!item || !item.endTime || item.reqError || item.resError) { return false; } if (/^wss?:\/\//.test(item.url)) { return item.res.statusCode == 101; } return item.inspect || (item.isHttps && item.req.headers['x-whistle-policy'] === 'tunnel'); }
// This one is just for coverage; describe(`Error protocol`, () => { const result = { rows: [] }; it(`must return correctly formatted error body`, () => { const error1 = new pgp.errors.QueryResultError(0, result, ``); const error2 = new pgp.errors.QueryResultError(0, result, {name: `name`, text: `text`}, []); expect(tools.inspect(error1)).toBe(error1.toString()); expect(tools.inspect(error2)).toBe(error2.toString()); }); });
Promise.all([server.start(), client.start()]) .then(() => client.waitForServices("server")) .then(() => { client.call("server.getABigBuffer", { size: 128 * 1024 }).then((res) => { client.logger.info("got", inspect(res)); }); });
//////////////////////////////////////////////////////// // Adds prototype inspection function addInspection(type, cb) { type.prototype[npm.util.inspect.custom] = cb; }
describe('#waitForText', () => { it('should return error if not present', async () => { try { await app.waitForText('Nothing here', 1, '~buttonTestCD'); } catch (e) { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.be.equal('expected element ~buttonTestCD to include "Nothing here"'); } }); });
export function ensure(obj, prop, name) { if (!obj[prop]) { throw new Error( `property "${prop}" must be defined on object: ${name || util.inspect(obj)}` ) } return obj[prop] }
describe('#openNotifications', () => { it('should react on notification opening', async () => { try { await app.seeElement('//android.widget.FrameLayout[@resource-id="com.android.systemui:id/quick_settings_container"]'); } catch (e) { e.should.be.instanceOf(AssertionFailedError); e.inspect().should.include('expected elements of //android.widget.FrameLayout[@resource-id="com.android.systemui:id/quick_settings_container"] to be seen'); } await app.openNotifications(); await app.waitForVisible('//android.widget.FrameLayout[@resource-id="com.android.systemui:id/quick_settings_container"]', 10); }); });
describe(`object inspection`, () => { const ps1 = new pgp.PreparedStatement({name: `test-name`, text: `test-query $1`}); const ps2 = new pgp.PreparedStatement({name: `test-name`, text: `test-query $1`, values: [123]}); it(`must stringify all values`, () => { expect(tools.inspect(ps1)).toBe(ps1.toString()); expect(tools.inspect(ps2)).toBe(ps2.toString()); }); });