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

prescript

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prescript - npm Package Compare versions

Comparing version 0.5555555.0-1 to 0.5555555.0-55

26

lib/cli.js

@@ -310,7 +310,4 @@ "use strict";

attach: (name, buffer, mimeType) => {
const allure = singletonAllureInstance_1.default.currentInstance;
const buf = Buffer.from(buffer);
if (allure) {
allure.addAttachment(name, buf, mimeType);
}
singletonAllureInstance_1.default.currentReportingInterface.addAttachment(name, buf, mimeType);
context.log('Attachment added: "%s" (%s, %s bytes)', name, mimeType, buf.length);

@@ -358,14 +355,11 @@ }

}
const allure = singletonAllureInstance_1.default.currentInstance;
if (allure) {
if (log.length > 0) {
const logText = log
.map(item => {
const prefix = `[${new Date(item.timestamp).toJSON()}] `;
return (prefix +
indent_string_1.default(item.text, prefix.length).substr(prefix.length));
})
.join('\n');
allure.addAttachment('Action log', Buffer.from(logText, 'utf8'), 'text/plain');
}
if (log.length > 0) {
const logText = log
.map(item => {
const prefix = `[${new Date(item.timestamp).toJSON()}] `;
return (prefix +
indent_string_1.default(item.text, prefix.length).substr(prefix.length));
})
.join('\n');
singletonAllureInstance_1.default.currentReportingInterface.addAttachment('Action log', Buffer.from(logText, 'utf8'), 'text/plain');
}

@@ -372,0 +366,0 @@ }

@@ -7,3 +7,6 @@ "use strict";

const path_1 = __importDefault(require("path"));
const crypto_1 = require("crypto");
const singletonAllureInstance_1 = __importDefault(require("./singletonAllureInstance"));
const allure_js_commons_1 = require("allure-js-commons");
const writers_1 = require("allure-js-commons/dist/src/writers");
function createReporter(testModulePath, rootStepName) {

@@ -23,35 +26,38 @@ if (!process.env.ALLURE_SUITE_NAME &&

const caseName = process.env.ALLURE_CASE_NAME || getDefaultCaseName();
const Allure = require('allure-js-commons');
const allure = new Allure();
if (process.env.ALLURE_RESULTS_DIR) {
allure.options.targetDir = process.env.ALLURE_RESULTS_DIR;
}
allure.startSuite(suiteName);
allure.startCase(caseName);
singletonAllureInstance_1.default.currentInstance = allure;
const allureConfig = {
resultsDir: process.env.ALLURE_RESULTS_DIR || 'allure-results'
};
const writer = new writers_1.AllureWriter(allureConfig);
const runtime = new allure_js_commons_1.AllureRuntime(Object.assign({}, allureConfig, { writer }));
const group = runtime.startGroup(suiteName);
const test = group.startTest(caseName);
let stack = new TestStepStack(test);
singletonAllureInstance_1.default.currentReportingInterface = {
addAttachment: (name, buf, mimeType) => {
const sha = crypto_1.createHash('sha256')
.update(buf)
.digest('hex');
const fileName = sha + path_1.default.extname(name);
writer.writeAttachment(fileName, buf);
stack.getExecutableItem().addAttachment(name, mimeType, fileName);
}
};
return {
iterationListener: {
onEnter(node) {
if (node.number)
allure.startStep(String(node.name), Date.now());
if (!node.number) {
return;
}
stack = stack.push(String(node.name));
},
onExit(node, error) {
if (node.number)
allure.endStep(error ? 'failed' : 'passed', Date.now());
if (!node.number) {
return;
}
stack = stack.pop(error);
}
},
onFinish(errors) {
if (errors.length) {
const error = errors[0];
if (error.__prescriptPending) {
allure.endCase('pending');
}
else {
allure.endCase('failed', error);
}
}
else {
allure.endCase('passed');
}
allure.endSuite();
stack = stack.pop(errors[0]);
group.endGroup();
}

@@ -61,2 +67,62 @@ };

exports.default = createReporter;
const saveOutcome = (executableItem, outcome) => {
if (!outcome) {
executableItem.status = allure_js_commons_1.Status.PASSED;
executableItem.stage = allure_js_commons_1.Stage.FINISHED;
return;
}
if (outcome.__prescriptPending) {
executableItem.stage = allure_js_commons_1.Stage.FINISHED;
executableItem.status = allure_js_commons_1.Status.SKIPPED;
return;
}
executableItem.stage = allure_js_commons_1.Stage.FINISHED;
executableItem.status = allure_js_commons_1.Status.FAILED;
executableItem.detailsMessage = outcome.message || '';
executableItem.detailsTrace = outcome.stack || '';
};
class NullStepStack {
push() {
throw new Error('This should not happen: Allure stack is corrupted.');
}
pop() {
throw new Error('This should not happen: Allure stack is corrupted.');
}
getExecutableItem() {
throw new Error('This should not happen: Allure stack is corrupted.');
}
}
class TestStepStack {
constructor(test) {
this.test = test;
}
push(stepName) {
return new StepStepStack(this, this.test.startStep(stepName));
}
pop(outcome) {
saveOutcome(this.test, outcome);
this.test.endTest();
return new NullStepStack();
}
getExecutableItem() {
return this.test;
}
}
class StepStepStack {
constructor(parent, step) {
this.parent = parent;
this.step = step;
}
push(stepName) {
return new StepStepStack(this, this.step.startStep(stepName));
}
pop(outcome) {
saveOutcome(this.step, outcome);
this.step.endStep();
return this.parent;
}
getExecutableItem() {
return this.step;
}
}
//# sourceMappingURL=createReporter.js.map

@@ -143,3 +143,3 @@ "use strict";

test(...args) {
if (Array.isArray(args[0])) {
if (isTemplateString(args[0])) {
const name = StepName.named(args[0], ...args.slice(1));

@@ -174,3 +174,3 @@ return (f) => appendTest(name, f);

action(...args) {
if (Array.isArray(args[0])) {
if (isTemplateString(args[0])) {
const name = StepName.named(args[0], ...args.slice(1));

@@ -197,3 +197,3 @@ const definition = getSource(error_stack_parser_1.default.parse(new Error(`Action Step: ${name}`)));

defer(...args) {
if (Array.isArray(args[0])) {
if (isTemplateString(args[0])) {
const name = StepName.named(args[0], ...args.slice(1));

@@ -215,3 +215,3 @@ const definition = getSource(error_stack_parser_1.default.parse(new Error(`Deferred Action Step: ${name}`)));

to(...args) {
if (Array.isArray(args[0])) {
if (isTemplateString(args[0])) {
const name = StepName.named(args[0], ...args.slice(1));

@@ -310,2 +310,5 @@ const definition = getSource(error_stack_parser_1.default.parse(new Error(`Composite Step: ${name}`)));

exports.default = loadTest;
function isTemplateString(input) {
return Array.isArray(input);
}
//# sourceMappingURL=loadTestModule.js.map

@@ -0,4 +1,8 @@

/// <reference types="node" />
export interface IReportingInterface {
addAttachment: (name: string, buf: Buffer, mimeType: string) => void;
}
declare const _default: {
currentInstance: any;
currentReportingInterface: IReportingInterface;
};
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class NullReportingInterface {
constructor() {
this.addAttachment = () => null;
}
}
exports.default = {
currentInstance: null
currentReportingInterface: new NullReportingInterface()
};
//# sourceMappingURL=singletonAllureInstance.js.map
{
"name": "prescript",
"version": "0.5555555.0-1",
"version": "0.5555555.0-55",
"description": "Object-oriented acceptance test tool",

@@ -16,3 +16,3 @@ "main": "./lib/singletonApi.js",

"@types/cosmiconfig": "^5.0.3",
"allure-js-commons": "^1.2.1",
"allure-js-commons": "^2.0.0-beta.7",
"chalk": "^2.4.1",

@@ -34,11 +34,13 @@ "co": "^4.6.0",

"@types/node": "^10.0.0",
"eslint": "^4.19.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.6.0",
"@typescript-eslint/parser": "^2.2.0",
"allure-commandline": "^2.13.0",
"eslint": "^6.3.0",
"eslint-config-prettier": "^6.2.0",
"eslint-plugin-prettier": "^3.1.0",
"glob": "^7.1.2",
"jest": "^22.4.3",
"prettier": "^1.12.1",
"prettier": "^1.18.2",
"ts-jest": "^22.4.4",
"typescript": "^3.0.3",
"typescript-eslint-parser": "^18.0.0"
"typescript": "~3.5.1",
"vuepress": "^1.4.1"
},

@@ -45,0 +47,0 @@ "scripts": {

@@ -22,2 +22,22 @@ # prescript

[Documentation is available on our website.](https://prescript.netlify.com)
[Documentation is available on our website.](https://taskworld.github.io/prescript/)
## Development
Running Prescript example scenarios:
```sh
yarn test-examples
```
Running individual scenario:
```sh
./bin/prescript "./examples/calculator/tests/Basic addition (page object).js"
```
Running unit tests:
```sh
yarn test
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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