Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cross-tester

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cross-tester - npm Package Compare versions

Comparing version 3.3.4 to 4.0.0

browsers.example.json

93

dist/index.js

@@ -5,4 +5,2 @@ 'use strict';

var _providers;
Object.defineProperty(exports, "__esModule", {

@@ -13,26 +11,16 @@ value: true

var _lodash = require('lodash');
var _ramda = require('ramda');
var _promisesUtil = require('./promises-util');
var _parseBrowsers = require('./parse-browsers');
var _wdConnector = require('./wd-connector');
var _parseBrowsers2 = _interopRequireDefault(_parseBrowsers);
var _wdConnector2 = _interopRequireDefault(_wdConnector);
var _saucelabs = require('./providers/saucelabs');
var SauceLabs = _interopRequireWildcard(_saucelabs);
var _browserstack = require('./providers/browserstack');
var BrowserStack = _interopRequireWildcard(_browserstack);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var isFunction = (0, _ramda.is)(Function);
var isObject = (0, _ramda.is)(Object);
var isString = (0, _ramda.is)(String);
var providers = (_providers = {}, _defineProperty(_providers, SauceLabs.name, SauceLabs), _defineProperty(_providers, BrowserStack.name, BrowserStack), _providers);
/**

@@ -49,3 +37,3 @@ * @function run

* function
* @property {String} provider - "saucelabs" or "browserstack"
* @property {Provider} provider - any class that implements Provider interface
* @property {String} [code] - valid JS code

@@ -65,3 +53,3 @@ * @property {Boolean} [verbose=false] - if true, prints logs about testing

var provider = _ref.provider;
var Provider = _ref.Provider;
var browsers = _ref.browsers;

@@ -79,20 +67,15 @@ var credentials = _ref.credentials;

if (!providers.hasOwnProperty(provider)) {
throw new Error('Provider "' + provider + '" is not available. Use one of those: ' + Object.keys(providers).join(','));
if (!isFunction(Provider)) {
throw new TypeError('"Provider" must be defined');
}
if (!(0, _lodash.isString)(code)) {
throw new TypeError('"code" must be a string');
if (!isString(code) && !isString(url)) {
throw new TypeError('"code" or "url" must be defined');
}
if (!(0, _lodash.isObject)(credentials) || (0, _lodash.isNull)(credentials) || !(0, _lodash.isString)(credentials.userName) || !(0, _lodash.isString)(credentials.accessToken)) {
if (!isObject(credentials) || (0, _ramda.isNil)(credentials) || !isString(credentials.userName) || !isString(credentials.accessToken)) {
throw new TypeError('"credentials" must be an object with not empty fields "userName" and "accessToken"');
}
var parsed = (0, _parseBrowsers2.default)(browsers);
var _providers$provider = providers[provider];
var createTest = _providers$provider.createTest;
var getConcurrencyLimit = _providers$provider.getConcurrencyLimit;
var parseBrowser = _providers$provider.parseBrowser;
var connect = (0, _wdConnector2.default)(Provider);
var userName = credentials.userName;

@@ -103,17 +86,11 @@ var accessToken = credentials.accessToken;

var testingSessions = Object.keys(parsed).map(function (browserName) {
var browserConfig = (0, _lodash.extend)(parseBrowser(parsed[browserName], browserName), {
displayName: browserName
});
var testingSessions = browsers.map(function (browser) {
return {
test: createTest(browserConfig, userName, accessToken),
browser: browserConfig
test: connect(browser, userName, accessToken),
browserName: browser.displayName
};
}).map(function (_ref2) {
var test = _ref2.test;
var browser = _ref2.browser;
var browserName = _ref2.browserName;
var browserName = browser.displayName;
function print(message) {

@@ -137,3 +114,8 @@ return (0, _promisesUtil.andReturn)(function () {

browser: browserName,
results: results,
results: results.map(function (result) {
return !result.hasOwnProperty('type') ? {
type: 'SUCCESS',
value: result
} : result;
}),
logs: logs

@@ -145,2 +127,5 @@ };

(0, _promisesUtil.andReturn)(test.quit()), (0, _promisesUtil.andThrow)(test.quit())).catch(function (err) {
if (verbose) {}
// console.error(err.stack);
// suppress any error

@@ -152,3 +137,3 @@ // we don't want to break a chain, but continue tests in other browsers

type: 'FAIL',
message: err.message
value: err.message
}],

@@ -162,17 +147,17 @@ logs: []

// run all tests with some concurrency
return getConcurrencyLimit(userName, accessToken).then(function (concurrencyLimit) {
return (0, _promisesUtil.concurrent)(testingSessions, concurrencyLimit).then(function (resultsForAllTests) {
return resultsForAllTests.reduce(function (map) {
var _ref5 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
return Provider.getConcurrencyLimit(userName, accessToken).then(function (concurrencyLimit) {
return (0, _promisesUtil.concurrent)(testingSessions, concurrencyLimit);
}).then(function (resultsForAllTests) {
return resultsForAllTests.reduce(function (map) {
var _ref5 = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var browser = _ref5.browser;
var results = _ref5.results;
var logs = _ref5.logs;
var browser = _ref5.browser;
var results = _ref5.results;
var logs = _ref5.logs;
map[browser] = { results: results, logs: logs };
map[browser] = { results: results, logs: logs };
return map;
}, {});
});
return map;
}, {});
});
}
#!/usr/bin/env node
'use strict';
var _providers;
var _minimist = require('minimist');

@@ -10,2 +12,4 @@

var _fs = require('fs');
var _index = require('./index');

@@ -15,72 +19,85 @@

var _saucelabs = require('./wd-providers/saucelabs');
var _saucelabs2 = _interopRequireDefault(_saucelabs);
var _browserstack = require('./wd-providers/browserstack');
var _browserstack2 = _interopRequireDefault(_browserstack);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var providers = (_providers = {}, _defineProperty(_providers, _saucelabs2.default.name, _saucelabs2.default), _defineProperty(_providers, _browserstack2.default.name, _browserstack2.default), _providers);
var args = (0, _minimist2.default)(process.argv.slice(2));
var defaultConfig = {
provider: 'saucelabs',
code: 'var x = 3; window.__results__.push(window.navigator.userAgent);',
browsers: {
'Google Chrome': {
name: 'chrome',
versions: {
latest: '46'
},
os: 'Windows'
},
'Mozilla Firefox': {
name: 'Firefox',
versions: {
latest: '42'
},
os: 'Windows'
},
'Microsoft Internet Explorer': {
name: 'Internet Explorer',
versions: {
latest: '11',
previous: '10',
old: '9'
},
os: 'Windows'
},
'Apple Safari': {
name: 'Safari',
versions: {
latest: '9',
previous: '8',
old: '7'
},
os: 'OS X'
},
'Microsoft Edge': {
name: 'Microsoft Edge',
versions: {
latest: '20', // works in SL
previous: '12' // works in BS
},
os: 'Windows'
},
'Safari Mobile': {
name: 'Safari',
versions: {
latest: {
osVersion: '8.3',
devices: ['iPhone', 'iPad']
},
previous: {
osVersion: '7.0',
devices: ['iPhone', 'iPad']
}
},
os: 'iOS'
},
'Android Browser': {
name: 'Android Browser',
versions: {
'Lollipop': '5.0',
'Jelly Bean': 'Jelly Bean'
}
}
}
provider: _saucelabs2.default,
code: 'var x = 3; window.__results__.push(window.navigator.userAgent); console.log("some log"); console.warn("some warning"); console.error("some error")',
browsers: [{
displayName: 'Google Chrome',
name: 'chrome',
version: '46',
os: 'windows',
osVersion: '7'
}, {
displayName: 'Google Chrome on Mac',
name: 'chrome',
version: '46',
os: 'os x',
osVersion: '10.10'
}, {
displayName: 'Mozilla Firefox',
name: 'firefox',
version: '42',
os: 'windows',
osVersion: '7'
}, {
displayName: 'Mozilla Firefox on Mac',
name: 'firefox',
version: '42',
os: 'os x',
osVersion: '10.10'
}, {
displayName: 'Safari Desktop',
name: 'safari',
version: '9',
os: 'os x',
osVersion: '10.11'
}, {
displayName: 'Internet Explorer',
name: 'internet explorer',
version: '11',
os: 'windows',
osVersion: '8.1'
}, {
displayName: 'MS Edge',
name: 'edge',
// take the only available version in SL and BS; it's behavior specific for
// Microsoft Edge
version: undefined,
os: 'windows',
osVersion: '10'
}, {
displayName: 'Android Browser',
name: 'android browser',
version: '5.0',
os: 'android',
osVersion: '5'
}, {
displayName: 'Android Browser Old',
name: 'android browser',
version: '4.4',
os: 'android',
osVersion: '4.4'
}, {
displayName: 'iPhone Safari',
name: 'safari mobile',
version: '9.0',
os: 'ios',
osVersion: '9.0',
device: 'iphone'
}]
};

@@ -93,8 +110,8 @@

},
browsers: args.code || args.b ? JSON.parse(args.code || args.b) : defaultConfig.browsers,
browsers: args.browsers || args.b ? JSON.parse((0, _fs.readFileSync)(args.browsers || args.b).toString()) : defaultConfig.browsers,
code: args.code || args.c || defaultConfig.code,
url: args.code || args.s || void 0,
provider: args.provider || args.p || defaultConfig.provider,
url: args.url || args.s || void 0,
Provider: args.provider || args.p ? providers[args.provider || args.p] : defaultConfig.provider,
verbose: true,
timeout: args.code || args.s ? 2000 : 1000
timeout: args.url || args.s ? 2000 : 1000
};

@@ -101,0 +118,0 @@

{
"name": "cross-tester",
"version": "3.3.4",
"version": "4.0.0",
"description": "Utility for automated cross-browser testing with SauceLabs and BrowserStack",

@@ -16,6 +16,8 @@ "main": "dist/index.js",

"lint": "eslint src/",
"mocha": "mocha --compilers js:test/babel.js --reporter spec --ui tdd test --require babel-polyfill",
"mocha": "mocha --compilers js:test/babel.js --reporter spec --ui tdd --require babel-polyfill test/**/*.spec.js src/**/*.spec.js",
"test": "npm run lint && npm run mocha",
"test-dev": "mocha watch --compilers js:test/babel.js --reporter spec --ui tdd --require babel-polyfill test/**/*.spec.js src/**/*.spec.js",
"precompile": "rm -rf dist/ && mkdir -p dist",
"compile": "babel -d dist/ src/ --presets es2015,stage-0,stage-1,stage-2,stage-3",
"compile-dev": "babel -d dist/ src/ --presets es2015,stage-0,stage-1,stage-2,stage-3 --source-maps inline",
"prepublish": "git checkout master && npm run compile",

@@ -39,5 +41,6 @@ "postpublish": "git add dist/; git commit -m 'Build dist/' dist/; git push origin master --tags",

"browserstack-webdriver": "^2.41.1",
"lodash": "^3.10.1",
"minimist": "^1.2.0",
"ramda": "^0.19.1",
"request-promise": "^1.0.2",
"semver": "^5.1.0",
"wd": "^0.4.0"

@@ -49,3 +52,3 @@ },

"babel-core": "^6.3.21",
"babel-plugin-rewire": "^1.0.0-beta-2",
"babel-plugin-rewire": "^1.0.0-beta-3",
"babel-polyfill": "^6.3.14",

@@ -60,5 +63,5 @@ "babel-preset-es2015": "^6.3.13",

"chai-spies-tdd": "^1.0.0",
"eslint": "^1.10.3",
"eslint": "^2.0.0-beta1",
"mocha": "^2.3.4"
}
}

@@ -21,2 +21,3 @@ # cross-tester

url: 'http://output.jsbin.com/kovanuyiqu', // URL to website with code is OK too
timeout: 2000 // specify, how long to wait for results (1000 ms is defualt)
credentials: {

@@ -26,38 +27,48 @@ userName: 'myUserName',

},
browsers: {
'Google Chrome': { // just a display name
name: 'Chrome', // actual browser name
versions: {
'latest': '46', // key is a display name, value - actual version number
'previous': '38'
},
platform: 'Windows',
osVersion: '10' // optional, can be guessed in most cases
},
'iOS Safari': {
name: 'Safari',
versions: {
'latest iPhone': {
osVersion: '9.2',
deviceName: 'iPhone',
devices: ['6', '6 Plus', '5S'] // second part of device name, all of those
// will be combined with the first one, creating 3 testing configurations
},
'previous iPad': {
osVersion: '8.4',
deviceName: 'iPad' // if you don't care about specific models, provide
// just a device name
}
},
platform: 'iOS'
},
'Android Browser': {
name: 'Android Browser',
versions: {
'Lollipop': '5.0',
'KitKat': 'KitKat' // you can use codenames for Android and OS X; in case
// of the first one, the newest version is used (ex. Jelly Bean => 4.3)
}
}
}
browsers: [{
displayName: 'Google Chrome on Mac',
name: 'chrome',
version: '46',
os: 'os x',
osVersion: '10.10'
}, {
displayName: 'Mozilla Firefox on Mac',
name: 'firefox',
version: '42',
os: 'os x',
osVersion: '10.10'
}, {
displayName: 'Safari Desktop',
name: 'safari',
version: '9',
os: 'os x',
osVersion: '10.11'
}, {
displayName: 'Internet Explorer',
name: 'internet explorer',
version: '11',
os: 'windows',
osVersion: '8.1'
}, {
displayName: 'MS Edge',
name: 'edge',
// take the only available version in SL and BS; it's behavior specific for
// Microsoft Edge
version: undefined,
os: 'windows',
osVersion: '10'
}, {
displayName: 'Android Browser',
name: 'android browser',
version: '5.0',
os: 'android',
osVersion: '5'
}, {
displayName: 'iPhone Safari',
name: 'safari mobile',
version: '9.0',
os: 'ios',
osVersion: '9.0',
device: 'iphone'
}]
}).then(

@@ -77,5 +88,5 @@ (results) => console.log(results),

`-u` and `-a` (those three are only required parameters), code with `-c` (or URL
with `-s`) and list of browsers with `-b` (the last one has to be valid JSON
object, so I recommend to simply edit executable file). Full-featured CLI
program is coming!
with `-s`) and json file containing list of browsers with `-b` (the last one has
to be valid JSON object, so I recommend to simply edit executable file). Full
featured CLI program is coming!

@@ -82,0 +93,0 @@ ## Notes

import {
extend,
isNull,
isObject,
isString
} from 'lodash';
isNil,
is
} from 'ramda';
import { concurrent, andReturn, andThrow, call } from './promises-util';
import parseBrowsers from './parse-browsers';
import * as SauceLabs from './providers/saucelabs';
import * as BrowserStack from './providers/browserstack';
import createConnector from './wd-connector';
const isFunction = is(Function);
const isObject = is(Object);
const isString = is(String);
const providers = {
[SauceLabs.name]: SauceLabs,
[BrowserStack.name]: BrowserStack
};
/**

@@ -30,3 +24,3 @@ * @function run

* function
* @property {String} provider - "saucelabs" or "browserstack"
* @property {Provider} provider - any class that implements Provider interface
* @property {String} [code] - valid JS code

@@ -44,3 +38,3 @@ * @property {Boolean} [verbose=false] - if true, prints logs about testing

export default function run({
provider,
Provider,
browsers,

@@ -53,11 +47,11 @@ credentials,

} = {}) {
if (!providers.hasOwnProperty(provider)) {
throw new Error(`Provider "${provider}" is not available. Use one of those: ${Object.keys(providers).join(',')}`);
if(!isFunction(Provider)) {
throw new TypeError('"Provider" must be defined');
}
if(!isString(code)) {
throw new TypeError('"code" must be a string');
if(!isString(code) && !isString(url)) {
throw new TypeError('"code" or "url" must be defined');
}
if(!isObject(credentials) || isNull(credentials) ||
if(!isObject(credentials) || isNil(credentials) ||
!isString(credentials.userName) ||

@@ -69,22 +63,14 @@ !isString(credentials.accessToken)

const parsed = parseBrowsers(browsers);
const { createTest, getConcurrencyLimit, parseBrowser } = providers[provider];
const connect = createConnector(Provider);
const { userName, accessToken } = credentials;
// define tests for all the websites in all browsers (from current config file)
const testingSessions = Object.keys(parsed)
.map((browserName) => {
const browserConfig = extend(parseBrowser(parsed[browserName], browserName), {
displayName: browserName
});
const testingSessions = browsers
.map((browser) => {
return {
test: createTest(browserConfig, userName, accessToken),
browser: browserConfig
test: connect(browser, userName, accessToken),
browserName: browser.displayName
};
})
.map(({ test, browser }) => {
const browserName = browser.displayName;
.map(({ test, browserName }) => {
function print(message) {

@@ -113,3 +99,6 @@ return andReturn(() => Promise.resolve(verbose ? console.log(`${browserName} - ${message}`) : 0));

browser: browserName,
results,
results: results.map((result) => !result.hasOwnProperty('type') ? ({
type: 'SUCCESS',
value: result
}) : result),
logs

@@ -123,2 +112,5 @@ }))

).catch((err) => {
if (verbose) {
// console.error(err.stack);
}
// suppress any error

@@ -130,3 +122,3 @@ // we don't want to break a chain, but continue tests in other browsers

type: 'FAIL',
message: err.message
value: err.message
}],

@@ -140,12 +132,11 @@ logs: []

// run all tests with some concurrency
return getConcurrencyLimit(userName, accessToken).then((concurrencyLimit) =>
concurrent(testingSessions, concurrencyLimit)
.then((resultsForAllTests) => {
return resultsForAllTests.reduce((map, { browser, results, logs } = {}) => {
map[browser] = { results, logs };
return Provider.getConcurrencyLimit(userName, accessToken)
.then((concurrencyLimit) => concurrent(testingSessions, concurrencyLimit))
.then((resultsForAllTests) => {
return resultsForAllTests.reduce((map, { browser, results, logs } = {}) => {
map[browser] = { results, logs };
return map;
}, {});
})
);
return map;
}, {});
});
}

@@ -5,72 +5,81 @@ #!/usr/bin/env node

import { inspect } from 'util';
import { readFileSync } from 'fs';
import run from './index';
import SauceLabsProvider from './wd-providers/saucelabs';
import BrowserStackProvider from './wd-providers/browserstack';
const providers = {
[SauceLabsProvider.name]: SauceLabsProvider,
[BrowserStackProvider.name]: BrowserStackProvider
};
const args = parseArgs(process.argv.slice(2));
const defaultConfig = {
provider: 'saucelabs',
code: 'var x = 3; window.__results__.push(window.navigator.userAgent);',
browsers: {
'Google Chrome': {
name: 'chrome',
versions: {
latest: '46'
},
os: 'Windows'
},
'Mozilla Firefox': {
name: 'Firefox',
versions: {
latest: '42'
},
os: 'Windows'
},
'Microsoft Internet Explorer': {
name: 'Internet Explorer',
versions: {
latest: '11',
previous: '10',
old: '9'
},
os: 'Windows'
},
'Apple Safari': {
name: 'Safari',
versions: {
latest: '9',
previous: '8',
old: '7'
},
os: 'OS X'
},
'Microsoft Edge': {
name: 'Microsoft Edge',
versions: {
latest: '20', // works in SL
previous: '12' // works in BS
},
os: 'Windows'
},
'Safari Mobile': {
name: 'Safari',
versions: {
latest: {
osVersion: '8.3',
devices: ['iPhone', 'iPad']
},
previous: {
osVersion: '7.0',
devices: ['iPhone', 'iPad']
}
},
os: 'iOS'
},
'Android Browser': {
name: 'Android Browser',
versions: {
'Lollipop': '5.0',
'Jelly Bean': 'Jelly Bean'
}
}
}
provider: SauceLabsProvider,
code: 'var x = 3; window.__results__.push(window.navigator.userAgent); console.log("some log"); console.warn("some warning"); console.error("some error")',
browsers: [{
displayName: 'Google Chrome',
name: 'chrome',
version: '46',
os: 'windows',
osVersion: '7'
}, {
displayName: 'Google Chrome on Mac',
name: 'chrome',
version: '46',
os: 'os x',
osVersion: '10.10'
}, {
displayName: 'Mozilla Firefox',
name: 'firefox',
version: '42',
os: 'windows',
osVersion: '7'
}, {
displayName: 'Mozilla Firefox on Mac',
name: 'firefox',
version: '42',
os: 'os x',
osVersion: '10.10'
}, {
displayName: 'Safari Desktop',
name: 'safari',
version: '9',
os: 'os x',
osVersion: '10.11'
}, {
displayName: 'Internet Explorer',
name: 'internet explorer',
version: '11',
os: 'windows',
osVersion: '8.1'
}, {
displayName: 'MS Edge',
name: 'edge',
// take the only available version in SL and BS; it's behavior specific for
// Microsoft Edge
version: undefined,
os: 'windows',
osVersion: '10'
}, {
displayName: 'Android Browser',
name: 'android browser',
version: '5.0',
os: 'android',
osVersion: '5'
}, {
displayName: 'Android Browser Old',
name: 'android browser',
version: '4.4',
os: 'android',
osVersion: '4.4'
}, {
displayName: 'iPhone Safari',
name: 'safari mobile',
version: '9.0',
os: 'ios',
osVersion: '9.0',
device: 'iphone'
}]
};

@@ -83,10 +92,10 @@

},
browsers: (args.code || args.b) ?
JSON.parse((args.code || args.b)) :
browsers: (args.browsers || args.b) ?
JSON.parse(readFileSync(args.browsers || args.b).toString()) :
defaultConfig.browsers,
code: args.code || args.c || defaultConfig.code,
url: args.code || args.s || void 0,
provider: args.provider || args.p || defaultConfig.provider,
url: args.url || args.s || void 0,
Provider: (args.provider || args.p) ? providers[(args.provider || args.p)] : defaultConfig.provider,
verbose: true,
timeout: (args.code || args.s) ? 2000 : 1000
timeout: (args.url || args.s) ? 2000 : 1000
};

@@ -93,0 +102,0 @@

@@ -1,16 +0,21 @@

export default {
'Chrome 40': {
export default [{
displayName: 'Chrome 40',
name: 'Chrome',
version: '40.0'
},
'Firefox 38': {
version: '40.0',
os: 'Windows',
osVersion: '7'
}, {
displayName: 'Firefox 38',
name: 'Firefox',
version: '38.0'
},
'iPhone 8.1': {
name: 'iPhone 8.1',
platform: 'MAC',
version: '38.0',
os: 'Linux',
osVersion: '2.3.2'
}, {
displayName: 'iPhone 8.1',
name: 'Safari Mobile',
version: '8.1',
os: 'iOS',
osVersion: '8.1',
device: 'iPhone 5S'
}
};
];
/* global suite, test, setup, teardown */
import { assign } from 'lodash';
import { merge, mergeAll } from 'ramda';
import { default as chai, assert } from 'chai';

@@ -11,9 +11,9 @@ import chaiSpies from 'chai-spies';

import {
instances as createdTests,
resetInstances as resetCreatedTests,
instances as providerInstances,
resetInstances as resetProviderInstances,
resetReturned as resetReturnedFromMock,
mock as createTestMock,
mock as TestProvider,
makeItAllRight,
throwOn
} from './create-test.mock';
} from './provider.mock';
import testBrowsers from './browsers.fixture';

@@ -23,14 +23,5 @@

RewireAPI.__Rewire__('providers', {
test: {
getConcurrencyLimit: () => Promise.resolve(1),
parseBrowser: (browser, browserName) => assign({ displayName: browserName }, browser),
createTest: createTestMock
}
});
RewireAPI.__Rewire__('parseBrowsers', (browsers) => browsers);
const VALID_CONFIG = {
provider: 'test',
Provider: TestProvider,
browsers: testBrowsers,

@@ -41,3 +32,4 @@ code: 'var abc = 1234;',

accessToken: '1234'
}
},
verbose: false
};

@@ -47,3 +39,3 @@

function overwrite(base, src) {
return assign({}, base, src);
return mergeAll([{}, base, src]);
}

@@ -66,24 +58,2 @@

test('provider parameter checking', () => {
const ERR_PATTERN = /is not available/;
assert.throws(() => {
run(overwrite(VALID_CONFIG, {
provider: 'unknown'
}));
}, ERR_PATTERN);
assert.throws(() => {
run(overwrite(VALID_CONFIG, {
provider: null
}));
}, ERR_PATTERN, 'throws if provider is not available');
assert.throws(() => {
run(overwrite(VALID_CONFIG, {
provider: undefined
}));
}, ERR_PATTERN);
});
test('code parameter checking', () => {

@@ -143,10 +113,14 @@ const ERR_PATTERN = /must be a string/;

setup(() => {
createTestMock.reset();
resetReturnedFromMock();
resetCreatedTests();
resetProviderInstances();
});
test('creating sessions', () => {
run(VALID_CONFIG);
assert.calledExactly(createTestMock, 3, 'one test session per browser');
test('creating sessions', (done) => {
run(VALID_CONFIG).then(() => {
assert.lengthOf(providerInstances, 3, 'one test session per browser');
done();
stopMaking();
}, done);
var stopMaking = makeItAllRight();
});

@@ -163,8 +137,9 @@

done();
stopMaking();
});
makeItAllRight();
var stopMaking = makeItAllRight();
});
test(`resolving returned promise`, (done) => {
test(`not resolving returned promise`, (done) => {
let resolved;

@@ -184,5 +159,4 @@ run(VALID_CONFIG).then(() => {

setup(() => {
createTestMock.reset();
resetReturnedFromMock();
resetCreatedTests();
resetProviderInstances();
});

@@ -206,13 +180,7 @@

run(VALID_CONFIG).then(() => {
createdTests.forEach(({ quit }) => {
// why check it like that? quit method is called twice (once for
// success, once for failure path) and we wish to know if any function
// returned by one of those calls was called (no matter which one)
const callsCount = quit.returned
.map((returnedByQuit) => returnedByQuit.__spy.calls.length)
.reduce((acc, value) => acc + value, 0);
assert.equal(callsCount, 1, 'function returned by quit method was called once');
providerInstances.forEach(({ quit }) => {
assert.calledOnce(quit, 'function returned by quit method was called once');
});
done();
}, console.log.bind(console, 'ERR!'));
});

@@ -219,0 +187,0 @@ throwOn('execute');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc