How to use pinkie - 10 common examples

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-hammerhead / src / client / sandbox / cookie / window-sync.ts View on Github external
private _sendSyncMessage (win: Window, cmd: string, cookies): Promise {
        const id     = this._messageIdGenerator.increment();
        let attempts = 0;

        return new Promise((resolve: Function) => {
            let timeoutId: number | null = null;

            const resolveWrapper = () => {
                nativeMethods.clearTimeout.call(this._win, timeoutId as number);
                this._resolversMap.delete(id);
                resolve();
            };

            const sendMsg = () => {
                // NOTE: The window was removed if the parent property is null.
                if (attempts++ < SYNC_MESSAGE_ATTEMPT_COUNT || !win.parent) {
                    this._messageSandbox.sendServiceMsg({ id, cmd, cookies }, win);
                    timeoutId = nativeMethods.setTimeout.call(this._win, sendMsg, SYNC_MESSAGE_TIMEOUT * attempts);
                }
                else
                    resolveWrapper();
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-hammerhead / src / client / sandbox / node / window.ts View on Github external
window.navigator.serviceWorker.register = (...args) => {
                const url = args[0];

                if (typeof url === 'string') {
                    if (WindowSandbox._isSecureOrigin(url)) {
                        // NOTE: We cannot create an instance of the DOMException in the Android 6.0 and in the Edge 17 browsers.
                        // The 'TypeError: Illegal constructor' error is raised if we try to call the constructor.
                        return Promise.reject(isAndroid || isMSEdge && browserVersion >= 17
                            ? new Error('Only secure origins are allowed.')
                            : new DOMException('Only secure origins are allowed.', 'SecurityError'));
                    }

                    args[0] = getProxyUrl(url, { resourceType: stringifyResourceType({ isScript: true }) });
                }

                if (args[1] && typeof args[1].scope === 'string') {
                    args[1].scope = getProxyUrl(args[1].scope, {
                        resourceType: stringifyResourceType({ isScript: true })
                    });
                }

                return nativeMethods.registerServiceWorker.apply(window.navigator.serviceWorker, args);
            };
        }
github DevExpress / testcafe / src / utils / parse-ssl-options.js View on Github external
export default async function (optionsStr = '') {
    const splittedOptions = optionsStr.split(OPTIONS_SEPARATOR);

    if (!splittedOptions.length)
        return null;

    const parsedOptions = {};

    await Promise.all(splittedOptions.map(async item => {
        const keyValuePair = item.split(OPTION_KEY_VALUE_SEPARATOR);
        const key          = keyValuePair[0];
        let value          = keyValuePair[1];

        if (!key || !value)
            return;

        value = await ensureOptionValue(key, value);

        parsedOptions[key] = value;
    }));

    return parsedOptions;
}
github DevExpress / testcafe-hammerhead / src / client / transport.ts View on Github external
asyncServiceMsg (msg): Promise {
        return new Promise((resolve, reject) => {
            this._performRequest(msg, (err, data) => {
                if (!err)
                    resolve(data);
                else if (msg.allowRejecting)
                    reject(err);
            });
        });
    }
github DevExpress / testcafe-browser-provider-electron / src / ipc.js View on Github external
_startIpcServer () {
        return new Promise(resolve => {
            this.ipc.serve(() => resolve(this.ipc.server));

            this.ipc.server.start();
        });
    }
github DevExpress / testcafe / src / client / browser / index.js View on Github external
export function sendXHR (url, createXHR, { method = 'GET', data = null, parseResponse = true } = {}) {
    return new Promise((resolve, reject) => {
        const xhr = createXHR();

        xhr.open(method, url, true);

        if (isRetryingTestPagesEnabled()) {
            xhr.setRequestHeader(UNSTABLE_NETWORK_MODE_HEADER, 'true');
            xhr.setRequestHeader('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
        }

        xhr.onreadystatechange = () => {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    let responseText = xhr.responseText || '';

                    if (responseText && parseResponse)
                        responseText = JSON.parse(xhr.responseText); //eslint-disable-line no-restricted-globals
github DevExpress / testcafe-browser-provider-electron / src / ipc.js View on Github external
_connectToIpcServer () {
        return new Promise(resolve => {
            this.ipc.connectTo(this.serverId, resolve);
        });
    }
github DevExpress / testcafe-browser-provider-electron / src / ipc.js View on Github external
_getIpcSocket () {
        return new Promise(resolve => this.server.on('connect', resolve));
    }

pinkie

Itty bitty little widdle twinkie pinkie ES2015 Promise implementation

MIT
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis