How to use the pinkie.resolve function in pinkie

To help you get started, we’ve selected a few pinkie 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 DevExpress / testcafe / src / api / test-controller / index.js View on Github external
UseRoleCommand
} from '../../test-run/commands/actions';

import {
    TakeScreenshotCommand,
    TakeElementScreenshotCommand,
    ResizeWindowCommand,
    ResizeWindowToFitDeviceCommand,
    MaximizeWindowCommand
} from '../../test-run/commands/browser-manipulation';

import { WaitCommand, DebugCommand } from '../../test-run/commands/observation';
import assertRequestHookType from '../request-hooks/assert-type';
import { createExecutionContext as createContext } from './execution-context';

const originalThen = Promise.resolve().then;

export default class TestController {
    constructor (testRun) {
        this._executionContext = null;

        this.testRun               = testRun;
        this.executionChain        = Promise.resolve();
        this.callsitesWithoutAwait = new Set();
    }

    // NOTE: we track missing `awaits` by exposing a special custom Promise to user code.
    // Action or assertion is awaited if:
    // a)someone used `await` so Promise's `then` function executed
    // b)Promise chained by using one of the mixed-in controller methods
    //
    // In both scenarios, we check that callsite that produced Promise is equal to the one
github DevExpress / testcafe-browser-provider-browserstack / src / index.js View on Github external
import BrowserProxy from './browser-proxy';
import isEnvVarTrue from './utils/is-env-var-true';

const ANDROID_PROXY_RESPONSE_DELAY = 500;


const isAutomateEnabled = () => isEnvVarTrue('BROWSERSTACK_USE_AUTOMATE');
const isLocalEnabled    = () => !isEnvVarTrue('BROWSERSTACK_NO_LOCAL');

export default {
    // Multiple browsers support
    isMultiBrowser: true,

    backend: null,

    connectorPromise:    Promise.resolve(null),
    browserProxyPromise: Promise.resolve(null),

    workers:       {},
    platformsInfo: [],
    browserNames:  [],

    _getConnector () {
        this.connectorPromise = this.connectorPromise
            .then(async connector => {
                if (!connector && isLocalEnabled()) {
                    connector = new BrowserstackConnector(process.env['BROWSERSTACK_ACCESS_KEY']);

                    await connector.create();
                }

                return connector;
github DevExpress / testcafe-browser-provider-browserstack / src / api-request.js View on Github external
import Promise from 'pinkie';
import request from 'request-promise';
import delay from './utils/delay';
import * as ERROR_MESSAGES from './templates/error-messages';


const BUILD_ID     = process.env['BROWSERSTACK_BUILD_ID'];
const PROJECT_NAME = process.env['BROWSERSTACK_PROJECT_NAME'];

const API_REQUEST_DELAY = 100;

let apiRequestPromise = Promise.resolve(null);


export default function (apiPath, params) {
    if (!process.env['BROWSERSTACK_USERNAME'] || !process.env['BROWSERSTACK_ACCESS_KEY'])
        throw new Error(ERROR_MESSAGES.BROWSERSTACK_AUTHENTICATION_FAILED());

    var url = apiPath.url;

    var opts = {
        auth: {
            user: process.env['BROWSERSTACK_USERNAME'],
            pass: process.env['BROWSERSTACK_ACCESS_KEY'],
        },

        qs: Object.assign({},
            BUILD_ID && { build: BUILD_ID },
github DevExpress / testcafe / src / api / test-controller / index.js View on Github external
.catch(err => {
                        this.executionChain = Promise.resolve();

                        throw err;
                    });
            };
github DevExpress / testcafe-hammerhead / src / client / transport.ts View on Github external
queuedAsyncServiceMsg (msg): Promise {
        if (!this.msgQueue[msg.cmd])
            this.msgQueue[msg.cmd] = Promise.resolve();

        const isRejectingAllowed = msg.allowRejecting;

        msg.allowRejecting = true;

        this.msgQueue[msg.cmd] = this.msgQueue[msg.cmd]
            .catch(noop)
            .then(() => this.asyncServiceMsg(msg));

        return this.msgQueue[msg.cmd]
            .catch(err => {
                if (isRejectingAllowed)
                    return Promise.reject(err);

                return createUnresolvablePromise();
            });
github DevExpress / testcafe-hammerhead / src / client / sandbox / upload / info-manager.ts View on Github external
loadFileListData (_input, fileList) {
        if (!fileList.length)
            return Promise.resolve(new FileListWrapper([]));

        return new Promise(resolve => {
            const fileReader  = new FileReader();
            const readedFiles = [];
            let index         = 0;
            let file          = fileList[index];

            fileReader.addEventListener('load', (e: any) => {
                readedFiles.push({
                    data: e.target.result.substr(e.target.result.indexOf(',') + 1),
                    blob: file.slice(0, file.size),
                    info: {
                        type:             file.type,
                        name:             file.name,
                        lastModifiedDate: file.lastModifiedDate
                    }
github DevExpress / testcafe-hammerhead / src / client / transport.ts View on Github external
batchUpdate (): Promise {
        const storedMessages = Transport._getStoredMessages();

        if (storedMessages.length) {
            const tasks = [];

            nativeMethods.winLocalStorageGetter.call(window).removeItem(settings.get().sessionId);

            for (const storedMessage of storedMessages)
                tasks.push(this.queuedAsyncServiceMsg(storedMessage));

            return Promise.all(tasks);
        }
        return Promise.resolve();
    }
github DevExpress / testcafe-browser-provider-electron / src / node-debug.js View on Github external
constructor (port = 5858, host = '127.0.0.1') {
        this.currentPacketNumber = 1;
        this.events              = new EventEmitter();
        this.port                = port;
        this.host                = host;
        this.socket              = new Socket();
        this.buffer              = Buffer.alloc(0);
        this.getPacketPromise    = Promise.resolve();
        this.sendPacketPromise   = Promise.resolve();

        this.nodeInfo = {
            v8Version:       '',
            protocolVersion: '',
            embeddingHost:   ''
        };
    }
github DevExpress / testcafe-browser-provider-browserstack / src / utils / request-api.js View on Github external
method: apiPath.method || 'GET',
        json:   apiPath.encoding === void 0
    };

    const proxy = process.env['BROWSERSTACK_PROXY'];

    if (proxy)
        opts.proxy = `http://${proxy}`;

    if (body)
        opts.body = body;

    if (apiPath.encoding !== void 0)
        opts.encoding = apiPath.encoding;

    const chainPromise = executeImmediately ? Promise.resolve(null) : apiRequestPromise;

    const currentRequestPromise = chainPromise
        .then(() => request(opts))
        .catch(error => {
            if (error.statusCode === 401)
                throw new Error(ERROR_MESSAGES.BROWSERSTACK_AUTHENTICATION_FAILED());

            throw error;
        });

    return currentRequestPromise;
}
github DevExpress / testcafe-browser-provider-electron / src / node-debug.js View on Github external
constructor (port = 5858, host = '127.0.0.1') {
        this.currentPacketNumber = 1;
        this.events              = new EventEmitter();
        this.port                = port;
        this.host                = host;
        this.socket              = new Socket();
        this.buffer              = Buffer.alloc(0);
        this.getPacketPromise    = Promise.resolve();
        this.sendPacketPromise   = Promise.resolve();

        this.nodeInfo = {
            v8Version:       '',
            protocolVersion: '',
            embeddingHost:   ''
        };
    }

pinkie

Itty bitty little widdle twinkie pinkie ES2015 Promise implementation

MIT
Latest version published 9 years ago

Package Health Score

67 / 100
Full package analysis