@zohodesk/testinglibrary 0.1.8 → 0.1.9-exp-actors
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/.babelrc +3 -0
- package/build/bdd-framework/cli/commands/env.js +1 -1
- package/build/bdd-framework/config/configDir.js +35 -0
- package/build/bdd-framework/config/enrichReporterData.js +23 -0
- package/build/bdd-framework/config/index.js +10 -6
- package/build/bdd-framework/cucumber/createTestStep.js +43 -0
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +126 -0
- package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +72 -0
- package/build/bdd-framework/cucumber/formatter/PickleParser.js +25 -0
- package/build/bdd-framework/cucumber/formatter/durationHelpers.js +13 -0
- package/build/bdd-framework/cucumber/formatter/getColorFns.js +57 -0
- package/build/bdd-framework/cucumber/formatter/index.js +16 -0
- package/build/bdd-framework/cucumber/formatter/locationHelpers.js +16 -0
- package/build/bdd-framework/cucumber/loadFeatures.js +62 -31
- package/build/bdd-framework/cucumber/loadSteps.js +7 -0
- package/build/bdd-framework/cucumber/resolveFeaturePaths.js +62 -0
- package/build/bdd-framework/cucumber/stepArguments.js +21 -0
- package/build/bdd-framework/cucumber/valueChecker.js +23 -0
- package/build/bdd-framework/gen/formatter.js +11 -23
- package/build/bdd-framework/gen/index.js +41 -20
- package/build/bdd-framework/gen/testFile.js +69 -26
- package/build/bdd-framework/gen/testMeta.js +60 -0
- package/build/bdd-framework/gen/testNode.js +11 -12
- package/build/bdd-framework/hooks/scenario.js +29 -6
- package/build/bdd-framework/hooks/worker.js +7 -1
- package/build/bdd-framework/index.js +8 -1
- package/build/bdd-framework/playwright/getLocationInFile.js +36 -9
- package/build/bdd-framework/playwright/loadUtils.js +33 -0
- package/build/bdd-framework/playwright/transform.js +5 -1
- package/build/bdd-framework/reporter/cucumber/base.js +57 -0
- package/build/bdd-framework/reporter/cucumber/custom.js +73 -0
- package/build/bdd-framework/reporter/cucumber/helper.js +12 -0
- package/build/bdd-framework/reporter/cucumber/html.js +35 -0
- package/build/bdd-framework/reporter/cucumber/index.js +74 -0
- package/build/bdd-framework/reporter/cucumber/json.js +312 -0
- package/build/bdd-framework/reporter/cucumber/junit.js +205 -0
- package/build/bdd-framework/reporter/cucumber/message.js +20 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +64 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +196 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +43 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +52 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +105 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +70 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +45 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +27 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +38 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +128 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +126 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +102 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +50 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +88 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +30 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwUtils.js +51 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +35 -0
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +5 -0
- package/build/bdd-framework/run/StepInvoker.js +21 -26
- package/build/bdd-framework/run/bddDataAttachment.js +46 -0
- package/build/bdd-framework/run/bddFixtures.js +31 -10
- package/build/bdd-framework/run/bddWorld.js +5 -2
- package/build/bdd-framework/run/bddWorldInternal.js +15 -0
- package/build/bdd-framework/snippets/index.js +3 -7
- package/build/bdd-framework/stepDefinitions/defineStep.js +1 -1
- package/build/bdd-framework/utils/AutofillMap.js +20 -0
- package/build/bdd-framework/utils/index.js +23 -0
- package/build/bdd-framework/utils/stripAnsiEscapes.js +20 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +1 -0
- package/build/core/playwright/builtInFixtures/context.js +18 -1
- package/build/core/playwright/builtInFixtures/i18N.js +33 -0
- package/build/core/playwright/builtInFixtures/index.js +17 -1
- package/build/core/playwright/builtInFixtures/page.js +87 -39
- package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
- package/build/core/playwright/clear-caches.js +19 -8
- package/build/core/playwright/codegen.js +4 -4
- package/build/core/playwright/constants/browserTypes.js +12 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +10 -6
- package/build/core/playwright/helpers/auth/accountLogin.js +18 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +50 -0
- package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
- package/build/core/playwright/helpers/auth/getUsers.js +111 -0
- package/build/core/playwright/helpers/auth/index.js +70 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +36 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +24 -0
- package/build/core/playwright/helpers/getUserFixtures.js +23 -0
- package/build/core/playwright/helpers/mergeObjects.js +13 -0
- package/build/core/playwright/helpers/parseUserArgs.js +11 -0
- package/build/core/playwright/index.js +63 -1
- package/build/core/playwright/readConfigFile.js +23 -12
- package/build/core/playwright/report-generator.js +7 -7
- package/build/core/playwright/setup/config-creator.js +4 -1
- package/build/core/playwright/setup/config-utils.js +43 -7
- package/build/core/playwright/setup/custom-reporter.js +3 -2
- package/build/core/playwright/test-runner.js +20 -10
- package/build/core/playwright/types.js +43 -0
- package/build/index.d.ts +39 -2
- package/build/index.js +60 -11
- package/build/lib/cli.js +12 -3
- package/build/lib/post-install.js +18 -10
- package/build/setup-folder-structure/helper.js +3 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +20 -21
- package/build/utils/cliArgsToObject.js +5 -1
- package/build/utils/fileUtils.js +3 -0
- package/build/utils/rootPath.js +16 -9
- package/changelog.md +13 -0
- package/npm-shrinkwrap.json +18 -12
- package/package.json +6 -4
- package/build/bdd-framework/config/dir.js +0 -27
- package/build/bdd-framework/cucumber/loadSources.js +0 -57
- /package/build/bdd-framework/cucumber/{gherkin.d.js → types.js} +0 -0
|
@@ -10,64 +10,59 @@ var _testTypeImpl = require("../playwright/testTypeImpl");
|
|
|
10
10
|
var _defineStep = require("../stepDefinitions/defineStep");
|
|
11
11
|
var _lang = require("../config/lang");
|
|
12
12
|
/**
|
|
13
|
-
* Class to invoke
|
|
13
|
+
* Class to invoke step in playwright runner.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
class StepInvoker {
|
|
17
17
|
world;
|
|
18
18
|
keyword;
|
|
19
|
-
text = '';
|
|
20
|
-
argument;
|
|
21
19
|
constructor(world, keyword) {
|
|
22
20
|
this.world = world;
|
|
23
21
|
this.keyword = keyword;
|
|
24
22
|
this.invoke = this.invoke.bind(this);
|
|
25
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Invokes particular step.
|
|
26
|
+
* See: https://github.com/cucumber/cucumber-js/blob/main/src/runtime/test_case_runner.ts#L299
|
|
27
|
+
*/
|
|
26
28
|
async invoke(text, argument, stepFixtures) {
|
|
27
|
-
this.
|
|
28
|
-
|
|
29
|
-
const {
|
|
30
|
-
world
|
|
31
|
-
} = this;
|
|
32
|
-
world.stepFixtures = stepFixtures || {};
|
|
33
|
-
const stepDefinition = this.getStepDefinition();
|
|
29
|
+
this.world.$internal.currentStepFixtures = stepFixtures || {};
|
|
30
|
+
const stepDefinition = this.getStepDefinition(text);
|
|
34
31
|
// Get location of step call in generated test file.
|
|
35
32
|
// This call must be exactly here to have correct call stack (before async calls)
|
|
36
|
-
const location = (0, _getLocationInFile.getLocationInFile)(world.
|
|
37
|
-
const stepTitle = this.getStepTitle();
|
|
33
|
+
const location = (0, _getLocationInFile.getLocationInFile)(this.world.testInfo.file);
|
|
34
|
+
const stepTitle = this.getStepTitle(text);
|
|
38
35
|
const code = (0, _defineStep.getStepCode)(stepDefinition);
|
|
39
|
-
const parameters = await this.getStepParameters(stepDefinition);
|
|
40
|
-
|
|
36
|
+
const parameters = await this.getStepParameters(stepDefinition, text, argument || undefined);
|
|
37
|
+
this.world.$internal.bddData.registerStep(stepDefinition, text, location);
|
|
38
|
+
return (0, _testTypeImpl.runStepWithCustomLocation)(this.world.test, stepTitle, location, () => code.apply(this.world, parameters));
|
|
41
39
|
}
|
|
42
|
-
getStepDefinition() {
|
|
43
|
-
const stepDefinition = (0, _loadSteps.findStepDefinition)(this.world.options.supportCodeLibrary,
|
|
40
|
+
getStepDefinition(text) {
|
|
41
|
+
const stepDefinition = (0, _loadSteps.findStepDefinition)(this.world.options.supportCodeLibrary, text, this.world.testInfo.file);
|
|
44
42
|
if (!stepDefinition) {
|
|
45
|
-
throw new Error(`Undefined step: "${
|
|
43
|
+
throw new Error(`Undefined step: "${text}"`);
|
|
46
44
|
}
|
|
47
45
|
return stepDefinition;
|
|
48
46
|
}
|
|
49
|
-
async getStepParameters(stepDefinition) {
|
|
50
|
-
|
|
51
|
-
text,
|
|
52
|
-
argument,
|
|
53
|
-
world
|
|
54
|
-
} = this;
|
|
47
|
+
async getStepParameters(stepDefinition, text, argument) {
|
|
48
|
+
// see: https://github.com/cucumber/cucumber-js/blob/main/src/models/step_definition.ts#L25
|
|
55
49
|
const {
|
|
56
50
|
parameters
|
|
57
51
|
} = await stepDefinition.getInvocationParameters({
|
|
58
52
|
hookParameter: {},
|
|
53
|
+
// only text and argument are needed
|
|
59
54
|
step: {
|
|
60
55
|
text,
|
|
61
56
|
argument
|
|
62
57
|
},
|
|
63
|
-
world
|
|
58
|
+
world: this.world
|
|
64
59
|
});
|
|
65
60
|
return parameters;
|
|
66
61
|
}
|
|
67
|
-
getStepTitle() {
|
|
62
|
+
getStepTitle(text) {
|
|
68
63
|
// Currently prepend keyword only for English.
|
|
69
64
|
// For other langs it's more complex as we need to pass original keyword from step.
|
|
70
|
-
return (0, _lang.isEnglish)(this.world.options.lang) ? `${this.keyword} ${
|
|
65
|
+
return (0, _lang.isEnglish)(this.world.options.lang) ? `${this.keyword} ${text}` : text;
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
exports.StepInvoker = StepInvoker;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BddData = void 0;
|
|
7
|
+
exports.getBddDataFromTestResult = getBddDataFromTestResult;
|
|
8
|
+
exports.isBddDataAttachment = isBddDataAttachment;
|
|
9
|
+
var _createTestStep = require("../cucumber/createTestStep");
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
const BDD_DATA_ATTACHMENT_NAME = '__bddData';
|
|
12
|
+
class BddData {
|
|
13
|
+
world;
|
|
14
|
+
steps = [];
|
|
15
|
+
constructor(world) {
|
|
16
|
+
this.world = world;
|
|
17
|
+
}
|
|
18
|
+
registerStep(stepDefinition, stepText, pwStepLocation) {
|
|
19
|
+
const step = (0, _createTestStep.createTestStep)(stepDefinition, stepText);
|
|
20
|
+
this.steps.push({
|
|
21
|
+
pwStepLocation: (0, _utils.stringifyLocation)(pwStepLocation),
|
|
22
|
+
stepMatchArgumentsLists: step.stepMatchArgumentsLists || []
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async attach(testMeta, uri) {
|
|
26
|
+
const attachment = {
|
|
27
|
+
uri,
|
|
28
|
+
pickleLocation: testMeta.pickleLocation,
|
|
29
|
+
steps: this.steps
|
|
30
|
+
};
|
|
31
|
+
await this.world.testInfo.attach(BDD_DATA_ATTACHMENT_NAME, {
|
|
32
|
+
contentType: 'application/json',
|
|
33
|
+
body: JSON.stringify(attachment)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BddData = BddData;
|
|
38
|
+
function getBddDataFromTestResult(result) {
|
|
39
|
+
var _attachment$body;
|
|
40
|
+
const attachment = result.attachments.find(isBddDataAttachment);
|
|
41
|
+
const attachmentBody = attachment === null || attachment === void 0 || (_attachment$body = attachment.body) === null || _attachment$body === void 0 ? void 0 : _attachment$body.toString();
|
|
42
|
+
return attachmentBody ? JSON.parse(attachmentBody) : undefined;
|
|
43
|
+
}
|
|
44
|
+
function isBddDataAttachment(attachment) {
|
|
45
|
+
return attachment.name === BDD_DATA_ATTACHMENT_NAME;
|
|
46
|
+
}
|
|
@@ -12,10 +12,13 @@ var _bddWorld = require("./bddWorld");
|
|
|
12
12
|
var _config = require("../config");
|
|
13
13
|
var _env = require("../config/env");
|
|
14
14
|
var _steps = require("../stepDefinitions/decorators/steps");
|
|
15
|
-
var
|
|
15
|
+
var _configDir = require("../config/configDir");
|
|
16
16
|
var _scenario = require("../hooks/scenario");
|
|
17
17
|
var _worker = require("../hooks/worker");
|
|
18
18
|
var _StepInvoker = require("./StepInvoker");
|
|
19
|
+
var _testMeta = require("../gen/testMeta");
|
|
20
|
+
var _logger = require("../utils/logger");
|
|
21
|
+
var _enrichReporterData = require("../config/enrichReporterData");
|
|
19
22
|
const test = exports.test = _test.test.extend({
|
|
20
23
|
// load cucumber once per worker (auto-fixture)
|
|
21
24
|
// todo: maybe remove caching in cucumber/loadConfig.ts and cucumber/loadSteps.ts
|
|
@@ -23,7 +26,7 @@ const test = exports.test = _test.test.extend({
|
|
|
23
26
|
$cucumber: [async ({}, use, workerInfo) => {
|
|
24
27
|
const config = (0, _env.getConfigFromEnv)(workerInfo.project.testDir);
|
|
25
28
|
const environment = {
|
|
26
|
-
cwd: (0,
|
|
29
|
+
cwd: (0, _configDir.getPlaywrightConfigDir)()
|
|
27
30
|
};
|
|
28
31
|
const {
|
|
29
32
|
runConfiguration
|
|
@@ -36,12 +39,14 @@ const test = exports.test = _test.test.extend({
|
|
|
36
39
|
await use({
|
|
37
40
|
runConfiguration,
|
|
38
41
|
supportCodeLibrary,
|
|
39
|
-
World
|
|
42
|
+
World,
|
|
43
|
+
config
|
|
40
44
|
});
|
|
41
45
|
}, {
|
|
42
46
|
auto: true,
|
|
43
47
|
scope: 'worker'
|
|
44
48
|
}],
|
|
49
|
+
// $lang fixture can be overwritten in test file
|
|
45
50
|
$lang: ({}, use) => use(''),
|
|
46
51
|
// init $bddWorldFixtures with empty object, will be owerwritten in test file for cucumber-style
|
|
47
52
|
$bddWorldFixtures: ({}, use) => use({}),
|
|
@@ -50,12 +55,15 @@ const test = exports.test = _test.test.extend({
|
|
|
50
55
|
$test,
|
|
51
56
|
$bddWorldFixtures,
|
|
52
57
|
$cucumber,
|
|
53
|
-
$lang
|
|
58
|
+
$lang,
|
|
59
|
+
$testMeta,
|
|
60
|
+
$uri
|
|
54
61
|
}, use, testInfo) => {
|
|
55
62
|
const {
|
|
56
63
|
runConfiguration,
|
|
57
64
|
supportCodeLibrary,
|
|
58
|
-
World
|
|
65
|
+
World,
|
|
66
|
+
config
|
|
59
67
|
} = $cucumber;
|
|
60
68
|
const world = new World({
|
|
61
69
|
testInfo,
|
|
@@ -65,12 +73,15 @@ const test = exports.test = _test.test.extend({
|
|
|
65
73
|
$bddWorldFixtures,
|
|
66
74
|
lang: $lang,
|
|
67
75
|
parameters: runConfiguration.runtime.worldParameters || {},
|
|
68
|
-
log: () =>
|
|
69
|
-
attach: async () =>
|
|
76
|
+
log: () => _logger.logger.warn(`world.log() is noop, please use world.testInfo.attach()`),
|
|
77
|
+
attach: async () => _logger.logger.warn(`world.attach() is noop, please use world.testInfo.attach()`)
|
|
70
78
|
});
|
|
71
79
|
await world.init();
|
|
72
80
|
await use(world);
|
|
73
81
|
await world.destroy();
|
|
82
|
+
if ((0, _enrichReporterData.getEnrichReporterData)(config)) {
|
|
83
|
+
await world.$internal.bddData.attach($testMeta, $uri);
|
|
84
|
+
}
|
|
74
85
|
},
|
|
75
86
|
Given: ({
|
|
76
87
|
$bddWorld
|
|
@@ -87,10 +98,20 @@ const test = exports.test = _test.test.extend({
|
|
|
87
98
|
But: ({
|
|
88
99
|
$bddWorld
|
|
89
100
|
}, use) => use(new _StepInvoker.StepInvoker($bddWorld, 'But').invoke),
|
|
90
|
-
// init $
|
|
91
|
-
$
|
|
92
|
-
//
|
|
101
|
+
// init $testMetaMap with empty object, will be overwritten in each test file
|
|
102
|
+
$testMetaMap: ({}, use) => use({}),
|
|
103
|
+
// concrete test meta
|
|
104
|
+
$testMeta: ({
|
|
105
|
+
$testMetaMap
|
|
106
|
+
}, use, testInfo) => use((0, _testMeta.getTestMeta)($testMetaMap, testInfo)),
|
|
107
|
+
// concrete test tags
|
|
108
|
+
$tags: ({
|
|
109
|
+
$testMeta
|
|
110
|
+
}, use) => use($testMeta.tags || []),
|
|
111
|
+
// init $test with base test, but it will be overwritten in test file
|
|
93
112
|
$test: ({}, use) => use(_test.test),
|
|
113
|
+
// feature file uri, relative to configDir, will be overwritten in test file
|
|
114
|
+
$uri: ({}, use) => use(''),
|
|
94
115
|
// can be owerwritten in test file if there are scenario hooks
|
|
95
116
|
$scenarioHookFixtures: ({}, use) => use({}),
|
|
96
117
|
$before: [
|
|
@@ -6,12 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.BddWorld = void 0;
|
|
7
7
|
exports.getWorldConstructor = getWorldConstructor;
|
|
8
8
|
var _cucumber = require("@cucumber/cucumber");
|
|
9
|
+
var _bddWorldInternal = require("./bddWorldInternal");
|
|
9
10
|
class BddWorld extends _cucumber.World {
|
|
10
11
|
options;
|
|
11
|
-
|
|
12
|
+
// special property to hold internal bdd related methods, must be public.
|
|
13
|
+
$internal;
|
|
12
14
|
constructor(options) {
|
|
13
15
|
super(options);
|
|
14
16
|
this.options = options;
|
|
17
|
+
this.$internal = new _bddWorldInternal.BddWorldInternal(this);
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* Use particular fixture in cucumber-style steps.
|
|
@@ -30,7 +33,7 @@ class BddWorld extends _cucumber.World {
|
|
|
30
33
|
* See: https://github.com/Microsoft/TypeScript/pull/26349
|
|
31
34
|
*/
|
|
32
35
|
useFixture(fixtureName) {
|
|
33
|
-
return this.
|
|
36
|
+
return this.$internal.currentStepFixtures[fixtureName];
|
|
34
37
|
}
|
|
35
38
|
get page() {
|
|
36
39
|
return this.options.$bddWorldFixtures.page;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BddWorldInternal = void 0;
|
|
7
|
+
var _bddDataAttachment = require("./bddDataAttachment");
|
|
8
|
+
class BddWorldInternal {
|
|
9
|
+
currentStepFixtures = {};
|
|
10
|
+
bddData;
|
|
11
|
+
constructor(world) {
|
|
12
|
+
this.bddData = new _bddDataAttachment.BddData(world);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.BddWorldInternal = BddWorldInternal;
|
|
@@ -32,16 +32,12 @@ class Snippets {
|
|
|
32
32
|
// exit();
|
|
33
33
|
}
|
|
34
34
|
async createSnippetBuilder() {
|
|
35
|
-
const
|
|
36
|
-
snippetInterface
|
|
37
|
-
} = this.runConfiguration.formats.options;
|
|
35
|
+
const snippetInterface = this.runConfiguration.formats.options.snippetInterface;
|
|
38
36
|
const snippetSyntax = this.getSnippetSyntax();
|
|
39
37
|
return (0, _loadSnippetBuilder.loadSnippetBuilder)(this.supportCodeLibrary, snippetInterface, snippetSyntax);
|
|
40
38
|
}
|
|
41
39
|
getSnippetSyntax() {
|
|
42
|
-
const
|
|
43
|
-
snippetSyntax
|
|
44
|
-
} = this.runConfiguration.formats.options;
|
|
40
|
+
const snippetSyntax = this.runConfiguration.formats.options.snippetSyntax;
|
|
45
41
|
if (!snippetSyntax && this.isPlaywrightStyle()) {
|
|
46
42
|
this.bddBuiltInSyntax = true;
|
|
47
43
|
const filePath = this.isDecorators() ? require.resolve('./snippetSyntaxDecorators.js') : this.isTypeScript() ? require.resolve('./snippetSyntaxTs.js') : require.resolve('./snippetSyntax.js');
|
|
@@ -76,7 +72,7 @@ class Snippets {
|
|
|
76
72
|
line,
|
|
77
73
|
column
|
|
78
74
|
} = undefinedStep.step.location;
|
|
79
|
-
const snippetWithLocation = [`// ${index}. Missing step definition for "${file.
|
|
75
|
+
const snippetWithLocation = [`// ${index}. Missing step definition for "${file.featureUri}:${line}:${column}"`, snippet].join('\n');
|
|
80
76
|
return {
|
|
81
77
|
snippet,
|
|
82
78
|
snippetWithLocation
|
|
@@ -35,7 +35,7 @@ function defineStep(stepConfig) {
|
|
|
35
35
|
function buildCucumberStepCode(stepConfig) {
|
|
36
36
|
const code = function (...args) {
|
|
37
37
|
// build the first argument (fixtures) for step fn
|
|
38
|
-
const fixturesArg = Object.assign({}, this.
|
|
38
|
+
const fixturesArg = Object.assign({}, this.$internal.currentStepFixtures, {
|
|
39
39
|
$testInfo: this.testInfo,
|
|
40
40
|
$test: this.test,
|
|
41
41
|
$tags: this.tags
|
|
@@ -0,0 +1,20 @@
|
|
|
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;
|
|
@@ -8,9 +8,12 @@ exports.callWithTimeout = callWithTimeout;
|
|
|
8
8
|
exports.extractTemplateParams = extractTemplateParams;
|
|
9
9
|
exports.getPackageVersion = getPackageVersion;
|
|
10
10
|
exports.getSymbolByName = getSymbolByName;
|
|
11
|
+
exports.omit = omit;
|
|
11
12
|
exports.removeDuplicates = removeDuplicates;
|
|
12
13
|
exports.resolvePackageRoot = resolvePackageRoot;
|
|
14
|
+
exports.stringifyLocation = stringifyLocation;
|
|
13
15
|
exports.template = template;
|
|
16
|
+
exports.toPosixPath = toPosixPath;
|
|
14
17
|
var _fs = _interopRequireDefault(require("fs"));
|
|
15
18
|
var _path = _interopRequireDefault(require("path"));
|
|
16
19
|
var _util = require("util");
|
|
@@ -67,4 +70,24 @@ async function callWithTimeout(fn, timeout, timeoutMsg) {
|
|
|
67
70
|
}).then(() => {
|
|
68
71
|
throw new Error(timeoutMsg || `Function timeout (${timeout} ms)`);
|
|
69
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);
|
|
70
93
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -4,12 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _readConfigFile = require("../readConfigFile");
|
|
8
|
+
const {
|
|
9
|
+
testSetup
|
|
10
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
11
|
+
async function performDefaultContextSteps({
|
|
12
|
+
context
|
|
13
|
+
}) {
|
|
14
|
+
if (testSetup.context && typeof testSetup.context === 'function') {
|
|
15
|
+
await testSetup.context({
|
|
16
|
+
context
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
7
20
|
var _default = exports.default = {
|
|
8
21
|
context: async ({
|
|
9
22
|
context
|
|
10
23
|
}, use) => {
|
|
24
|
+
await context.addInitScript(() =>
|
|
11
25
|
// eslint-disable-next-line no-undef
|
|
12
|
-
|
|
26
|
+
window.localStorage.setItem('isDnBannerHide', true));
|
|
27
|
+
await performDefaultContextSteps({
|
|
28
|
+
context
|
|
29
|
+
});
|
|
13
30
|
await use(context);
|
|
14
31
|
}
|
|
15
32
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/* eslint-disable no-undef */
|
|
8
|
+
/* eslint-disable no-param-reassign */
|
|
9
|
+
|
|
10
|
+
// Note: We are duplicating below method from @zohodesk/i18n. We are not importing it as react package not yet availble in test environment.
|
|
11
|
+
function replaceI18NValuesWithRegex(i18nStr, values) {
|
|
12
|
+
if (typeof values !== 'undefined') {
|
|
13
|
+
if (Array.isArray(values)) {
|
|
14
|
+
for (let i = 0; i < values.length; i++) {
|
|
15
|
+
i18nStr = i18nStr.replace(new RegExp(`\\{${i}\\}`, 'g'), values[i]);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
i18nStr = i18nStr.replace(new RegExp('\\{0\\}', 'g'), values);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return i18nStr;
|
|
22
|
+
}
|
|
23
|
+
var _default = exports.default = {
|
|
24
|
+
i18N: async ({
|
|
25
|
+
page
|
|
26
|
+
}, use) => {
|
|
27
|
+
await use(async (key, values) => {
|
|
28
|
+
const i18nValue = await page.evaluate(i18nKey => window.i18n[i18nKey], key);
|
|
29
|
+
const i18nStr = replaceI18NValuesWithRegex(i18nValue, values);
|
|
30
|
+
return i18nStr;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -9,17 +9,33 @@ var _page = _interopRequireDefault(require("./page"));
|
|
|
9
9
|
var _context = _interopRequireDefault(require("./context"));
|
|
10
10
|
var _cacheLayer = _interopRequireDefault(require("./cacheLayer"));
|
|
11
11
|
var _addTags = _interopRequireDefault(require("./addTags"));
|
|
12
|
+
var _i18N = _interopRequireDefault(require("./i18N"));
|
|
13
|
+
var _unauthenticatedPage = _interopRequireDefault(require("./unauthenticatedPage"));
|
|
14
|
+
function extractTagsFromTitle(text) {
|
|
15
|
+
return text.match(/@\w+/g) || [];
|
|
16
|
+
}
|
|
12
17
|
function getBuiltInFixtures(bddMode) {
|
|
13
18
|
let builtInFixtures = {
|
|
14
19
|
..._page.default,
|
|
15
20
|
..._context.default,
|
|
16
|
-
..._cacheLayer.default
|
|
21
|
+
..._cacheLayer.default,
|
|
22
|
+
..._i18N.default,
|
|
23
|
+
..._unauthenticatedPage.default
|
|
17
24
|
};
|
|
18
25
|
if (bddMode) {
|
|
19
26
|
builtInFixtures = {
|
|
20
27
|
...builtInFixtures,
|
|
21
28
|
..._addTags.default
|
|
22
29
|
};
|
|
30
|
+
} else {
|
|
31
|
+
builtInFixtures = {
|
|
32
|
+
...builtInFixtures,
|
|
33
|
+
$tags: async ({}, use, testInfo) => {
|
|
34
|
+
// Extract only the elements after the "@" symbol as tags
|
|
35
|
+
const tags = testInfo.title ? extractTagsFromTitle(testInfo.title) : [];
|
|
36
|
+
await use(tags);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
23
39
|
}
|
|
24
40
|
return builtInFixtures;
|
|
25
41
|
}
|
|
@@ -4,48 +4,96 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
7
|
+
var _auth = require("../helpers/auth");
|
|
8
|
+
var _readConfigFile = require("../readConfigFile");
|
|
9
|
+
/* eslint-disable global-require */
|
|
10
|
+
|
|
11
|
+
function getTagInputFromSelectedTags(tags, inputString) {
|
|
12
|
+
const selectedTag = tags.find(tag => tag.startsWith(inputString));
|
|
13
|
+
let tagInput = null;
|
|
14
|
+
if (selectedTag) {
|
|
15
|
+
tagInput = selectedTag.split(`${inputString}_`).pop().toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
return tagInput;
|
|
18
|
+
}
|
|
19
|
+
function getCustomAccountDetails(tags) {
|
|
20
|
+
const tagsTobeFiltered = ['@profile', '@edition', '@beta', '@portal'];
|
|
21
|
+
const filteredTags = tags.filter(tag => tagsTobeFiltered.some(prefix => tag.startsWith(prefix)));
|
|
22
|
+
if (filteredTags && filteredTags.length > 0) {
|
|
23
|
+
const portalInfo = getTagInputFromSelectedTags(filteredTags, '@portal');
|
|
24
|
+
const betaFeature = getTagInputFromSelectedTags(filteredTags, '@beta');
|
|
25
|
+
const profileInfo = getTagInputFromSelectedTags(filteredTags, '@profile');
|
|
26
|
+
const editionInfo = getTagInputFromSelectedTags(filteredTags, '@edition');
|
|
27
|
+
const user = (0, _auth.getUserForSelectedEditionAndProfile)(editionInfo, profileInfo, betaFeature, portalInfo);
|
|
28
|
+
return user;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const {
|
|
33
|
+
testSetup
|
|
34
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
35
|
+
async function performDefaultPageSteps({
|
|
36
|
+
context,
|
|
37
|
+
$tags,
|
|
38
|
+
page
|
|
39
|
+
}) {
|
|
40
|
+
if (testSetup.page && typeof testSetup.page === 'function') {
|
|
41
|
+
await testSetup.page({
|
|
42
|
+
context,
|
|
43
|
+
$tags,
|
|
44
|
+
page
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
await page.goto(process.env.domain);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
33
50
|
var _default = exports.default = {
|
|
34
51
|
page: async ({
|
|
52
|
+
context,
|
|
53
|
+
$tags,
|
|
35
54
|
page
|
|
36
55
|
}, use) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
const testPortalDetails = getCustomAccountDetails($tags);
|
|
57
|
+
if (testPortalDetails === null) {
|
|
58
|
+
await performDefaultPageSteps({
|
|
59
|
+
context,
|
|
60
|
+
$tags,
|
|
61
|
+
page
|
|
62
|
+
});
|
|
63
|
+
const {
|
|
64
|
+
edition,
|
|
65
|
+
profile
|
|
66
|
+
} = (0, _auth.getDefaultActor)();
|
|
67
|
+
const user = (0, _auth.getUserForSelectedEditionAndProfile)(edition, profile);
|
|
68
|
+
const {
|
|
69
|
+
password,
|
|
70
|
+
...actorInfo
|
|
71
|
+
} = user;
|
|
72
|
+
process.env.actorInfo = JSON.stringify(actorInfo);
|
|
73
|
+
await use(page);
|
|
74
|
+
} else {
|
|
75
|
+
await context.clearCookies();
|
|
76
|
+
const {
|
|
77
|
+
email
|
|
78
|
+
} = testPortalDetails;
|
|
79
|
+
const {
|
|
80
|
+
password,
|
|
81
|
+
...actorInfo
|
|
82
|
+
} = testPortalDetails;
|
|
83
|
+
await (0, _auth.performLoginSteps)({
|
|
84
|
+
page,
|
|
85
|
+
authFilePrefix: email,
|
|
86
|
+
useremail: email,
|
|
87
|
+
password: password
|
|
88
|
+
}, async () => page.url().includes(process.env.domain));
|
|
89
|
+
process.env.actorInfo = JSON.stringify(actorInfo);
|
|
90
|
+
await performDefaultPageSteps({
|
|
91
|
+
context,
|
|
92
|
+
$tags,
|
|
93
|
+
page
|
|
94
|
+
});
|
|
95
|
+
await use(page);
|
|
96
|
+
await context.close();
|
|
97
|
+
}
|
|
50
98
|
}
|
|
51
99
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
unauthenticatedPage: async ({
|
|
9
|
+
browser
|
|
10
|
+
}, use) => {
|
|
11
|
+
const context = await browser.newContext({
|
|
12
|
+
storageState: null
|
|
13
|
+
});
|
|
14
|
+
const unauthenticatedPage = await context.newPage();
|
|
15
|
+
await use(unauthenticatedPage);
|
|
16
|
+
await context.close();
|
|
17
|
+
}
|
|
18
|
+
};
|