How to use the postman-collection.Event function in postman-collection

To help you get started, we’ve selected a few postman-collection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / postman-collection / postman-collection-tests.ts View on Github external
desc.update("string", "string"); // $ExpectType void
desc.update(descDef); // $ExpectType void

pmCollection.Description.isDescription(desc); // $ExpectType boolean

// EventDefinition Tests

const eventDesc: pmCollection.EventDefinition = {
    script: "string"
};
eventDesc.listen; // $ExpectType string | undefined
eventDesc.script; // $ExpectType string | string[] | ScriptDefinition | Script

// Event Tests

const event = new pmCollection.Event(eventDesc);
event.listen; // $ExpectType string | undefined
event.script; // $ExpectType Script

event.update(eventDesc); // $ExpectType void

// EventList Tests

const eventList = new pmCollection.EventList(null, [event]);
eventList.listeners("string"); // $ExpectType Event[]
eventList.listenersOwn("string"); // $ExpectType Event[]

pmCollection.EventList.isEventList(eventList); // $ExpectType boolean

// FormParamDefinition Tests

const fpDef: pmCollection.FormParamDefinition = {};
github postmanlabs / postman-sandbox / lib / index.js View on Github external
execute: function (target, options, callback) {
        if (_.isFunction(options) && !callback) {
            callback = options;
            options = null;
        }

        !_.isObject(options) && (options = {});

        // if the target is simple code, we make a generic event out of it
        if (_.isString(target) || _.isArray(target)) {
            target = new PostmanEvent({
                script: target
            });
        }
        // if target is not a code and instead is not something that can be cast to an event, it is definitely an error
        else if (!_.isObject(target)) {
            return callback(new Error('sandbox: no target provided for execution'));
        }

        var id = _.isString(options.id) ? options.id : uuid(),
            executionEventName = 'execution.result.' + id,
            consoleEventName = 'execution.console.' + id,
            executionTimeout = _.get(options, 'timeout', this.executionTimeout),
            cursor = _.clone(_.get(options, 'cursor', {})), // clone the cursor as it travels through IPC for mutation
            debugMode = _.has(options, 'debug') ? options.debug : this.debug,
            waiting;
github postmanlabs / postman-sandbox / lib / sandbox / execute.js View on Github external
bridge.on('execute', function (id, event, context, options) {
        if (!(id && _.isString(id))) {
            return bridge.dispatch('error', new Error('sandbox: execution identifier parameter(s) missing'));
        }

        !options && (options = {});
        !context && (context = {});
        event = (new PostmanEvent(event));

        var executionEventName = EXECUTION_RESULT_EVENT_BASE + id,
            executionRequestEventName = EXECUTION_REQUEST_EVENT_BASE + id,
            errorEventName = EXECUTION_ERROR_EVENT_BASE + id,
            abortEventName = EXECUTION_ABORT_EVENT_BASE + id,
            responseEventName = EXECUTION_RESPONSE_EVENT_BASE + id,
            cookiesEventName = EXECUTION_COOKIES_EVENT_BASE + id,

            // extract the code from event. The event can be the code itself and we know that if the event is of type
            // string.
            code = _.isFunction(event.script && event.script.toSource) && event.script.toSource(),
            // create the execution object
            execution = new Execution(id, event, context, options),

            waiting,
            timers;