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

allure-js-commons

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allure-js-commons - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

.eslintrc

2

beans/attachment.js

@@ -19,5 +19,5 @@ /**

}
}
};
};
module.exports = Attachment;

@@ -0,1 +1,2 @@

'use strict';
function Step(name, timestamp) {

@@ -9,5 +10,9 @@ this.name = name;

Step.prototype.addStep = function (step) {
this.steps.push(step)
this.steps.push(step);
};
Step.prototype.addAttachment = function (attachment) {
this.attachments.push(attachment);
};
Step.prototype.end = function (status, timestamp) {

@@ -27,2 +32,7 @@ this.status = status;

title: this.name,
attachments: {
attachment: this.attachments.map(function (attachment) {
return attachment.toXML();
})
},
steps: {

@@ -33,5 +43,5 @@ step: this.steps.map(function (step) {

}
}
};
};
module.exports = Step;

@@ -32,5 +32,5 @@ function Suite(name, timestamp) {

}
}
};
};
module.exports = Suite;

@@ -0,1 +1,2 @@

'use strict';
var STATUSES = ['passed', 'pending', 'skipped', 'failed', 'broken'];

@@ -19,7 +20,7 @@ function Test(name, timestamp) {

Test.prototype.addStep = function (step) {
this.steps.push(step)
this.steps.push(step);
};
Test.prototype.addAttachment = function (attachment) {
this.attachments.push(attachment)
this.attachments.push(attachment);
};

@@ -57,3 +58,3 @@

}
}
};
})

@@ -60,0 +61,0 @@ },

@@ -0,1 +1,2 @@

'use strict';
var _ = require('lodash'),

@@ -11,7 +12,8 @@ Suite = require('./beans/suite'),

this.suites = [];
this.options = {
targetDir: 'allure-results'
};
}
Allure.prototype.setOptions = function(options) {
this.options = _.defaults(options, {
targetDir: 'allure-results'
});
_.assign(this.options, options);
};

@@ -67,3 +69,3 @@

attachment = new Attachment(attachmentName, name, buffer.length, info.mime);
this.getCurrentSuite().currentTest.addAttachment(attachment);
this.getCurrentSuite().currentStep.addAttachment(attachment);
};

@@ -70,0 +72,0 @@

{
"name": "allure-js-commons",
"version": "1.0.3",
"version": "1.1.0",
"description": "Common helper for writing plugins to allure-framework",

@@ -8,6 +8,11 @@ "main": "index.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"pretest": "eslint --ignore-path=.gitignore .",
"test": "JASMINE_CONFIG_PATH=jasmine.json jasmine"
},
"license": "Apache-2.0",
"devDependencies": {},
"devDependencies": {
"eslint": "^1.4.1",
"jasmine": "^2.3.2",
"mockery": "^1.4.0"
},
"dependencies": {

@@ -14,0 +19,0 @@ "fs-extra": "^0.18.2",

@@ -0,1 +1,2 @@

'use strict';
var Allure = function(allure) {

@@ -5,10 +6,15 @@ this._allure = allure;

Allure.prototype.isPromise = function(obj) {
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
};
Allure.prototype.createStep = function(name, stepFunc) {
var that = this;
return function() {
var stepName = that._replace(name, Array.prototype.slice.call(arguments, 0)),
status = 'passed';
var stepName = that._format(name, Array.prototype.slice.call(arguments, 0)),
status = 'passed',
result;
that._allure.startStep(stepName);
try {
var result = stepFunc.apply(this, arguments);
result = stepFunc.apply(this, arguments);
}

@@ -20,14 +26,25 @@ catch(error) {

finally {
that._allure.endStep(status);
if(that.isPromise(result)) {
result.then(
that._allure.endStep.bind(that._allure, 'passed'),
that._allure.endStep.bind(that._allure, 'broken')
);
} else {
that._allure.endStep(status);
}
}
return result;
}
};
};
Allure.prototype.createAttachment = function(name, attachmentFunc, type) {
Allure.prototype.createAttachment = function(name, content, type) {
var that = this;
return function() {
var attachmentName = that._replace(name, Array.prototype.slice.call(arguments, 0)),
buffer = attachmentFunc.apply(this, arguments);
that._allure.addAttachment(attachmentName, buffer, type);
if(typeof content === 'function') {
return function() {
var attachmentName = that._format(name, Array.prototype.slice.call(arguments, 0)),
buffer = content.apply(this, arguments);
return that.createAttachment(attachmentName, buffer, type);
};
} else {
return that._allure.addAttachment(name, content, type);
}

@@ -40,3 +57,3 @@ };

Allure.prototype._replace = function(name, arr) {
Allure.prototype._format = function(name, arr) {
return name.replace(/(\{(\d+)\})/gi, function(match, submatch, index) {

@@ -43,0 +60,0 @@ return arr[index];

@@ -19,4 +19,4 @@ var fileType = require('file-type'),

ext: fileExtension
}
};
}
};
};

@@ -0,1 +1,2 @@

'use strict';
var fs = require('fs-extra'),

@@ -8,3 +9,3 @@ path = require('path'),

writeSuite: function(targetDir, suites) {
fs.outputFileSync(path.join(targetDir, uuid.v4() + '-testsuite.xml'), xml('ns2:test-suite', suites))
fs.outputFileSync(path.join(targetDir, uuid.v4() + '-testsuite.xml'), xml('ns2:test-suite', suites));
},

@@ -11,0 +12,0 @@ writeBuffer: function(targetDir, buffer, ext) {

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