Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@qavajs/template

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qavajs/template - npm Package Compare versions

Comparing version
0.0.7
to
0.8.0
+16
vitest.config.js
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
coverage: {
provider: 'c8',
include: ["src/**/*.ts"],
exclude: ["/lib/", "/node_modules/"],
branches: 80,
functions: 90,
lines: 90,
statements: -10,
},
testTimeout: 20000
}
})
+3
-0

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

## 0.8.0
- :beetle: fixed regexp control characters escape
## 0.0.7

@@ -2,0 +5,0 @@ - :beetle: fixed template duration

+148
-135

@@ -25,2 +25,11 @@ "use strict";

};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -33,156 +42,160 @@ const testCaseRunner = __importStar(require("@cucumber/cucumber/lib/runtime/test_case_runner"));

const QAVAJS_MULTILINE = 'qavajsMultiline';
const ARG_REGEXP = /(<.+?>)/g;
function getTemplateRegexp(scenarioName) {
const name = scenarioName
.replace(/([[\]()^$.?{}*+\\|])/g, '\\$1')
.replace(ARG_REGEXP, '(.+?)');
return new RegExp(`^${name}$`);
}
// memo for gherkin documents
let gherkinDocuments;
async function loadTemplates() {
const templatePaths = await global.config.templates.reduce(
// @ts-ignore
async (paths, pattern) => (await paths).concat(await (0, glob_1.glob)(pattern)), []);
if (!gherkinDocuments) {
gherkinDocuments = await (0, utils_1.parseGherkin)(templatePaths);
}
const argRegexp = /(<.+?>)/g;
// memo templates
const templates = (0, utils_1.cloneDeep)(gherkinDocuments)
.reduce((scenarios, doc) => scenarios.concat(doc.feature ? doc.feature.children : []), [])
.map((featureChild) => {
const scenario = featureChild.scenario;
if (!scenario)
throw new Error('Scenario is not defined');
return {
...scenario,
templateRegex: new RegExp(`^${scenario.name.replace(argRegexp, '(.+?)')}$`),
argNames: scenario.name.match(argRegexp) ?? [],
};
function loadTemplates() {
return __awaiter(this, void 0, void 0, function* () {
const templatePaths = yield global.config.templates.reduce(
// @ts-ignore
(paths, pattern) => __awaiter(this, void 0, void 0, function* () { return (yield paths).concat(yield (0, glob_1.glob)(pattern)); }), []);
if (!gherkinDocuments) {
gherkinDocuments = yield (0, utils_1.parseGherkin)(templatePaths);
}
// memo templates
const templates = (0, utils_1.cloneDeep)(gherkinDocuments)
.reduce((scenarios, doc) => scenarios.concat(doc.feature ? doc.feature.children : []), [])
.map((featureChild) => {
var _a;
const scenario = featureChild.scenario;
if (!scenario)
throw new Error('Scenario is not defined');
return Object.assign(Object.assign({}, scenario), { templateRegex: getTemplateRegexp(scenario.name), argNames: (_a = scenario.name.match(ARG_REGEXP)) !== null && _a !== void 0 ? _a : [] });
});
return templates;
});
return templates;
}
async function runTemplate(templateDefs, pickleStep, callerSteps) {
if (this.isSkippingSteps()) {
return {
status: messages_1.TestStepResultStatus.SKIPPED,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
}
if (callerSteps.includes(pickleStep.text)) {
return {
status: messages_1.TestStepResultStatus.FAILED,
message: `${pickleStep.text} has recursive call`,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
}
const scenario = templateDefs.find((s) => s.templateRegex.test(pickleStep.text));
if (!scenario) {
return {
status: messages_1.TestStepResultStatus.UNDEFINED,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
}
// get scenario arguments
const matchArgs = pickleStep.text.match(scenario.templateRegex);
const args = matchArgs ? matchArgs.splice(1) : [];
const scenarioArgs = scenario.argNames.map((name, index) => ({ name: name.replace(/(^<)|(>$)/g, ''), value: args[index] }));
// if data table or multiline exist add them to scenario args
if (pickleStep?.argument?.docString) {
scenarioArgs.push({
name: QAVAJS_MULTILINE,
value: pickleStep?.argument?.docString?.content,
});
}
if (pickleStep?.argument?.dataTable) {
for (const row of pickleStep.argument.dataTable.rows) {
scenarioArgs.push({ name: row.cells[0].value, value: row.cells[1].value });
function runTemplate(templateDefs, pickleStep, callerSteps) {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
if (this.isSkippingSteps()) {
return {
status: messages_1.TestStepResultStatus.SKIPPED,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
}
}
// get step defs
const stepDefs = cucumber_1.supportCodeLibraryBuilder.buildStepDefinitions(templateDefs.map((step) => step.id));
// execute steps
const stepResults = [];
for (const step of scenario.steps) {
const stepTemplateText = step.text;
step.text = (0, utils_1.resolveTemplateParams)(step.text, scenarioArgs);
const stepDefinition = stepDefs.stepDefinitions.find((sd) => sd.matchesStepName(step.text));
if (step.docString) {
// @ts-ignore
step.argument = {
docString: { content: step.docString.content },
if (callerSteps.includes(pickleStep.text)) {
return {
status: messages_1.TestStepResultStatus.FAILED,
message: `${pickleStep.text} has recursive call`,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
// @ts-ignore
step.argument.docString.content = (0, utils_1.resolveTemplateParams)(step.argument.docString.content, scenarioArgs);
}
if (step.dataTable) {
const rows = step.dataTable.rows.map(row => ({
...row,
cells: row.cells.map(cell => ({
...cell,
value: (0, utils_1.resolveTemplateParams)(cell.value, scenarioArgs)
}))
}));
// @ts-ignore
step.argument = {
dataTable: { rows },
const scenario = templateDefs.find((s) => s.templateRegex.test(pickleStep.text));
if (!scenario) {
return {
status: messages_1.TestStepResultStatus.UNDEFINED,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
}
// try to find template
if (!stepDefinition) {
// @ts-ignore
const result = await runTemplate.apply(this, [templateDefs, step, [...callerSteps, pickleStep.text]]);
if (result.status === messages_1.TestStepResultStatus.UNDEFINED) {
return {
status: messages_1.TestStepResultStatus.FAILED,
message: `${step.text} is not defined`,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
// get scenario arguments
const matchArgs = pickleStep.text.match(scenario.templateRegex);
const args = matchArgs ? matchArgs.splice(1) : [];
const scenarioArgs = scenario.argNames.map((name, index) => ({ name: name.replace(/(^<)|(>$)/g, ''), value: args[index] }));
// if data table or multiline exist add them to scenario args
if ((_a = pickleStep === null || pickleStep === void 0 ? void 0 : pickleStep.argument) === null || _a === void 0 ? void 0 : _a.docString) {
scenarioArgs.push({
name: QAVAJS_MULTILINE,
value: (_c = (_b = pickleStep === null || pickleStep === void 0 ? void 0 : pickleStep.argument) === null || _b === void 0 ? void 0 : _b.docString) === null || _c === void 0 ? void 0 : _c.content,
});
}
if ((_d = pickleStep === null || pickleStep === void 0 ? void 0 : pickleStep.argument) === null || _d === void 0 ? void 0 : _d.dataTable) {
for (const row of pickleStep.argument.dataTable.rows) {
scenarioArgs.push({ name: row.cells[0].value, value: row.cells[1].value });
}
stepResults.push(result);
}
else {
// run BeforeStep hooks
stepResults.push(...(await this.runStepHooks(this.getBeforeStepHookDefinitions(), step)));
// run step itself
let stepResult;
if ((0, messages_1.getWorstTestStepResult)(stepResults).status !== messages_1.TestStepResultStatus.FAILED) {
const hookParameter = {
gherkinDocument: this.gherkinDocument,
pickle: this.pickle,
testCaseStartedId: this.currentTestCaseStartedId,
// get step defs
const stepDefs = cucumber_1.supportCodeLibraryBuilder.buildStepDefinitions(templateDefs.map((step) => step.id));
// execute steps
const stepResults = [];
for (const step of scenario.steps) {
const stepTemplateText = step.text;
step.text = (0, utils_1.resolveTemplateParams)(step.text, scenarioArgs);
const stepDefinition = stepDefs.stepDefinitions.find((sd) => sd.matchesStepName(step.text));
if (step.docString) {
// @ts-ignore
step.argument = {
docString: { content: step.docString.content },
};
stepResult = await this.invokeStep(step, stepDefinition, hookParameter);
stepResults.push(stepResult);
// @ts-ignore
step.argument.docString.content = (0, utils_1.resolveTemplateParams)(step.argument.docString.content, scenarioArgs);
}
// run AfterStep hooks
const afterStepHookResults = await this.runStepHooks(this.getAfterStepHookDefinitions(), step, stepResult);
stepResults.push(...afterStepHookResults);
if (step.dataTable) {
const rows = step.dataTable.rows.map(row => (Object.assign(Object.assign({}, row), { cells: row.cells.map(cell => (Object.assign(Object.assign({}, cell), { value: (0, utils_1.resolveTemplateParams)(cell.value, scenarioArgs) }))) })));
// @ts-ignore
step.argument = {
dataTable: { rows },
};
}
// try to find template
if (!stepDefinition) {
// @ts-ignore
const result = yield runTemplate.apply(this, [templateDefs, step, [...callerSteps, pickleStep.text]]);
if (result.status === messages_1.TestStepResultStatus.UNDEFINED) {
return {
status: messages_1.TestStepResultStatus.FAILED,
message: `${step.text} is not defined`,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
}
stepResults.push(result);
}
else {
// run BeforeStep hooks
stepResults.push(...(yield this.runStepHooks(this.getBeforeStepHookDefinitions(), step)));
// run step itself
let stepResult;
if ((0, messages_1.getWorstTestStepResult)(stepResults).status !== messages_1.TestStepResultStatus.FAILED) {
const hookParameter = {
gherkinDocument: this.gherkinDocument,
pickle: this.pickle,
testCaseStartedId: this.currentTestCaseStartedId,
};
stepResult = yield this.invokeStep(step, stepDefinition, hookParameter);
stepResults.push(stepResult);
}
// run AfterStep hooks
const afterStepHookResults = yield this.runStepHooks(this.getAfterStepHookDefinitions(), step, stepResult);
stepResults.push(...afterStepHookResults);
}
// finalizing scenario
const finalStepResult = (0, messages_1.getWorstTestStepResult)(stepResults);
step.text = stepTemplateText;
const duration = (0, utils_1.getDuration)(stepResults);
if (finalStepResult.status === messages_1.TestStepResultStatus.FAILED) {
return (0, utils_1.formatErrorMessage)(finalStepResult, step, duration);
}
}
// finalizing scenario
const finalStepResult = (0, messages_1.getWorstTestStepResult)(stepResults);
step.text = stepTemplateText;
const duration = (0, utils_1.getDuration)(stepResults);
if (finalStepResult.status === messages_1.TestStepResultStatus.FAILED) {
return (0, utils_1.formatErrorMessage)(finalStepResult, step, duration);
}
}
return {
status: messages_1.TestStepResultStatus.PASSED,
duration: (0, utils_1.getDuration)(stepResults),
};
return {
status: messages_1.TestStepResultStatus.PASSED,
duration: (0, utils_1.getDuration)(stepResults),
};
});
}
const originRunStep = testCaseRunner.default.prototype.runStep;
// patch runStep method
testCaseRunner.default.prototype.runStep = async function (pickleStep, testStep) {
// @ts-ignore
const stepDefinitions = testStep.stepDefinitionIds.map((stepDefinitionId) => (0, utils_1.findStepDefinition)(stepDefinitionId, this.supportCodeLibrary));
if (stepDefinitions.length === 0) {
// guard to check if templates property provided
if (!global.config.templates) {
console.warn('Property templates is not defined. Make sure you have added it to config file');
return {
status: messages_1.TestStepResultStatus.UNDEFINED,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
testCaseRunner.default.prototype.runStep = function (pickleStep, testStep) {
return __awaiter(this, void 0, void 0, function* () {
// @ts-ignore
const stepDefinitions = testStep.stepDefinitionIds.map((stepDefinitionId) => (0, utils_1.findStepDefinition)(stepDefinitionId, this.supportCodeLibrary));
if (stepDefinitions.length === 0) {
// guard to check if templates property provided
if (!global.config.templates) {
console.warn('Property templates is not defined. Make sure you have added it to config file');
return {
status: messages_1.TestStepResultStatus.UNDEFINED,
duration: messages_1.TimeConversion.millisecondsToDuration(0),
};
}
const templates = yield loadTemplates();
return runTemplate.apply(this, [templates, pickleStep, []]);
}
const templates = await loadTemplates();
return runTemplate.apply(this, [templates, pickleStep, []]);
}
return originRunStep.apply(this, [pickleStep, testStep]);
return originRunStep.apply(this, [pickleStep, testStep]);
});
};
//# sourceMappingURL=index.js.map

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

{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gGAAkF;AAClF,iDAU4B;AAC5B,+BAA4B;AAC5B,iDAA+D;AAC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ACnC,QAAQ,EAAE,IAAA,mBAAW,EAAC,WAAW,CAAC;SACrC,CAAC;;CACL;AAED,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;AAC/D,uBAAuB;AACvB,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,UAA2B,UAAsB,EAAE,QAAkB;;QAC5G,aAAa;QACb,MAAM,eAAe,GAAG,QAAQ,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,IAAA,0BAAkB,EAAC,gBAAgB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAC5I,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,gDAAgD;YAChD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;gBAC1B,OAAO,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;gBAC9F,OAAO;oBACH,MAAM,EAAE,+BAAoB,CAAC,SAAS;oBACtC,QAAQ,EAAE,yBAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC;iBACrD,CAAC;aACL;YACD,MAAM,SAAS,GAAG,MAAM,aAAa,EAAE,CAAC;YACxC,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;SAC/D;QACD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC7D,CAAC;CAAA,CAAC"}
{
"name": "@qavajs/template",
"version": "0.0.7",
"version": "0.8.0",
"description": "library that allow to define step definitions on Gherkin language",
"scripts": {
"build": "tsc",
"test": "jest --coverage",
"test:e2e": "ts-node --esm --project tsconfig.json node_modules/@qavajs/cli/bin/qavajs.js run --config test-e2e/template.ts",
"test": "vitest --coverage run",
"test:e2e": "ts-node --project tsconfig.json node_modules/@qavajs/cli/bin/qavajs.js run --config test-e2e/template.ts",
"lint:write": "npm run pretty && eslint ./src/ --fix",
"pretty": "prettier --write ./src/"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint:write"
}
},
"repository": {

@@ -31,34 +26,32 @@ "type": "git",

"devDependencies": {
"@cucumber/cucumber": "^9.1.0",
"@cucumber/cucumber": "^9.1.2",
"@cucumber/gherkin-streams": "^5.0.1",
"@cucumber/messages": "^22.0.0",
"@jest/globals": "^29.5.0",
"@qavajs/cli": "^0.0.21",
"@qavajs/cli": "^0.25.0",
"@qavajs/console-formatter": "^0.2.1",
"@qavajs/memory": "^1.3.0",
"@qavajs/memory": "^1.4.1",
"@qavajs/xunit-formatter": "^0.0.4",
"@types/chai": "^4.3.4",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.5",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.56.0",
"chai": "^4.3.7",
"eslint": "8.36.0",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"@vitest/coverage-c8": "^0.31.1",
"eslint": "8.41.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
"prettier": "^2.8.5",
"ts-jest": "^29.0.5",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
"typescript": "^5.0.4",
"vitest": "^0.31.1"
},
"dependencies": {
"glob": "^10.2.1"
"glob": "^10.2.6"
}
}

@@ -34,3 +34,9 @@ import * as testCaseRunner from '@cucumber/cucumber/lib/runtime/test_case_runner';

const QAVAJS_MULTILINE = 'qavajsMultiline';
const ARG_REGEXP = /(<.+?>)/g;
function getTemplateRegexp(scenarioName: string): RegExp {
const name = scenarioName
.replace(/([[\]()^$.?{}*+\\|])/g, '\\$1')
.replace(ARG_REGEXP, '(.+?)');
return new RegExp(`^${name}$`)
}
// memo for gherkin documents

@@ -48,3 +54,2 @@ let gherkinDocuments: Array<GherkinDocument>;

}
const argRegexp = /(<.+?>)/g;
// memo templates

@@ -58,4 +63,4 @@ const templates: Array<ScenarioTemplate> = cloneDeep(gherkinDocuments)

...scenario,
templateRegex: new RegExp(`^${scenario.name.replace(argRegexp, '(.+?)')}$`),
argNames: scenario.name.match(argRegexp) ?? [],
templateRegex: getTemplateRegexp(scenario.name),
argNames: scenario.name.match(ARG_REGEXP) ?? [],
};

@@ -62,0 +67,0 @@ });

@@ -11,6 +11,5 @@ {

"compilerOptions": {
"baseUrl": ".",
"target": "esnext",
"target": "es2016",
"module": "commonjs",
"moduleResolution": "node",
"moduleResolution": "node16",
"outDir": "./lib",

@@ -39,7 +38,4 @@ "esModuleInterop": true,

"@qavajs/memory"
],
"paths": { /* Specify a set of entries that re-map imports to additional lookup locations. */
"@src/*":["src/*"]
},
]
}
}
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
coveragePathIgnorePatterns: ["/lib/", "/node_modules/"],
coverageThreshold: {
global: {
branches: 90,
functions: 90,
lines: 90,
statements: -10,
},
},
};