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

kunlun

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kunlun - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

lib/clt/fixture/testobject.json

42

lib/clt/cli.js

@@ -9,2 +9,3 @@ // Command Line Tool

│   ├── testData.json
│   ├── testobject.json
│   └── default.json

@@ -87,2 +88,34 @@ ├── lib

{
type: 'input',
name: 'testObjectUsername',
message: 'What\'s your TestObject user name?',
when: function(answers){
return answers.cloudSetting.indexOf('TestObject') !== -1;
},
validate: function( value ) {
var pass = value.match(/^[a-zA-Z_$][a-zA-Z_$0-9]*$/i);
if (pass) {
return true;
} else {
return 'Please enter a valid user name';
}
}
},
{
type: 'input',
name: 'testObjectKey',
message: 'What\'s your TestObject access key (in the format of xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)?',
when: function(answers){
return answers.cloudSetting.indexOf('TestObject') !== -1;
},
validate: function( value ) {
var pass = value.match(/^[0-9a-zA-Z]{32}$/i);
if (pass) {
return true;
} else {
return 'Please enter a valid access key (in the format of xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)';
}
}
},
{
type: 'confirm',

@@ -109,2 +142,4 @@ name: 'toContinue',

var sauceLabsKey = answers.sauceLabsKey || 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
var testObjectUsername = answers.testObjectUsername || 'xxxxxxxxxx';
var testObjectKey = answers.testObjectKey || 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

@@ -126,2 +161,6 @@ // set up app dir

Fs.appendFileSync(Path.join(dir, 'default.json'), content);
// - write config/testobject.json
content = Fs.readFileSync( __dirname + Path.sep + 'fixture/testobject.json', 'utf8');
content = content.replace(/#<testObjectKey>/g, testObjectKey);
Fs.appendFileSync(Path.join(dir, 'testobject.json'), content);
// - write config/testData.json

@@ -146,2 +185,3 @@ content = Fs.readFileSync( __dirname + Path.sep + 'fixture/testData.json', 'utf8');

content = content.replace(/#<sauceLabsKey>/g, sauceLabsKey);
content = content.replace(/#<testObjectKey>/g, testObjectKey);
Fs.appendFileSync(Path.join(dir, 'env.js'), content);

@@ -153,2 +193,4 @@ // - write lib/magellan_setup.js

content = content.replace(/#<sauceLabsKey>/g, sauceLabsKey);
content = content.replace(/#<testObjectUsername>/g, testObjectUsername);
content = content.replace(/#<testObjectKey>/g, testObjectKey);
Fs.appendFileSync(Path.join(dir, 'magellan_setup.js'), content);

@@ -155,0 +197,0 @@ // - create and write lib/module/sampleModule.js

64

lib/clt/fixture/env.js

@@ -7,2 +7,4 @@ var Config = require('config');

var sauce_password = process.env.SAUCE_ACCESS_KEY || '#<sauceLabsKey>';
var testobj_username = process.env.TESTOBJ_USERNAME || '#<testObjectKey>';
var testobj_password = process.env.TESTOBJ_ACCESS_KEY || '';

@@ -26,2 +28,18 @@ var sauceAccount = new SauceLabs({

var title = this.currentTest.fullTitle();
if (Config.desiredCapabilities) {
// Based on --browsers value, Magellan sends back desiredCapabilities to each test
// in NODE_CONFIG env variable, which can be extracted in Config.desiredCapabilities
// Currently Magellan only returns desiredCapabilities like follows:
// {
// "browserName":"iphone",
// "version":"9.2",
// "platform":"OS X 10.10",
// "deviceName":"iPhone Simulator"
// }
// Pending for https://github.com/TestArmada/guacamole/issues/15 to fully integrate
Config.capabilities.platformVersion = Config.desiredCapabilities.version;
Config.capabilities.deviceName = Config.desiredCapabilities.deviceName;
}
return appiumDriver.init(Config.capabilities).then(function() {

@@ -43,3 +61,3 @@ // feed back selenium session ID to parent process (Magellan)

}, function(reason) {
console.log(reason);
console.log("Error reason: " + JSON.stringify(reason));
if (reason.data.sessionId === undefined) {

@@ -60,5 +78,9 @@ throw reason;

// update Sauce dashboard status - job result
var build = process.env.BUILD === undefined ?
Config.remoteAppName + '-' + Moment().format() :
Config.remoteAppName + '-' + process.env.BUILD;
var passed = this.currentTest.state === 'passed' ? 1 : 0;
sauceAccount.updateJob(appiumDriver.sessionID, {
passed: passed,
build: build,
passed: passed
}, function(err) {

@@ -70,2 +92,40 @@ if (err) console.log(err);

});
} else if (Config.capabilities.testobject_api_key) {
appiumDriver = new AppiumDriver(Config.testServer);
var cap = Config.capabilities;
var build = process.env.BUILD === undefined ?
Config.remoteAppName + '-' + Moment().format() :
Config.remoteAppName + '-' + process.env.BUILD;
cap.testobject_suite_name = build;
beforeEach(function() {
cap.testobject_test_name = this.currentTest.fullTitle();
return appiumDriver.init(cap);
});
afterEach(function() {
var passed = this.currentTest.state === 'passed';
if(appiumDriver.sessionID) {
var options = {
uri: 'https://app.testobject.com:443/api/rest/appium/v1/session/' + appiumDriver.session>
json: true,
strictSSL: false,
method: 'PUT',
proxy: Config.proxy,
body: { passed: passed },
auth: {
user: testobj_username,
password: testobj_password
}
};
Request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
} else {
console.log('Error while sending TestObject test status');
console.log(error);
}
});
}
return appiumDriver.quit();
});
} else {

@@ -72,0 +132,0 @@ appiumDriver = new AppiumDriver(Config.testServer);

39

lib/clt/fixture/magellan_setup.js

@@ -8,2 +8,4 @@ var Q = require('q');

var sauce_password = process.env.SAUCE_ACCESS_KEY || '#<sauceLabsKey>';
var testobj_username = process.env.TESTOBJ_USERNAME || '#<testObjectUsername>';
var testobj_password = process.env.TESTOBJ_ACCESS_KEY || '#<testObjectKey>';

@@ -17,7 +19,10 @@ var SetupTeardown = function () {

if (process.env.SAUCE !== 'true' || process.env.UPLOADAPP !== 'true') {
// If we don't plan to upload app to cloud vendor, nothing to do
if (process.env.UPLOADAPP !== 'true') {
deferred.resolve();
return deferred.promise;
} else {
// Zip Config.capabilities.app then upload to Sauce Labs storage
// If upload app to cloud vendor:
// - if upload .app to Sauce Labs, we zip the .app file first then upload
// - if upload .apk to TestObject, directly upload
var config_source = {};

@@ -51,11 +56,23 @@ Config.util.getConfigSources().forEach(function (source) {

// Upload app to Sauce Labs storage
console.log('Start uploading ' + localZipFilePath + ' to Sauce Labs storage...');
Exec(
'curl -u ' + sauce_username + ':' + sauce_password +
' -X POST "http://saucelabs.com/rest/v1/storage/' + sauce_username +
'/' + Config.remoteAppName +
'?overwrite=true" -H "Content-Type: application/octet-stream" --data-binary @'+
localZipFilePath, {stdio:[0, null]}
);
if (process.env.SAUCE == 'true') {
// Upload asset to Sauce Labs storage
console.log('Start uploading ' + localZipFilePath + ' to Sauce Labs storage...');
Exec(
'curl -u ' + sauce_username + ':' + sauce_password +
' -X POST "http://saucelabs.com/rest/v1/storage/' + sauce_username +
'/' + Config.remoteAppName +
'?overwrite=true" -H "Content-Type: application/octet-stream" --data-binary @'+
localZipFilePath, {stdio:[0, null]}
);
} else if (Config.capabilities.testobject_api_key) {
// Upload apk to TestObject storage
console.log('\nStart uploading ' + localZipFilePath + ' to TestObject storage...');
Exec(
'curl -u ' + testobj_username + ':' + testobj_password +
' -X POST https://app.testobject.com:443/api/storage/upload' +
' -H "Content-Type: application/octet-stream" --data-binary @' +
localZipFilePath, {stdio:[0, null]}
);
}
console.log('Upload successful, you are good to go!');

@@ -62,0 +79,0 @@

@@ -5,3 +5,3 @@ # Your Project Name

* Install `Xcode 7.2` (If your Mac OS version is lower than 10.10.5, you need to upgrade your Mac OS first)
* Install `Xcode 7.2` or newer version of Xcode
* Install [Node.js >= v0.12 and npm](http://nodejs.org/)

@@ -8,0 +8,0 @@ * Clone this repo and install npm package dependencies:

exports.AppiumDriver = require('./kunlun');
exports.version = '0.2.6';
exports.version = '0.2.7';
{
"name": "kunlun",
"version": "0.2.6",
"version": "0.2.7",
"author": "Chaoyi Chen, Lillian Wang",

@@ -38,3 +38,3 @@ "description": "Enhanced Appium JS Client",

"devDependencies": {
"mocha": "^2.3.4",
"mocha": "^3.1.0",
"grunt-cli": "^1.1.0",

@@ -41,0 +41,0 @@ "grunt": "^1.0.1",

@@ -19,3 +19,3 @@ ## Kunlun

- [clickEl(selector, by)](#clickelselector-by)
- [typeEl(selector, by)](#typeelselector-by)
- [typeEl(value, selector, by)](#typeelvalue-selector-by)
- [getEls(selector, by)](#getelsselector-by)

@@ -66,4 +66,4 @@ - [getEl(selector, by)](#getelselector-by)

* #### `typeEl(selector, by)`
Type text in selected element after waiting for it to be displayed
* #### `typeEl(value, selector, by)`
Type text value in selected element after waiting for it to be displayed

@@ -70,0 +70,0 @@ * #### `getEls(selector, by)`

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