@zohodesk/testinglibrary 2.9.2 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +1 -1
- package/README.md +27 -1
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/fileMutex.js +10 -12
- package/build/core/playwright/index.js +10 -23
- package/build/core/playwright/setup/config-creator.js +3 -3
- package/build/core/playwright/setup/config-utils.js +8 -25
- package/build/core/playwright/tagProcessor.js +18 -28
- package/build/core/playwright/test-runner.js +1 -1
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +1 -1
- package/build/setup-folder-structure/samples/actors-index.js +2 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +14 -66
- package/build/setup-folder-structure/samples/editions-index.js +3 -0
- package/build/setup-folder-structure/samples/free-sample.json +25 -0
- package/build/setup-folder-structure/samples/settings.json +7 -0
- package/build/setup-folder-structure/setupProject.js +18 -5
- package/nobdd/uat/conf/nobdd/uat.config.js +1 -2
- package/nobdd/uat.config.js +1 -2
- package/package.json +7 -7
- package/build/bdd-framework/cli/commands/env.js +0 -42
- package/build/bdd-framework/cli/commands/export.js +0 -62
- package/build/bdd-framework/cli/commands/test.js +0 -64
- package/build/bdd-framework/cli/index.js +0 -11
- package/build/bdd-framework/cli/options.js +0 -19
- package/build/bdd-framework/cli/worker.js +0 -13
- package/build/bdd-framework/config/configDir.js +0 -35
- package/build/bdd-framework/config/enrichReporterData.js +0 -23
- package/build/bdd-framework/config/env.js +0 -50
- package/build/bdd-framework/config/index.js +0 -94
- package/build/bdd-framework/config/lang.js +0 -14
- package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
- package/build/bdd-framework/cucumber/createTestStep.js +0 -43
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +0 -126
- package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +0 -72
- package/build/bdd-framework/cucumber/formatter/PickleParser.js +0 -25
- package/build/bdd-framework/cucumber/formatter/durationHelpers.js +0 -13
- package/build/bdd-framework/cucumber/formatter/getColorFns.js +0 -57
- package/build/bdd-framework/cucumber/formatter/index.js +0 -16
- package/build/bdd-framework/cucumber/formatter/locationHelpers.js +0 -16
- package/build/bdd-framework/cucumber/loadConfig.js +0 -17
- package/build/bdd-framework/cucumber/loadFeatures.js +0 -70
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
- package/build/bdd-framework/cucumber/loadSteps.js +0 -47
- package/build/bdd-framework/cucumber/resolveFeaturePaths.js +0 -62
- package/build/bdd-framework/cucumber/stepArguments.js +0 -21
- package/build/bdd-framework/cucumber/types.js +0 -5
- package/build/bdd-framework/cucumber/valueChecker.js +0 -23
- package/build/bdd-framework/decorators.js +0 -18
- package/build/bdd-framework/gen/fixtures.js +0 -48
- package/build/bdd-framework/gen/formatter.js +0 -167
- package/build/bdd-framework/gen/i18n.js +0 -39
- package/build/bdd-framework/gen/index.js +0 -197
- package/build/bdd-framework/gen/specialTags.js +0 -70
- package/build/bdd-framework/gen/testFile.js +0 -470
- package/build/bdd-framework/gen/testMeta.js +0 -60
- package/build/bdd-framework/gen/testNode.js +0 -35
- package/build/bdd-framework/gen/testPoms.js +0 -133
- package/build/bdd-framework/hooks/scenario.js +0 -130
- package/build/bdd-framework/hooks/worker.js +0 -89
- package/build/bdd-framework/index.js +0 -52
- package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -93
- package/build/bdd-framework/playwright/getLocationInFile.js +0 -79
- package/build/bdd-framework/playwright/loadConfig.js +0 -42
- package/build/bdd-framework/playwright/loadUtils.js +0 -33
- package/build/bdd-framework/playwright/testTypeImpl.js +0 -79
- package/build/bdd-framework/playwright/transform.js +0 -88
- package/build/bdd-framework/playwright/types.js +0 -12
- package/build/bdd-framework/playwright/utils.js +0 -56
- package/build/bdd-framework/reporter/cucumber/base.js +0 -52
- package/build/bdd-framework/reporter/cucumber/custom.js +0 -73
- package/build/bdd-framework/reporter/cucumber/helper.js +0 -12
- package/build/bdd-framework/reporter/cucumber/html.js +0 -40
- package/build/bdd-framework/reporter/cucumber/index.js +0 -74
- package/build/bdd-framework/reporter/cucumber/json.js +0 -312
- package/build/bdd-framework/reporter/cucumber/junit.js +0 -205
- package/build/bdd-framework/reporter/cucumber/message.js +0 -20
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +0 -82
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +0 -197
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +0 -43
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +0 -52
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +0 -105
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +0 -70
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +0 -45
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +0 -27
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +0 -38
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +0 -128
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +0 -154
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +0 -123
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +0 -67
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +0 -114
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +0 -30
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwStepUtils.js +0 -70
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +0 -35
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +0 -5
- package/build/bdd-framework/run/StepInvoker.js +0 -69
- package/build/bdd-framework/run/bddData/index.js +0 -59
- package/build/bdd-framework/run/bddData/types.js +0 -5
- package/build/bdd-framework/run/bddFixtures.js +0 -192
- package/build/bdd-framework/run/bddWorld.js +0 -79
- package/build/bdd-framework/run/bddWorldInternal.js +0 -11
- package/build/bdd-framework/snippets/index.js +0 -132
- package/build/bdd-framework/snippets/snippetSyntax.js +0 -43
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
- package/build/bdd-framework/stepDefinitions/createBdd.js +0 -66
- package/build/bdd-framework/stepDefinitions/decorators/class.js +0 -68
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -99
- package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
- package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
- package/build/bdd-framework/steps/createBdd.js +0 -78
- package/build/bdd-framework/steps/decorators/class.js +0 -68
- package/build/bdd-framework/steps/decorators/steps.js +0 -98
- package/build/bdd-framework/steps/defineStep.js +0 -62
- package/build/bdd-framework/steps/stepConfig.js +0 -24
- package/build/bdd-framework/utils/AutofillMap.js +0 -20
- package/build/bdd-framework/utils/exit.js +0 -62
- package/build/bdd-framework/utils/index.js +0 -93
- package/build/bdd-framework/utils/jsStringWrap.js +0 -44
- package/build/bdd-framework/utils/logger.js +0 -30
- package/build/bdd-framework/utils/stripAnsiEscapes.js +0 -20
- package/build/setup-folder-structure/samples/authUsers-sample.json +0 -9
- package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
- package/nobdd/src/App.js +0 -7
- package/npm-shrinkwrap.json +0 -6475
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBdd = createBdd;
|
|
7
|
-
exports.hasCustomTest = void 0;
|
|
8
|
-
var _bddFixtures = require("../run/bddFixtures");
|
|
9
|
-
var _testTypeImpl = require("../playwright/testTypeImpl");
|
|
10
|
-
var _defineStep = require("./defineStep");
|
|
11
|
-
var _exit = require("../utils/exit");
|
|
12
|
-
var _scenario = require("../hooks/scenario");
|
|
13
|
-
var _worker = require("../hooks/worker");
|
|
14
|
-
var _fixtureParameterNames = require("../playwright/fixtureParameterNames");
|
|
15
|
-
/**
|
|
16
|
-
* Stuff related to writing steps in Playwright-style.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
// Global flag showing that custom test was passed.
|
|
20
|
-
// Used when checking 'importTestFrom' config option.
|
|
21
|
-
// todo: https://github.com/vitalets/playwright-bdd/issues/46
|
|
22
|
-
let hasCustomTest = exports.hasCustomTest = false;
|
|
23
|
-
function createBdd(customTest, _CustomWorld) {
|
|
24
|
-
if (!hasCustomTest) {
|
|
25
|
-
exports.hasCustomTest = hasCustomTest = isCustomTest(customTest);
|
|
26
|
-
}
|
|
27
|
-
const Given = defineStepCtor('Given', hasCustomTest);
|
|
28
|
-
const When = defineStepCtor('When', hasCustomTest);
|
|
29
|
-
const Then = defineStepCtor('Then', hasCustomTest);
|
|
30
|
-
const Step = defineStepCtor('Unknown', hasCustomTest);
|
|
31
|
-
const Before = (0, _scenario.scenarioHookFactory)('before');
|
|
32
|
-
const After = (0, _scenario.scenarioHookFactory)('after');
|
|
33
|
-
const BeforeAll = (0, _worker.workerHookFactory)('beforeAll');
|
|
34
|
-
const AfterAll = (0, _worker.workerHookFactory)('afterAll');
|
|
35
|
-
return {
|
|
36
|
-
Given,
|
|
37
|
-
When,
|
|
38
|
-
Then,
|
|
39
|
-
Step,
|
|
40
|
-
Before,
|
|
41
|
-
After,
|
|
42
|
-
BeforeAll,
|
|
43
|
-
AfterAll
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function defineStepCtor(keyword, hasCustomTest) {
|
|
47
|
-
return (pattern, fn) => {
|
|
48
|
-
(0, _defineStep.defineStep)({
|
|
49
|
-
keyword,
|
|
50
|
-
pattern,
|
|
51
|
-
fn,
|
|
52
|
-
hasCustomTest
|
|
53
|
-
});
|
|
54
|
-
return (fixtures, ...args) => {
|
|
55
|
-
assertStepIsCalledWithRequiredFixtures(pattern, fn, fixtures);
|
|
56
|
-
return fn(fixtures, ...args);
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function isCustomTest(customTest) {
|
|
61
|
-
if (!customTest || customTest === _bddFixtures.test) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
assertTestHasBddFixtures(customTest);
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
function assertTestHasBddFixtures(customTest) {
|
|
68
|
-
if (!(0, _testTypeImpl.isTestContainsSubtest)(customTest, _bddFixtures.test)) {
|
|
69
|
-
(0, _exit.exit)(`createBdd() should use 'test' extended from "playwright-bdd"`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function assertStepIsCalledWithRequiredFixtures(pattern, fn, fixtures) {
|
|
73
|
-
const fixtureNames = (0, _fixtureParameterNames.fixtureParameterNames)(fn);
|
|
74
|
-
const missingFixtures = fixtureNames.filter(fixtureName => !Object.prototype.hasOwnProperty.call(fixtures, fixtureName));
|
|
75
|
-
if (missingFixtures.length) {
|
|
76
|
-
throw new Error([`Invocation of step "${pattern}" from another step does not pass all required fixtures.`, `Missings fixtures: ${missingFixtures.join(', ')}`].join(' '));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Fixture = Fixture;
|
|
7
|
-
exports.getPomNodeByFixtureName = getPomNodeByFixtureName;
|
|
8
|
-
var _steps = require("./steps");
|
|
9
|
-
var _exit = require("../../utils/exit");
|
|
10
|
-
/**
|
|
11
|
-
* Class level @Fixture decorator.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Graph of POM class inheritance.
|
|
16
|
-
* Allows to guess correct fixture by step text.
|
|
17
|
-
*/
|
|
18
|
-
const pomGraph = new Map();
|
|
19
|
-
/**
|
|
20
|
-
* @Fixture decorator.
|
|
21
|
-
*/
|
|
22
|
-
function Fixture(fixtureName) {
|
|
23
|
-
// context parameter is required for decorator by TS even though it's not used
|
|
24
|
-
return (Ctor, _context) => {
|
|
25
|
-
createPomNode(Ctor, fixtureName);
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function createPomNode(Ctor, fixtureName) {
|
|
29
|
-
const pomNode = {
|
|
30
|
-
fixtureName,
|
|
31
|
-
className: Ctor.name,
|
|
32
|
-
children: new Set()
|
|
33
|
-
};
|
|
34
|
-
ensureUniqueFixtureName(pomNode);
|
|
35
|
-
pomGraph.set(Ctor, pomNode);
|
|
36
|
-
(0, _steps.linkStepsWithPomNode)(Ctor, pomNode);
|
|
37
|
-
linkParentWithPomNode(Ctor, pomNode);
|
|
38
|
-
return pomNode;
|
|
39
|
-
}
|
|
40
|
-
function ensureUniqueFixtureName({
|
|
41
|
-
fixtureName,
|
|
42
|
-
className
|
|
43
|
-
}) {
|
|
44
|
-
if (!fixtureName) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const existingPom = getPomNodeByFixtureName(fixtureName);
|
|
48
|
-
if (existingPom) {
|
|
49
|
-
(0, _exit.exit)(`Duplicate fixture name "${fixtureName}"`, `defined for classes: ${existingPom.className}, ${className}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function linkParentWithPomNode(Ctor, pomNode) {
|
|
53
|
-
const parentCtor = Object.getPrototypeOf(Ctor);
|
|
54
|
-
if (!parentCtor) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
// if parentCtor is not in pomGraph, add it.
|
|
58
|
-
// Case: parent class is not marked with @Fixture, but has decorator steps (base class)
|
|
59
|
-
const parentPomNode = pomGraph.get(parentCtor) || createPomNode(parentCtor, '');
|
|
60
|
-
parentPomNode.children.add(pomNode);
|
|
61
|
-
}
|
|
62
|
-
function getPomNodeByFixtureName(fixtureName) {
|
|
63
|
-
for (const pomNode of pomGraph.values()) {
|
|
64
|
-
if (pomNode.fixtureName === fixtureName) {
|
|
65
|
-
return pomNode;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.appendDecoratorSteps = appendDecoratorSteps;
|
|
7
|
-
exports.createStepDecorator = createStepDecorator;
|
|
8
|
-
exports.linkStepsWithPomNode = linkStepsWithPomNode;
|
|
9
|
-
var _bddFixtures = require("../../run/bddFixtures");
|
|
10
|
-
var _buildStepDefinition = require("../../cucumber/buildStepDefinition");
|
|
11
|
-
var _defineStep = require("../defineStep");
|
|
12
|
-
/**
|
|
13
|
-
* Define steps via decorators.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
// initially we sotre step data inside method,
|
|
17
|
-
// and then extract it in @Fixture decorator call
|
|
18
|
-
const decoratedStepSymbol = Symbol('decoratedStep');
|
|
19
|
-
// global list of all decorator steps
|
|
20
|
-
const decoratedSteps = new Set();
|
|
21
|
-
/**
|
|
22
|
-
* Creates @Given, @When, @Then decorators.
|
|
23
|
-
*/
|
|
24
|
-
function createStepDecorator(keyword) {
|
|
25
|
-
return pattern => {
|
|
26
|
-
// context parameter is required for decorator by TS even though it's not used
|
|
27
|
-
return (method, _context) => {
|
|
28
|
-
saveStepConfigToMethod(method, {
|
|
29
|
-
keyword,
|
|
30
|
-
pattern,
|
|
31
|
-
fn: method,
|
|
32
|
-
hasCustomTest: true
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function linkStepsWithPomNode(Ctor, pomNode) {
|
|
38
|
-
if (!(Ctor !== null && Ctor !== void 0 && Ctor.prototype)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const propertyDescriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
|
|
42
|
-
return Object.values(propertyDescriptors).forEach(descriptor => {
|
|
43
|
-
const stepConfig = getStepConfigFromMethod(descriptor);
|
|
44
|
-
if (!stepConfig) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
stepConfig.pomNode = pomNode;
|
|
48
|
-
decoratedSteps.add(stepConfig);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Append decorator steps to Cucumber's supportCodeLibrary.
|
|
53
|
-
*/
|
|
54
|
-
function appendDecoratorSteps(supportCodeLibrary) {
|
|
55
|
-
decoratedSteps.forEach(stepConfig => {
|
|
56
|
-
const {
|
|
57
|
-
keyword,
|
|
58
|
-
pattern,
|
|
59
|
-
fn
|
|
60
|
-
} = stepConfig;
|
|
61
|
-
stepConfig.fn = (fixturesArg, ...args) => {
|
|
62
|
-
const fixture = getFirstNonAutoInjectFixture(fixturesArg, stepConfig);
|
|
63
|
-
return fn.call(fixture, ...args);
|
|
64
|
-
};
|
|
65
|
-
const code = (0, _defineStep.buildCucumberStepCode)(stepConfig);
|
|
66
|
-
const stepDefinition = (0, _buildStepDefinition.buildStepDefinition)({
|
|
67
|
-
keyword,
|
|
68
|
-
pattern,
|
|
69
|
-
code,
|
|
70
|
-
line: 0,
|
|
71
|
-
// not used in playwright-bdd
|
|
72
|
-
options: {},
|
|
73
|
-
// not used in playwright-bdd
|
|
74
|
-
uri: '' // not used in playwright-bdd
|
|
75
|
-
}, supportCodeLibrary);
|
|
76
|
-
supportCodeLibrary.stepDefinitions.push(stepDefinition);
|
|
77
|
-
});
|
|
78
|
-
decoratedSteps.clear();
|
|
79
|
-
// todo: fill supportCodeLibrary.originalCoordinates as it is used in snippets?
|
|
80
|
-
}
|
|
81
|
-
function getFirstNonAutoInjectFixture(fixturesArg, stepConfig) {
|
|
82
|
-
// there should be exatcly one suitable fixture in fixturesArg
|
|
83
|
-
const fixtureNames = Object.keys(fixturesArg).filter(fixtureName => !(0, _bddFixtures.isBddAutoInjectFixture)(fixtureName));
|
|
84
|
-
if (fixtureNames.length === 0) {
|
|
85
|
-
throw new Error(`No suitable fixtures found for decorator step "${stepConfig.pattern}"`);
|
|
86
|
-
}
|
|
87
|
-
if (fixtureNames.length > 1) {
|
|
88
|
-
throw new Error(`Several suitable fixtures found for decorator step "${stepConfig.pattern}"`);
|
|
89
|
-
}
|
|
90
|
-
return fixturesArg[fixtureNames[0]];
|
|
91
|
-
}
|
|
92
|
-
function saveStepConfigToMethod(method, stepConfig) {
|
|
93
|
-
method[decoratedStepSymbol] = stepConfig;
|
|
94
|
-
}
|
|
95
|
-
function getStepConfigFromMethod(descriptor) {
|
|
96
|
-
// filter out getters / setters
|
|
97
|
-
return typeof descriptor.value === 'function' ? descriptor.value[decoratedStepSymbol] : undefined;
|
|
98
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.buildCucumberStepCode = buildCucumberStepCode;
|
|
7
|
-
exports.defineStep = defineStep;
|
|
8
|
-
exports.getStepCode = getStepCode;
|
|
9
|
-
var _cucumber = require("@cucumber/cucumber");
|
|
10
|
-
var _exit = require("../utils/exit");
|
|
11
|
-
/**
|
|
12
|
-
* Defines step by config.
|
|
13
|
-
* Calls cucumber's Given(), When(), Then() under the hood.
|
|
14
|
-
*/
|
|
15
|
-
function defineStep(stepConfig) {
|
|
16
|
-
const {
|
|
17
|
-
keyword,
|
|
18
|
-
pattern
|
|
19
|
-
} = stepConfig;
|
|
20
|
-
const cucumberDefineStepFn = getCucumberDefineStepFn(keyword);
|
|
21
|
-
const code = buildCucumberStepCode(stepConfig);
|
|
22
|
-
try {
|
|
23
|
-
cucumberDefineStepFn(pattern, code);
|
|
24
|
-
} catch (e) {
|
|
25
|
-
// todo: detect that this is import from test file
|
|
26
|
-
// and skip/delay registering cucumber steps until cucumber is loaded
|
|
27
|
-
const isMissingCucumber = /Cucumber that isn't running/i.test(e.message);
|
|
28
|
-
if (isMissingCucumber) {
|
|
29
|
-
(0, _exit.exit)(`Option "importTestFrom" should point to a separate file without step definitions`, `(e.g. without calls of Given, When, Then)`);
|
|
30
|
-
} else {
|
|
31
|
-
throw e;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function buildCucumberStepCode(stepConfig) {
|
|
36
|
-
const code = function (...args) {
|
|
37
|
-
// build the first argument (fixtures) for step fn
|
|
38
|
-
const fixturesArg = Object.assign({}, this.$internal.currentStepFixtures, {
|
|
39
|
-
$testInfo: this.testInfo,
|
|
40
|
-
$test: this.test,
|
|
41
|
-
$tags: this.tags
|
|
42
|
-
});
|
|
43
|
-
return stepConfig.fn.call(this, fixturesArg, ...args);
|
|
44
|
-
};
|
|
45
|
-
code.stepConfig = stepConfig;
|
|
46
|
-
return code;
|
|
47
|
-
}
|
|
48
|
-
function getStepCode(stepDefinition) {
|
|
49
|
-
return stepDefinition.code;
|
|
50
|
-
}
|
|
51
|
-
function getCucumberDefineStepFn(keyword) {
|
|
52
|
-
switch (keyword) {
|
|
53
|
-
case 'Given':
|
|
54
|
-
return _cucumber.Given;
|
|
55
|
-
case 'When':
|
|
56
|
-
return _cucumber.When;
|
|
57
|
-
case 'Then':
|
|
58
|
-
return _cucumber.Then;
|
|
59
|
-
default:
|
|
60
|
-
return _cucumber.defineStep;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getStepConfig = getStepConfig;
|
|
7
|
-
exports.isDecorator = isDecorator;
|
|
8
|
-
exports.isPlaywrightStyle = isPlaywrightStyle;
|
|
9
|
-
/**
|
|
10
|
-
* Playwright-bdd's step config.
|
|
11
|
-
*/
|
|
12
|
-
function getStepConfig(step) {
|
|
13
|
-
return step.code.stepConfig;
|
|
14
|
-
}
|
|
15
|
-
function isDecorator(stepConfig) {
|
|
16
|
-
return Boolean(stepConfig === null || stepConfig === void 0 ? void 0 : stepConfig.pomNode);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Cucumber-style steps don't have stepConfig
|
|
20
|
-
* b/c they created directly via cucumber's Given, When, Then.
|
|
21
|
-
*/
|
|
22
|
-
function isPlaywrightStyle(stepConfig) {
|
|
23
|
-
return Boolean(stepConfig);
|
|
24
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AutofillMap = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Extended Map that automatically creates item if it does not exist.
|
|
9
|
-
*/
|
|
10
|
-
class AutofillMap extends Map {
|
|
11
|
-
getOrCreate(key, createFn) {
|
|
12
|
-
let item = this.get(key);
|
|
13
|
-
if (!item) {
|
|
14
|
-
item = createFn(key);
|
|
15
|
-
this.set(key, item);
|
|
16
|
-
}
|
|
17
|
-
return item;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.AutofillMap = AutofillMap;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.exit = exit;
|
|
7
|
-
exports.withExitHandler = withExitHandler;
|
|
8
|
-
var _worker_threads = require("worker_threads");
|
|
9
|
-
/**
|
|
10
|
-
* Exit utils.
|
|
11
|
-
*
|
|
12
|
-
* When calling process.exit() in worker thread used for test-file generation,
|
|
13
|
-
* logs are not flushed (https://github.com/vitalets/playwright-bdd/issues/59).
|
|
14
|
-
* That's why instead of process.exit we throw ExitError
|
|
15
|
-
* that just sets process.exitCode = 1 and allow program to exit normally.
|
|
16
|
-
* This esnured by wrapping code with withExitHandler().
|
|
17
|
-
*
|
|
18
|
-
* On the other hand, when running in the main thread, especially inside Playwright,
|
|
19
|
-
* thrown error is captured by Playwright and show with additional messages (e.g. no tests found).
|
|
20
|
-
* That's why in main thread we to call process.exit() to show only needed error.
|
|
21
|
-
*
|
|
22
|
-
* Relevant discussions:
|
|
23
|
-
* - https://github.com/nodejs/node/issues/6379
|
|
24
|
-
* - https://github.com/nodejs/node-v0.x-archive/issues/3737
|
|
25
|
-
* - https://github.com/cucumber/cucumber-js/pull/123
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
class ExitError extends Error {
|
|
29
|
-
get stack() {
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function withExitHandler(fn) {
|
|
34
|
-
try {
|
|
35
|
-
return await fn();
|
|
36
|
-
} catch (e) {
|
|
37
|
-
if (e instanceof ExitError) {
|
|
38
|
-
if (e.message) {
|
|
39
|
-
// eslint-disable-next-line no-console
|
|
40
|
-
console.error(e.message);
|
|
41
|
-
}
|
|
42
|
-
process.exitCode = 1;
|
|
43
|
-
} else {
|
|
44
|
-
throw e;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function exit(...messages) {
|
|
49
|
-
messages = messages.filter(Boolean);
|
|
50
|
-
if (_worker_threads.isMainThread) {
|
|
51
|
-
// use console.error() here instead of logger.error() to have less stack
|
|
52
|
-
// for flushing messages to stderr.
|
|
53
|
-
|
|
54
|
-
if (messages.length) {
|
|
55
|
-
// eslint-disable-next-line no-console, max-depth
|
|
56
|
-
console.error('Error:', ...messages);
|
|
57
|
-
}
|
|
58
|
-
process.exit(1);
|
|
59
|
-
} else {
|
|
60
|
-
throw new ExitError(messages.join(' '));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.callWithTimeout = callWithTimeout;
|
|
8
|
-
exports.extractTemplateParams = extractTemplateParams;
|
|
9
|
-
exports.getPackageVersion = getPackageVersion;
|
|
10
|
-
exports.getSymbolByName = getSymbolByName;
|
|
11
|
-
exports.omit = omit;
|
|
12
|
-
exports.removeDuplicates = removeDuplicates;
|
|
13
|
-
exports.resolvePackageRoot = resolvePackageRoot;
|
|
14
|
-
exports.stringifyLocation = stringifyLocation;
|
|
15
|
-
exports.template = template;
|
|
16
|
-
exports.toPosixPath = toPosixPath;
|
|
17
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
18
|
-
var _path = _interopRequireDefault(require("path"));
|
|
19
|
-
var _util = require("util");
|
|
20
|
-
const setTimeoutPromise = (0, _util.promisify)(setTimeout);
|
|
21
|
-
/**
|
|
22
|
-
* Returns Symbol by name.
|
|
23
|
-
* See: https://stackoverflow.com/questions/50453640/how-can-i-get-the-value-of-a-symbol-property
|
|
24
|
-
*/
|
|
25
|
-
function getSymbolByName(target, name) {
|
|
26
|
-
const ownKeys = Reflect.ownKeys(target);
|
|
27
|
-
const symbol = ownKeys.find(key => key.toString() === `Symbol(${name})`);
|
|
28
|
-
if (!symbol) {
|
|
29
|
-
throw new Error(`Symbol "${name}" not found in target. ownKeys: ${ownKeys}`);
|
|
30
|
-
}
|
|
31
|
-
return symbol;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Inserts params into template.
|
|
35
|
-
* Params defined as <param>.
|
|
36
|
-
*/
|
|
37
|
-
function template(t, params = {}) {
|
|
38
|
-
return t.replace(/<(.+?)>/g, (match, key) => {
|
|
39
|
-
return params[key] !== undefined ? String(params[key]) : match;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Extracts all template params from string.
|
|
44
|
-
* Params defined as <param>.
|
|
45
|
-
*/
|
|
46
|
-
function extractTemplateParams(t) {
|
|
47
|
-
return [...t.matchAll(/<(.+?)>/g)].map(m => m[1]);
|
|
48
|
-
}
|
|
49
|
-
function removeDuplicates(arr) {
|
|
50
|
-
return [...new Set(arr)];
|
|
51
|
-
}
|
|
52
|
-
function resolvePackageRoot(packageName) {
|
|
53
|
-
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
54
|
-
return _path.default.dirname(packageJsonPath);
|
|
55
|
-
}
|
|
56
|
-
function getPackageVersion(packageName) {
|
|
57
|
-
const packageRoot = resolvePackageRoot(packageName);
|
|
58
|
-
const packageJsonPath = _path.default.join(packageRoot, 'package.json');
|
|
59
|
-
const packageJson = JSON.parse(_fs.default.readFileSync(packageJsonPath, 'utf8'));
|
|
60
|
-
return packageJson.version || '';
|
|
61
|
-
}
|
|
62
|
-
async function callWithTimeout(fn, timeout, timeoutMsg) {
|
|
63
|
-
if (!timeout) {
|
|
64
|
-
return fn();
|
|
65
|
-
}
|
|
66
|
-
const ac = new AbortController();
|
|
67
|
-
return Promise.race([fn(), setTimeoutPromise(timeout, null, {
|
|
68
|
-
ref: false,
|
|
69
|
-
signal: ac.signal
|
|
70
|
-
}).then(() => {
|
|
71
|
-
throw new Error(timeoutMsg || `Function timeout (${timeout} ms)`);
|
|
72
|
-
})]).finally(() => ac.abort());
|
|
73
|
-
}
|
|
74
|
-
function stringifyLocation({
|
|
75
|
-
line,
|
|
76
|
-
column
|
|
77
|
-
}) {
|
|
78
|
-
return `${line}:${column}`;
|
|
79
|
-
}
|
|
80
|
-
function omit(obj, key) {
|
|
81
|
-
const res = {
|
|
82
|
-
...obj
|
|
83
|
-
};
|
|
84
|
-
delete res[key];
|
|
85
|
-
return res;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns path with "/" separator on all platforms.
|
|
89
|
-
* See: https://stackoverflow.com/questions/53799385/how-can-i-convert-a-windows-path-to-posix-path-using-node-path
|
|
90
|
-
*/
|
|
91
|
-
function toPosixPath(somePath) {
|
|
92
|
-
return somePath.split(_path.default.sep).join(_path.default.posix.sep);
|
|
93
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.jsStringWrap = jsStringWrap;
|
|
7
|
-
/**
|
|
8
|
-
* Adopted version of https://github.com/joliss/js-string-escape
|
|
9
|
-
* - added support of backticks
|
|
10
|
-
* - added 'quotes' option to indicate which quotes to escape
|
|
11
|
-
* - wrap result string with provided quotes
|
|
12
|
-
*
|
|
13
|
-
* Considered alternative is https://github.com/mathiasbynens/jsesc,
|
|
14
|
-
* but it provides additional functionality and much slower
|
|
15
|
-
* See: https://github.com/mathiasbynens/jsesc/issues/16
|
|
16
|
-
*/
|
|
17
|
-
function jsStringWrap(str, {
|
|
18
|
-
quotes = 'single'
|
|
19
|
-
} = {}) {
|
|
20
|
-
const wrapQuote = quotes === 'single' ? "'" : quotes === 'double' ? '"' : '`';
|
|
21
|
-
// eslint-disable-next-line complexity
|
|
22
|
-
const escapedStr = ('' + str).replace(/["'`\\\n\r\u2028\u2029]/g, character => {
|
|
23
|
-
// Escape all characters not included in SingleStringCharacters and
|
|
24
|
-
// DoubleStringCharacters on
|
|
25
|
-
// http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
|
|
26
|
-
switch (character) {
|
|
27
|
-
case wrapQuote:
|
|
28
|
-
case '\\':
|
|
29
|
-
return '\\' + character;
|
|
30
|
-
// Four possible LineTerminator characters need to be escaped:
|
|
31
|
-
case '\n':
|
|
32
|
-
return '\\n';
|
|
33
|
-
case '\r':
|
|
34
|
-
return '\\r';
|
|
35
|
-
case '\u2028':
|
|
36
|
-
return '\\u2028';
|
|
37
|
-
case '\u2029':
|
|
38
|
-
return '\\u2029';
|
|
39
|
-
default:
|
|
40
|
-
return character;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return `${wrapQuote}${escapedStr}${wrapQuote}`;
|
|
44
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.logger = exports.Logger = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Simple logger
|
|
9
|
-
*/
|
|
10
|
-
class Logger {
|
|
11
|
-
options;
|
|
12
|
-
constructor(options = {}) {
|
|
13
|
-
this.options = options;
|
|
14
|
-
}
|
|
15
|
-
log(...args) {
|
|
16
|
-
if (this.options.verbose) {
|
|
17
|
-
console.log(...args);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
warn(...args) {
|
|
21
|
-
// using log() to output warnings to stdout, not stderr
|
|
22
|
-
console.log(...args);
|
|
23
|
-
}
|
|
24
|
-
error(...args) {
|
|
25
|
-
console.error(...args);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// default logger
|
|
29
|
-
exports.Logger = Logger;
|
|
30
|
-
const logger = exports.logger = new Logger();
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.stripAnsiEscapes = stripAnsiEscapes;
|
|
7
|
-
/**
|
|
8
|
-
* Copied from Playwright.
|
|
9
|
-
* See: https://github.com/microsoft/playwright/blob/main/packages/playwright/src/reporters/base.ts#L529
|
|
10
|
-
*
|
|
11
|
-
* Note: there is also 'strip-ansi' package, but is't ESM only.
|
|
12
|
-
* Adding it is tricky now.
|
|
13
|
-
* See: https://www.npmjs.com/package/strip-ansi
|
|
14
|
-
*/
|
|
15
|
-
const ansiRegex = new RegExp(
|
|
16
|
-
// eslint-disable-next-line max-len, no-control-regex
|
|
17
|
-
'([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))', 'g');
|
|
18
|
-
function stripAnsiEscapes(str) {
|
|
19
|
-
return str.replace(ansiRegex, '');
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dev": {
|
|
3
|
-
"domain": "https://desk.localzoho.com/agent",
|
|
4
|
-
"orgName": "org-name",
|
|
5
|
-
"deptName": "dept-name",
|
|
6
|
-
"moduleName": "module-name",
|
|
7
|
-
"devURL": "Provide your devURL here"
|
|
8
|
-
},
|
|
9
|
-
"prod": {
|
|
10
|
-
"domain": "https://desk.localzoho.com/agent",
|
|
11
|
-
"orgName": "org-name",
|
|
12
|
-
"deptName": "dept-name",
|
|
13
|
-
"moduleName": "module-name"
|
|
14
|
-
},
|
|
15
|
-
"k8test": {
|
|
16
|
-
"domain": "https://desk.localzoho.com/agent",
|
|
17
|
-
"orgName": "org-name",
|
|
18
|
-
"deptName": "dept-name",
|
|
19
|
-
"moduleName": "module-name"
|
|
20
|
-
}
|
|
21
|
-
}
|