@zohodesk/testinglibrary 2.9.1 → 3.0.2
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 +16 -23
- package/README.md +32 -1
- package/build/core/playwright/constants/fileMutexConfig.js +11 -0
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +2 -8
- package/build/core/playwright/helpers/auth/loginSteps.js +25 -18
- package/build/core/playwright/helpers/checkAuthDirectory.js +17 -0
- package/build/core/playwright/helpers/fileMutex.js +58 -0
- 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/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/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +94 -0
- package/nobdd/uat/conf/default/actors/index.js +1 -4
- package/nobdd/uat/conf/default/settings.json +1 -1
- package/nobdd/uat/conf/nobdd/uat.config.js +11 -4
- package/nobdd/uat/env-config.json +3 -3
- package/nobdd/uat/fixtures/setup.teardown.js +2 -1
- package/nobdd/uat/modules/nobdd/steps/VerifyNoBDD.feature.spec.js +3 -3
- package/nobdd/uat.config.js +8 -3
- package/package.json +8 -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/uat/conf/default/actors/beta/custom-module.json +0 -24
- package/nobdd/uat/conf/default/actors/beta/index.js +0 -6
- package/nobdd/uat/conf/default/actors/beta/parent-child.json +0 -24
- package/npm-shrinkwrap.json +0 -6475
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.calcMinMaxByArray = calcMinMaxByArray;
|
|
7
|
-
exports.toCucumberTimestamp = toCucumberTimestamp;
|
|
8
|
-
var _messages = require("@cucumber/messages");
|
|
9
|
-
/**
|
|
10
|
-
* Timing utils.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
function toCucumberTimestamp(time) {
|
|
14
|
-
return _messages.TimeConversion.millisecondsSinceEpochToTimestamp(time);
|
|
15
|
-
}
|
|
16
|
-
function calcMinMaxByArray(items) {
|
|
17
|
-
let startTime = items.length > 0 ? items[0].startTime : new Date();
|
|
18
|
-
let endTime = items.length > 0 ? getEndTime(items[0]) : new Date();
|
|
19
|
-
items.forEach(item => {
|
|
20
|
-
const resultEndTime = getEndTime(item);
|
|
21
|
-
if (item.startTime < startTime) {
|
|
22
|
-
startTime = item.startTime;
|
|
23
|
-
}
|
|
24
|
-
if (resultEndTime > endTime) {
|
|
25
|
-
endTime = resultEndTime;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
startTime,
|
|
30
|
-
duration: endTime.getTime() - startTime.getTime()
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function getEndTime(entity) {
|
|
34
|
-
return new Date(entity.startTime.getTime() + entity.duration);
|
|
35
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StepInvoker = void 0;
|
|
7
|
-
var _loadSteps = require("../cucumber/loadSteps");
|
|
8
|
-
var _getLocationInFile = require("../playwright/getLocationInFile");
|
|
9
|
-
var _testTypeImpl = require("../playwright/testTypeImpl");
|
|
10
|
-
var _defineStep = require("../steps/defineStep");
|
|
11
|
-
var _lang = require("../config/lang");
|
|
12
|
-
/**
|
|
13
|
-
* Class to invoke step in playwright runner.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
class StepInvoker {
|
|
17
|
-
world;
|
|
18
|
-
keyword;
|
|
19
|
-
constructor(world, keyword) {
|
|
20
|
-
this.world = world;
|
|
21
|
-
this.keyword = keyword;
|
|
22
|
-
this.invoke = this.invoke.bind(this);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Invokes particular step.
|
|
26
|
-
* See: https://github.com/cucumber/cucumber-js/blob/main/src/runtime/test_case_runner.ts#L299
|
|
27
|
-
*/
|
|
28
|
-
async invoke(stepText, argument, stepFixtures) {
|
|
29
|
-
var _this$world$$internal;
|
|
30
|
-
this.world.$internal.currentStepFixtures = stepFixtures || {};
|
|
31
|
-
const stepDefinition = this.getStepDefinition(stepText);
|
|
32
|
-
// Get location of step call in generated test file.
|
|
33
|
-
// This call must be exactly here to have correct call stack (before async calls)
|
|
34
|
-
const location = (0, _getLocationInFile.getLocationInFile)(this.world.testInfo.file);
|
|
35
|
-
const stepTitle = this.getStepTitle(stepText);
|
|
36
|
-
const code = (0, _defineStep.getStepCode)(stepDefinition);
|
|
37
|
-
const parameters = await this.getStepParameters(stepDefinition, stepText, argument || undefined);
|
|
38
|
-
(_this$world$$internal = this.world.$internal.bddDataManager) === null || _this$world$$internal === void 0 || _this$world$$internal.registerStep(stepDefinition, stepText, location);
|
|
39
|
-
await (0, _testTypeImpl.runStepWithCustomLocation)(this.world.test, stepTitle, location, () => code.apply(this.world, parameters));
|
|
40
|
-
}
|
|
41
|
-
getStepDefinition(text) {
|
|
42
|
-
const stepDefinition = (0, _loadSteps.findStepDefinition)(this.world.options.supportCodeLibrary, text, this.world.testInfo.file);
|
|
43
|
-
if (!stepDefinition) {
|
|
44
|
-
throw new Error(`Undefined step: "${text}"`);
|
|
45
|
-
}
|
|
46
|
-
return stepDefinition;
|
|
47
|
-
}
|
|
48
|
-
async getStepParameters(stepDefinition, text, argument) {
|
|
49
|
-
// see: https://github.com/cucumber/cucumber-js/blob/main/src/models/step_definition.ts#L25
|
|
50
|
-
const {
|
|
51
|
-
parameters
|
|
52
|
-
} = await stepDefinition.getInvocationParameters({
|
|
53
|
-
hookParameter: {},
|
|
54
|
-
// only text and argument are needed
|
|
55
|
-
step: {
|
|
56
|
-
text,
|
|
57
|
-
argument
|
|
58
|
-
},
|
|
59
|
-
world: this.world
|
|
60
|
-
});
|
|
61
|
-
return parameters;
|
|
62
|
-
}
|
|
63
|
-
getStepTitle(text) {
|
|
64
|
-
// Currently prepend keyword only for English.
|
|
65
|
-
// For other langs it's more complex as we need to pass original keyword from step.
|
|
66
|
-
return (0, _lang.isEnglish)(this.world.options.lang) ? `${this.keyword} ${text}` : text;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.StepInvoker = StepInvoker;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.BddDataManager = void 0;
|
|
7
|
-
exports.getBddDataFromTest = getBddDataFromTest;
|
|
8
|
-
var _createTestStep = require("../../cucumber/createTestStep");
|
|
9
|
-
var _utils = require("../../utils");
|
|
10
|
-
var _utils2 = require("../../playwright/utils");
|
|
11
|
-
const BDD_DATA_ANNOTATION_NAME = '__bddData';
|
|
12
|
-
class BddDataManager {
|
|
13
|
-
testInfo;
|
|
14
|
-
data;
|
|
15
|
-
constructor(testInfo, testMeta, uri) {
|
|
16
|
-
this.testInfo = testInfo;
|
|
17
|
-
this.data = {
|
|
18
|
-
uri,
|
|
19
|
-
pickleLocation: testMeta.pickleLocation,
|
|
20
|
-
steps: []
|
|
21
|
-
};
|
|
22
|
-
this.save({
|
|
23
|
-
create: true
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
registerStep(stepDefinition, stepText, pwStepLocation) {
|
|
27
|
-
const step = (0, _createTestStep.createTestStep)(stepDefinition, stepText);
|
|
28
|
-
this.data.steps.push({
|
|
29
|
-
pwStepLocation: (0, _utils.stringifyLocation)(pwStepLocation),
|
|
30
|
-
stepMatchArgumentsLists: step.stepMatchArgumentsLists || []
|
|
31
|
-
});
|
|
32
|
-
this.save();
|
|
33
|
-
}
|
|
34
|
-
save({
|
|
35
|
-
create = false
|
|
36
|
-
} = {}) {
|
|
37
|
-
(0, _utils2.updateAnnotation)(this.testInfo, {
|
|
38
|
-
type: BDD_DATA_ANNOTATION_NAME,
|
|
39
|
-
description: JSON.stringify(this.data)
|
|
40
|
-
}, {
|
|
41
|
-
create
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.BddDataManager = BddDataManager;
|
|
46
|
-
function getBddDataFromTest({
|
|
47
|
-
annotations
|
|
48
|
-
}) {
|
|
49
|
-
const annotationIndex = annotations.findIndex(isBddDataAnnotation);
|
|
50
|
-
const annotation = annotations[annotationIndex];
|
|
51
|
-
const bddData = annotation !== null && annotation !== void 0 && annotation.description ? JSON.parse(annotation.description) : undefined;
|
|
52
|
-
return {
|
|
53
|
-
bddData,
|
|
54
|
-
annotationIndex
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function isBddDataAnnotation(annotation) {
|
|
58
|
-
return annotation.type === BDD_DATA_ANNOTATION_NAME;
|
|
59
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isBddAutoInjectFixture = isBddAutoInjectFixture;
|
|
7
|
-
exports.test = void 0;
|
|
8
|
-
var _test = require("@playwright/test");
|
|
9
|
-
var _loadConfig = require("../cucumber/loadConfig");
|
|
10
|
-
var _loadSteps = require("../cucumber/loadSteps");
|
|
11
|
-
var _bddWorld = require("./bddWorld");
|
|
12
|
-
var _config = require("../config");
|
|
13
|
-
var _env = require("../config/env");
|
|
14
|
-
var _steps = require("../steps/decorators/steps");
|
|
15
|
-
var _configDir = require("../config/configDir");
|
|
16
|
-
var _scenario = require("../hooks/scenario");
|
|
17
|
-
var _worker = require("../hooks/worker");
|
|
18
|
-
var _StepInvoker = require("./StepInvoker");
|
|
19
|
-
var _testMeta = require("../gen/testMeta");
|
|
20
|
-
var _logger = require("../utils/logger");
|
|
21
|
-
var _enrichReporterData = require("../config/enrichReporterData");
|
|
22
|
-
var _bddData = require("./bddData");
|
|
23
|
-
const test = exports.test = _test.test.extend({
|
|
24
|
-
// load cucumber once per worker (auto-fixture)
|
|
25
|
-
// todo: maybe remove caching in cucumber/loadConfig.ts and cucumber/loadSteps.ts
|
|
26
|
-
// as we call it once per worker. Check generation phase.
|
|
27
|
-
$cucumber: [async ({}, use, workerInfo) => {
|
|
28
|
-
const config = (0, _env.getConfigFromEnv)(workerInfo.project.testDir);
|
|
29
|
-
const environment = {
|
|
30
|
-
cwd: (0, _configDir.getPlaywrightConfigDir)()
|
|
31
|
-
};
|
|
32
|
-
const {
|
|
33
|
-
runConfiguration
|
|
34
|
-
} = await (0, _loadConfig.loadConfig)({
|
|
35
|
-
provided: (0, _config.extractCucumberConfig)(config)
|
|
36
|
-
}, environment);
|
|
37
|
-
const supportCodeLibrary = await (0, _loadSteps.loadSteps)(runConfiguration, environment);
|
|
38
|
-
(0, _steps.appendDecoratorSteps)(supportCodeLibrary);
|
|
39
|
-
const World = (0, _bddWorld.getWorldConstructor)(supportCodeLibrary);
|
|
40
|
-
await use({
|
|
41
|
-
runConfiguration,
|
|
42
|
-
supportCodeLibrary,
|
|
43
|
-
World,
|
|
44
|
-
config
|
|
45
|
-
});
|
|
46
|
-
}, {
|
|
47
|
-
auto: true,
|
|
48
|
-
scope: 'worker'
|
|
49
|
-
}],
|
|
50
|
-
// $lang fixture can be overwritten in test file
|
|
51
|
-
$lang: ({}, use) => use(''),
|
|
52
|
-
// init $bddWorldFixtures with empty object, will be owerwritten in test file for cucumber-style
|
|
53
|
-
$bddWorldFixtures: ({}, use) => use({}),
|
|
54
|
-
$bddWorld: async ({
|
|
55
|
-
$tags,
|
|
56
|
-
$test,
|
|
57
|
-
$bddWorldFixtures,
|
|
58
|
-
$cucumber,
|
|
59
|
-
$lang,
|
|
60
|
-
$testMeta,
|
|
61
|
-
$uri
|
|
62
|
-
}, use, testInfo) => {
|
|
63
|
-
const {
|
|
64
|
-
runConfiguration,
|
|
65
|
-
supportCodeLibrary,
|
|
66
|
-
World,
|
|
67
|
-
config
|
|
68
|
-
} = $cucumber;
|
|
69
|
-
const world = new World({
|
|
70
|
-
testInfo,
|
|
71
|
-
supportCodeLibrary,
|
|
72
|
-
$tags,
|
|
73
|
-
$test,
|
|
74
|
-
$bddWorldFixtures,
|
|
75
|
-
lang: $lang,
|
|
76
|
-
parameters: runConfiguration.runtime.worldParameters || {},
|
|
77
|
-
log: () => _logger.logger.warn(`world.log() is noop, please use world.testInfo.attach()`),
|
|
78
|
-
attach: async () => _logger.logger.warn(`world.attach() is noop, please use world.testInfo.attach()`)
|
|
79
|
-
});
|
|
80
|
-
if ((0, _enrichReporterData.getEnrichReporterData)(config)) {
|
|
81
|
-
world.$internal.bddDataManager = new _bddData.BddDataManager(testInfo, $testMeta, $uri);
|
|
82
|
-
}
|
|
83
|
-
await world.init();
|
|
84
|
-
await use(world);
|
|
85
|
-
await world.destroy();
|
|
86
|
-
},
|
|
87
|
-
Given: ({
|
|
88
|
-
$bddWorld
|
|
89
|
-
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'Given').invoke),
|
|
90
|
-
When: ({
|
|
91
|
-
$bddWorld
|
|
92
|
-
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'When').invoke),
|
|
93
|
-
Then: ({
|
|
94
|
-
$bddWorld
|
|
95
|
-
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'Then').invoke),
|
|
96
|
-
And: ({
|
|
97
|
-
$bddWorld
|
|
98
|
-
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'And').invoke),
|
|
99
|
-
But: ({
|
|
100
|
-
$bddWorld
|
|
101
|
-
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'But').invoke),
|
|
102
|
-
// init $testMetaMap with empty object, will be overwritten in each test file
|
|
103
|
-
$testMetaMap: ({}, use) => use({}),
|
|
104
|
-
// concrete test meta
|
|
105
|
-
$testMeta: ({
|
|
106
|
-
$testMetaMap
|
|
107
|
-
}, use, testInfo) => use((0, _testMeta.getTestMeta)($testMetaMap, testInfo)),
|
|
108
|
-
// concrete test tags
|
|
109
|
-
$tags: ({
|
|
110
|
-
$testMeta
|
|
111
|
-
}, use) => use($testMeta.tags || []),
|
|
112
|
-
// init $test with base test, but it will be overwritten in test file
|
|
113
|
-
$test: ({}, use) => use(_test.test),
|
|
114
|
-
// feature file uri, relative to configDir, will be overwritten in test file
|
|
115
|
-
$uri: ({}, use) => use(''),
|
|
116
|
-
// can be owerwritten in test file if there are scenario hooks
|
|
117
|
-
$scenarioHookFixtures: ({}, use) => use({}),
|
|
118
|
-
$before: [
|
|
119
|
-
// Unused dependencies are important:
|
|
120
|
-
// 1. $beforeAll / $afterAll: in pw < 1.39 worker-scoped auto-fixtures were called after test-scoped
|
|
121
|
-
// 2. $after: to call after hooks in case of errors in before hooks
|
|
122
|
-
async ({
|
|
123
|
-
$scenarioHookFixtures,
|
|
124
|
-
$bddWorld,
|
|
125
|
-
$tags,
|
|
126
|
-
$beforeAll,
|
|
127
|
-
$afterAll,
|
|
128
|
-
$after
|
|
129
|
-
}, use, $testInfo) => {
|
|
130
|
-
await (0, _scenario.runScenarioHooks)('before', {
|
|
131
|
-
$bddWorld,
|
|
132
|
-
$tags,
|
|
133
|
-
$testInfo,
|
|
134
|
-
...$scenarioHookFixtures
|
|
135
|
-
});
|
|
136
|
-
await use();
|
|
137
|
-
}, {
|
|
138
|
-
auto: true
|
|
139
|
-
}],
|
|
140
|
-
$after: [async ({
|
|
141
|
-
$scenarioHookFixtures,
|
|
142
|
-
$bddWorld,
|
|
143
|
-
$tags
|
|
144
|
-
}, use, $testInfo) => {
|
|
145
|
-
await use();
|
|
146
|
-
await (0, _scenario.runScenarioHooks)('after', {
|
|
147
|
-
$bddWorld,
|
|
148
|
-
$tags,
|
|
149
|
-
$testInfo,
|
|
150
|
-
...$scenarioHookFixtures
|
|
151
|
-
});
|
|
152
|
-
}, {
|
|
153
|
-
auto: true
|
|
154
|
-
}],
|
|
155
|
-
// can be owerwritten in test file if there are worker hooks
|
|
156
|
-
$workerHookFixtures: [({}, use) => use({}), {
|
|
157
|
-
scope: 'worker'
|
|
158
|
-
}],
|
|
159
|
-
$beforeAll: [
|
|
160
|
-
// Important unused dependencies:
|
|
161
|
-
// 1. $afterAll: in pw < 1.39 worker-scoped auto-fixtures are called in incorrect order
|
|
162
|
-
// 2. $cucumber: to load hooks before this fixtures
|
|
163
|
-
async ({
|
|
164
|
-
$workerHookFixtures,
|
|
165
|
-
$cucumber
|
|
166
|
-
}, use, $workerInfo) => {
|
|
167
|
-
await (0, _worker.runWorkerHooks)('beforeAll', {
|
|
168
|
-
$workerInfo,
|
|
169
|
-
...$workerHookFixtures
|
|
170
|
-
});
|
|
171
|
-
await use();
|
|
172
|
-
}, {
|
|
173
|
-
auto: true,
|
|
174
|
-
scope: 'worker'
|
|
175
|
-
}],
|
|
176
|
-
$afterAll: [async ({
|
|
177
|
-
$workerHookFixtures
|
|
178
|
-
}, use, $workerInfo) => {
|
|
179
|
-
await use();
|
|
180
|
-
await (0, _worker.runWorkerHooks)('afterAll', {
|
|
181
|
-
$workerInfo,
|
|
182
|
-
...$workerHookFixtures
|
|
183
|
-
});
|
|
184
|
-
}, {
|
|
185
|
-
auto: true,
|
|
186
|
-
scope: 'worker'
|
|
187
|
-
}]
|
|
188
|
-
});
|
|
189
|
-
const BDD_AUTO_INJECT_FIXTURES = ['$testInfo', '$test', '$tags'];
|
|
190
|
-
function isBddAutoInjectFixture(name) {
|
|
191
|
-
return BDD_AUTO_INJECT_FIXTURES.includes(name);
|
|
192
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.BddWorld = void 0;
|
|
7
|
-
exports.getWorldConstructor = getWorldConstructor;
|
|
8
|
-
var _cucumber = require("@cucumber/cucumber");
|
|
9
|
-
var _bddWorldInternal = require("./bddWorldInternal");
|
|
10
|
-
class BddWorld extends _cucumber.World {
|
|
11
|
-
options;
|
|
12
|
-
// special namespace to hold internal bdd related methods, must be public.
|
|
13
|
-
$internal;
|
|
14
|
-
constructor(options) {
|
|
15
|
-
super(options);
|
|
16
|
-
this.options = options;
|
|
17
|
-
this.$internal = new _bddWorldInternal.BddWorldInternal();
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Use custom fixture in cucumber-style steps.
|
|
21
|
-
*
|
|
22
|
-
* Note: TS does not support partial generic inference,
|
|
23
|
-
* that's why we can't use this.useFixture<typeof test>('xxx');
|
|
24
|
-
* The solution is to pass TestType as a generic to BddWorld
|
|
25
|
-
* and call useFixture without explicit generic params.
|
|
26
|
-
* Finally, it looks even better as there is no need to pass `typeof test`
|
|
27
|
-
* in every `this.useFixture` call.
|
|
28
|
-
*
|
|
29
|
-
* The downside - it's impossible to pass fixtures type directly to `this.useFixture`
|
|
30
|
-
* like it's done in @Fixture decorator.
|
|
31
|
-
*
|
|
32
|
-
* See: https://stackoverflow.com/questions/45509621/specify-only-first-type-argument
|
|
33
|
-
* See: https://github.com/Microsoft/TypeScript/pull/26349
|
|
34
|
-
*/
|
|
35
|
-
useFixture(fixtureName) {
|
|
36
|
-
return this.$internal.currentStepFixtures[fixtureName];
|
|
37
|
-
}
|
|
38
|
-
get page() {
|
|
39
|
-
return this.options.$bddWorldFixtures.page;
|
|
40
|
-
}
|
|
41
|
-
get context() {
|
|
42
|
-
return this.options.$bddWorldFixtures.context;
|
|
43
|
-
}
|
|
44
|
-
get browser() {
|
|
45
|
-
return this.options.$bddWorldFixtures.browser;
|
|
46
|
-
}
|
|
47
|
-
get browserName() {
|
|
48
|
-
return this.options.$bddWorldFixtures.browserName;
|
|
49
|
-
}
|
|
50
|
-
get request() {
|
|
51
|
-
return this.options.$bddWorldFixtures.request;
|
|
52
|
-
}
|
|
53
|
-
get testInfo() {
|
|
54
|
-
return this.options.testInfo;
|
|
55
|
-
}
|
|
56
|
-
get tags() {
|
|
57
|
-
return this.options.$tags;
|
|
58
|
-
}
|
|
59
|
-
get test() {
|
|
60
|
-
return this.options.$test;
|
|
61
|
-
}
|
|
62
|
-
async init() {
|
|
63
|
-
// async setup before each test
|
|
64
|
-
}
|
|
65
|
-
async destroy() {
|
|
66
|
-
// async teardown after each test
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.BddWorld = BddWorld;
|
|
70
|
-
function getWorldConstructor(supportCodeLibrary) {
|
|
71
|
-
// setWorldConstructor was not called
|
|
72
|
-
if (supportCodeLibrary.World === _cucumber.World) {
|
|
73
|
-
return BddWorld;
|
|
74
|
-
}
|
|
75
|
-
if (!Object.prototype.isPrototypeOf.call(BddWorld, supportCodeLibrary.World)) {
|
|
76
|
-
throw new Error(`CustomWorld should inherit from playwright-bdd World`);
|
|
77
|
-
}
|
|
78
|
-
return supportCodeLibrary.World;
|
|
79
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Snippets = void 0;
|
|
7
|
-
var _url = require("url");
|
|
8
|
-
var _loadSnippetBuilder = require("../cucumber/loadSnippetBuilder");
|
|
9
|
-
var _logger = require("../utils/logger");
|
|
10
|
-
var _stepConfig = require("../steps/stepConfig");
|
|
11
|
-
/**
|
|
12
|
-
* Generate and show snippets for undefined steps
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
class Snippets {
|
|
16
|
-
files;
|
|
17
|
-
runConfiguration;
|
|
18
|
-
supportCodeLibrary;
|
|
19
|
-
snippetBuilder;
|
|
20
|
-
bddBuiltInSyntax = false;
|
|
21
|
-
constructor(files, runConfiguration, supportCodeLibrary) {
|
|
22
|
-
this.files = files;
|
|
23
|
-
this.runConfiguration = runConfiguration;
|
|
24
|
-
this.supportCodeLibrary = supportCodeLibrary;
|
|
25
|
-
}
|
|
26
|
-
async print() {
|
|
27
|
-
this.snippetBuilder = await this.createSnippetBuilder();
|
|
28
|
-
const snippets = this.getSnippets();
|
|
29
|
-
this.printHeader();
|
|
30
|
-
this.printSnippets(snippets);
|
|
31
|
-
this.printFooter(snippets);
|
|
32
|
-
// exit();
|
|
33
|
-
}
|
|
34
|
-
async createSnippetBuilder() {
|
|
35
|
-
const snippetInterface = this.runConfiguration.formats.options.snippetInterface;
|
|
36
|
-
const snippetSyntax = this.getSnippetSyntax();
|
|
37
|
-
return (0, _loadSnippetBuilder.loadSnippetBuilder)(this.supportCodeLibrary, snippetInterface, snippetSyntax);
|
|
38
|
-
}
|
|
39
|
-
getSnippetSyntax() {
|
|
40
|
-
const snippetSyntax = this.runConfiguration.formats.options.snippetSyntax;
|
|
41
|
-
if (!snippetSyntax && this.isPlaywrightStyle()) {
|
|
42
|
-
this.bddBuiltInSyntax = true;
|
|
43
|
-
const filePath = this.isDecorators() ? require.resolve('./snippetSyntaxDecorators.js') : this.isTypeScript() ? require.resolve('./snippetSyntaxTs.js') : require.resolve('./snippetSyntax.js');
|
|
44
|
-
return (0, _url.pathToFileURL)(filePath).toString();
|
|
45
|
-
} else {
|
|
46
|
-
return snippetSyntax;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
getSnippets() {
|
|
50
|
-
const snippetsSet = new Set();
|
|
51
|
-
const snippets = [];
|
|
52
|
-
this.files.forEach(file => {
|
|
53
|
-
file.undefinedSteps.forEach(undefinedStep => {
|
|
54
|
-
const {
|
|
55
|
-
snippet,
|
|
56
|
-
snippetWithLocation
|
|
57
|
-
} = this.getSnippet(file, snippets.length + 1, undefinedStep);
|
|
58
|
-
if (!snippetsSet.has(snippet)) {
|
|
59
|
-
snippetsSet.add(snippet);
|
|
60
|
-
snippets.push(snippetWithLocation);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
return snippets;
|
|
65
|
-
}
|
|
66
|
-
getSnippet(file, index, undefinedStep) {
|
|
67
|
-
const snippet = this.snippetBuilder.build({
|
|
68
|
-
keywordType: undefinedStep.keywordType,
|
|
69
|
-
pickleStep: undefinedStep.pickleStep
|
|
70
|
-
});
|
|
71
|
-
const {
|
|
72
|
-
line,
|
|
73
|
-
column
|
|
74
|
-
} = undefinedStep.step.location;
|
|
75
|
-
const snippetWithLocation = [`// ${index}. Missing step definition for "${file.featureUri}:${line}:${column}"`, snippet].join('\n');
|
|
76
|
-
return {
|
|
77
|
-
snippet,
|
|
78
|
-
snippetWithLocation
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
isTypeScript() {
|
|
82
|
-
const {
|
|
83
|
-
requirePaths,
|
|
84
|
-
importPaths
|
|
85
|
-
} = this.supportCodeLibrary.originalCoordinates;
|
|
86
|
-
return requirePaths.some(p => p.endsWith('.ts')) || importPaths.some(p => p.endsWith('.ts'));
|
|
87
|
-
}
|
|
88
|
-
isPlaywrightStyle() {
|
|
89
|
-
const {
|
|
90
|
-
stepDefinitions
|
|
91
|
-
} = this.supportCodeLibrary;
|
|
92
|
-
return stepDefinitions.length > 0 ? stepDefinitions.some(step => (0, _stepConfig.isPlaywrightStyle)((0, _stepConfig.getStepConfig)(step))) : true;
|
|
93
|
-
}
|
|
94
|
-
isDecorators() {
|
|
95
|
-
const {
|
|
96
|
-
stepDefinitions
|
|
97
|
-
} = this.supportCodeLibrary;
|
|
98
|
-
const decoratorSteps = stepDefinitions.filter(step => (0, _stepConfig.isDecorator)((0, _stepConfig.getStepConfig)(step)));
|
|
99
|
-
return decoratorSteps.length > stepDefinitions.length / 2;
|
|
100
|
-
}
|
|
101
|
-
printHeader() {
|
|
102
|
-
const lines = [`Missing steps found. Use snippets below:`];
|
|
103
|
-
if (this.bddBuiltInSyntax) {
|
|
104
|
-
if (this.isDecorators()) {
|
|
105
|
-
lines.push(`import { Fixture, Given, When, Then } from 'playwright-bdd/decorators';\n`);
|
|
106
|
-
} else {
|
|
107
|
-
lines.push(`import { createBdd } from '@zohodesk/testinglibrary';`, `const { Given, When, Then } = createBdd();\n`);
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
lines.push(`import { Given, When, Then } from '@cucumber/cucumber';\n`);
|
|
111
|
-
}
|
|
112
|
-
_logger.logger.error(lines.join('\n\n'));
|
|
113
|
-
}
|
|
114
|
-
printSnippets(snippets) {
|
|
115
|
-
_logger.logger.error(snippets.concat(['']).join('\n\n'));
|
|
116
|
-
}
|
|
117
|
-
printFooter(snippets) {
|
|
118
|
-
_logger.logger.error(`Missing step definitions (${snippets.length}).`, `Use snippets above to create them.`);
|
|
119
|
-
this.printWarningOnZeroScannedFiles();
|
|
120
|
-
}
|
|
121
|
-
printWarningOnZeroScannedFiles() {
|
|
122
|
-
const {
|
|
123
|
-
requirePaths,
|
|
124
|
-
importPaths
|
|
125
|
-
} = this.supportCodeLibrary.originalCoordinates;
|
|
126
|
-
const scannedFilesCount = requirePaths.length + importPaths.length;
|
|
127
|
-
if (scannedFilesCount === 0 && !this.isDecorators()) {
|
|
128
|
-
_logger.logger.error(`Note that 0 step definition files found, check the config.`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
exports.Snippets = Snippets;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
// todo: custom cucumber parameters
|
|
8
|
-
// See: https://github.com/cucumber/cucumber-expressions#custom-parameter-types
|
|
9
|
-
class _default {
|
|
10
|
-
isTypescript = false;
|
|
11
|
-
build({
|
|
12
|
-
generatedExpressions,
|
|
13
|
-
functionName,
|
|
14
|
-
stepParameterNames
|
|
15
|
-
}) {
|
|
16
|
-
// Always take only first generatedExpression
|
|
17
|
-
// Other expressions are for int/float combinations
|
|
18
|
-
const generatedExpression = generatedExpressions[0];
|
|
19
|
-
const expressionParameters = generatedExpression.parameterNames.map((name, i) => {
|
|
20
|
-
const argName = `arg${i === 0 ? '' : i}`;
|
|
21
|
-
const type = name.startsWith('string') ? 'string' : 'number';
|
|
22
|
-
return this.isTypescript ? `${argName}: ${type}` : argName;
|
|
23
|
-
});
|
|
24
|
-
const stepParameters = stepParameterNames.map(argName => {
|
|
25
|
-
const type = argName === 'dataTable' ? 'DataTable' : 'string';
|
|
26
|
-
return this.isTypescript ? `${argName}: ${type}` : argName;
|
|
27
|
-
});
|
|
28
|
-
const allParameterNames = ['{}', ...expressionParameters, ...stepParameters];
|
|
29
|
-
const functionSignature = `${functionName}('${this.escapeSpecialCharacters(generatedExpression)}', async (${allParameterNames.join(', ')}) => {`;
|
|
30
|
-
return [functionSignature,
|
|
31
|
-
// prettier-ignore
|
|
32
|
-
` // ...`, '});'].join('\n');
|
|
33
|
-
}
|
|
34
|
-
escapeSpecialCharacters(generatedExpression) {
|
|
35
|
-
let source = generatedExpression.source;
|
|
36
|
-
// double up any backslashes because we're in a javascript string
|
|
37
|
-
source = source.replace(/\\/g, '\\\\');
|
|
38
|
-
// escape any single quotes because that's our quote delimiter
|
|
39
|
-
source = source.replace(/'/g, "\\'");
|
|
40
|
-
return source;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.default = _default;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
class _default {
|
|
8
|
-
build({
|
|
9
|
-
generatedExpressions,
|
|
10
|
-
functionName
|
|
11
|
-
}) {
|
|
12
|
-
// Always take only first generatedExpression
|
|
13
|
-
// Other expressions are for int/float combinations
|
|
14
|
-
const generatedExpression = generatedExpressions[0];
|
|
15
|
-
return `@${functionName}('${this.escapeSpecialCharacters(generatedExpression)}')`;
|
|
16
|
-
}
|
|
17
|
-
escapeSpecialCharacters(generatedExpression) {
|
|
18
|
-
let source = generatedExpression.source;
|
|
19
|
-
// double up any backslashes because we're in a javascript string
|
|
20
|
-
source = source.replace(/\\/g, '\\\\');
|
|
21
|
-
// escape any single quotes because that's our quote delimiter
|
|
22
|
-
source = source.replace(/'/g, "\\'");
|
|
23
|
-
return source;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.default = _default;
|
|
@@ -1,18 +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.default = void 0;
|
|
8
|
-
var _snippetSyntax = _interopRequireDefault(require("./snippetSyntax"));
|
|
9
|
-
/**
|
|
10
|
-
* Playwright-style snippet syntax for typescript.
|
|
11
|
-
* Important to use separate file as it's simplest way to distinguish between js/ts
|
|
12
|
-
* without hooking into cucumber machinery.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
class _default extends _snippetSyntax.default {
|
|
16
|
-
isTypescript = true;
|
|
17
|
-
}
|
|
18
|
-
exports.default = _default;
|