How to use chai-as-promised - 10 common examples

To help you get started, we’ve selected a few chai-as-promised 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 IBM-Cloud / insurance-catalog / tests / sauce_actual / test-cases.js View on Github external
var wd = require('wd');
require('colors');
var _ = require("lodash");
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
var url = process.env.APP_URL;

chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

// checking sauce credential
if(!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY){
    console.warn(
        '\nPlease configure your sauce credential:\n\n' +
        'export SAUCE_USERNAME=\n' +
        'export SAUCE_ACCESS_KEY=\n\n'
    );
    throw new Error("Missing sauce credentials");
}

// http configuration, not needed for simple runs
wd.configureHttp( {
    timeout: 60000,
    retryDelay: 15000,
    retries: 5
github localnerve / flux-react-example / tests / functional / sauce-travis.js View on Github external
var wd = require('wd');
require('colors');
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
var browserSpecs = require('./browsers');

var testName = 'Basic test';
var baseUrl = process.env.TEST_BASEURL;
var timeout = 60000;
var state = {
  allPassed: true
};

chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

wd.configureHttp({
  timeout: timeout,
  retryDelay: 15000,
  retries: 5
});

// Define the SauceLabs test
var browserKey = process.env.TEST_BROWSER;
var test = browserSpecs[browserKey];
test.name = testName + ' with ' + browserKey;
test.tags = ['flux-react-example'];
if (process.env.TRAVIS) {
  test.tags = test.tags.concat('travis', process.env.TRAVIS_BRANCH);
  test.build = process.env.TRAVIS_BUILD_NUMBER;
}
github ustwo / ustwo.com-frontend / test / integration / sanity.js View on Github external
'use strict';

import wd from 'wd';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
const Q = wd.Q;

chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

// WebDriver browser instance
let browser;

// browser capabilities
// TODO: we should check Android later, seems currently (November 2015) Sauce
// Labs is having some problems with launching Android emulator fast enough or
// supporting setting a timeout long enough so that we don't intermittently
// get failing tests
const desireds = {
  firefox: {
    browserName: 'firefox',
    platform: 'OS X 10.10',
    screenResolution: '1280x1024'
  },
  chrome: {
github kerrishotts / Mastering-PhoneGap-Code-Package / logology-v06 / test-ui / helpers / should.js View on Github external
// from  https://github.com/appium/sample-code/blob/master/sample-code/examples/node/helpers/setup.js
var wd = require("wd");

require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
var should = chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

exports.should = should;
github sprinteins / ghost / test / spec.ts View on Github external
beforeEach(function() {
    this.app = new Application({
      path: (electronPath as unknown) as string,
      env: {
        NODE_ENV: 'test',
        PRELOAD_GIT_MOCK_FILE: 'glogExampleData.txt',
      },
      // The following line tells spectron to look and use the main.js file
      // and the package.json located 1 level above.
      args: [appPath],
    });

    // this will mock the repo-selection
    fakeDialog.apply(this.app);
    const pwd = `${process.cwd()}/test/testrepo/git`;
    chaiAsPromised.transferPromiseness = this.app.transferPromiseness;
    return this.app.start().then(() => fakeDialog.mock([{ method: 'showOpenDialog', value: { filePaths: [pwd], canceled: false } }]));
  });
github admc / wd / examples / mobile / appium_ios7_sauce.js View on Github external
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
chai.should();

var wd;
try {
  wd = require('wd');
} catch( err ) {
  wd = require('../../lib/main');
}

// enables chai assertion chaining
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

var browser = wd.promiseChainRemote(host, port, username, accessKey);

// optional extra logging
browser.on('status', function(info) {
  console.log(info.cyan);
});
browser.on('command', function(eventType, command, response) {
  console.log(' > ' + eventType.cyan, command, (response || '').grey);
});
browser.on('http', function(meth, path, data) {
  console.log(' > ' + meth.magenta, path, (data || '').grey);
});

var caps;
github admc / wd / examples / promise / wait-for.js View on Github external
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
chai.should();

var wd;
try {
  wd = require('wd');
} catch( err ) {
  wd = require('../../lib/main');
}

var Asserter = wd.Asserter; // asserter base class
var asserters = wd.asserters; // commonly used asserters

// enables chai assertion chaining
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

// js to add and remove a child div
var appendChild =
  'setTimeout(function() {\n' +
  ' $("#i_am_an_id").append("<div class="\\&quot;child\\&quot;">a waitFor child</div>");\n' +
  '}, arguments[0]);\n';

var removeChildren =
  ' $("#i_am_an_id").empty();\n';

// tagging chai assertion errors for retry
var tagChaiAssertionError = function(err) {
  // throw error and tag as retriable to poll again
  err.retriable = err instanceof chai.AssertionError;
  throw err;
};
github admc / wd / examples / promise / external-promise.js View on Github external
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
chai.should();

var wd;
try {
  wd = require('wd');
} catch( err ) {
  wd = require('../../lib/main');
}

var PromiseSimple = require('promise-simple');

// enables chai assertion chaining
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

function altSleepAndOk(ms) {
  var promise = PromiseSimple.defer();
  setTimeout(function() {
    promise.resolve('OK');
  }, ms);
  return promise;
}

// adding custom promise chain method
wd.addPromiseChainMethod(  'altSleepAndOk', altSleepAndOk );

var browser = wd.promiseChainRemote();

// optional extra logging
browser.on('status', function(info) {
github filmaj / appium-test / test / sauce-chrome-location.js View on Github external
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import wd from 'wd';
import {parse} from './helpers/creds';

let creds = parse();
let should = chai.should();
chai.use(chaiAsPromised);
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

let browser = wd.promiseChainRemote(creds.HOST, creds.PORT, creds.USER, creds.KEY);

describe('On Sauce Labs, ', function() {
    this.timeout(60000);
    before(async () => {
        try {
            await browser.init({
                deviceName:'Samsung Galaxy S5 Device',
                platformName:'Android',
                platformVersion:'4.4',
                browserName:'Chrome',
                name:'S5 real device w/ location dialog',
                "appium-version":"1.4.7"
            });
        } catch(err) {
github MarshallOfSound / Google-Play-Music-Desktop-Player-UNOFFICIAL- / test / spectron / util / _harness.js View on Github external
.then(() => {
          chaiAsPromised.transferPromiseness = app.transferPromiseness;
          return app;
        });
    });

chai-as-promised

Extends Chai with assertions about promises.

MIT
Latest version published 6 months ago

Package Health Score

81 / 100
Full package analysis

Popular chai-as-promised functions