@zohodesk/testinglibrary 0.1.8-exp-bdd-v3 → 0.1.8-exp-bdd-v4
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/.eslintrc.js +5 -1
- package/build/bdd-framework/cli/commands/env.js +42 -0
- package/build/bdd-framework/cli/commands/export.js +47 -0
- package/build/bdd-framework/cli/commands/test.js +64 -0
- package/build/bdd-framework/cli/index.js +11 -0
- package/build/bdd-framework/cli/options.js +19 -0
- package/build/bdd-framework/cli/worker.js +13 -0
- package/build/bdd-framework/config/dir.js +27 -0
- package/build/bdd-framework/config/env.js +50 -0
- package/build/bdd-framework/config/index.js +90 -0
- package/build/bdd-framework/config/lang.js +14 -0
- package/build/bdd-framework/cucumber/buildStepDefinition.js +43 -0
- package/build/bdd-framework/cucumber/gherkin.d.js +5 -0
- package/build/bdd-framework/cucumber/loadConfig.js +17 -0
- package/build/bdd-framework/cucumber/loadFeatures.js +39 -0
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +20 -0
- package/build/bdd-framework/cucumber/loadSources.js +57 -0
- package/build/bdd-framework/cucumber/loadSteps.js +40 -0
- package/build/bdd-framework/decorators.js +18 -0
- package/build/bdd-framework/gen/fixtures.js +48 -0
- package/build/bdd-framework/gen/formatter.js +135 -0
- package/build/bdd-framework/gen/i18n.js +39 -0
- package/build/bdd-framework/gen/index.js +164 -0
- package/build/bdd-framework/gen/testFile.js +422 -0
- package/build/bdd-framework/gen/testNode.js +61 -0
- package/build/bdd-framework/gen/testPoms.js +133 -0
- package/build/bdd-framework/hooks/scenario.js +107 -0
- package/build/bdd-framework/hooks/worker.js +83 -0
- package/build/bdd-framework/index.js +45 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +93 -0
- package/build/bdd-framework/playwright/getLocationInFile.js +52 -0
- package/build/bdd-framework/playwright/loadConfig.js +42 -0
- package/build/bdd-framework/playwright/testTypeImpl.js +61 -0
- package/build/bdd-framework/playwright/transform.js +84 -0
- package/build/bdd-framework/playwright/types.js +5 -0
- package/build/bdd-framework/playwright/utils.js +34 -0
- package/build/bdd-framework/run/StepInvoker.js +73 -0
- package/build/bdd-framework/run/bddFixtures.js +170 -0
- package/build/bdd-framework/run/bddWorld.js +76 -0
- package/build/bdd-framework/snippets/index.js +136 -0
- package/build/bdd-framework/snippets/snippetSyntax.js +43 -0
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +26 -0
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +18 -0
- package/build/bdd-framework/stepDefinitions/createBdd.js +66 -0
- package/build/bdd-framework/stepDefinitions/decorators/class.js +68 -0
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +99 -0
- package/build/bdd-framework/stepDefinitions/defineStep.js +62 -0
- package/build/bdd-framework/stepDefinitions/stepConfig.js +24 -0
- package/build/bdd-framework/utils/exit.js +58 -0
- package/build/bdd-framework/utils/index.js +70 -0
- package/build/bdd-framework/utils/jsStringWrap.js +44 -0
- package/build/bdd-framework/utils/logger.js +30 -0
- package/build/bdd-poc/core-runner/main.js +10 -0
- package/build/bdd-poc/core-runner/stepDefinitions.js +0 -1
- package/build/bdd-poc/index.js +26 -0
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +6 -6
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +1 -2
- package/build/bdd-poc/test/testDataMap.js +5 -5
- package/build/core/jest/preprocessor/jsPreprocessor.js +2 -3
- package/build/core/playwright/builtInFixtures/addTags.js +19 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +13 -0
- package/build/core/playwright/builtInFixtures/context.js +15 -0
- package/build/core/playwright/builtInFixtures/index.js +26 -0
- package/build/core/playwright/builtInFixtures/page.js +51 -0
- package/build/core/playwright/clear-caches.js +29 -0
- package/build/core/playwright/custom-commands.js +1 -2
- package/build/core/playwright/index.js +10 -79
- package/build/core/playwright/readConfigFile.js +12 -6
- package/build/core/playwright/report-generator.js +2 -1
- package/build/core/playwright/setup/config-creator.js +23 -17
- package/build/core/playwright/setup/config-utils.js +32 -1
- package/build/core/playwright/setup/custom-reporter.js +109 -0
- package/build/core/playwright/tag-processor.js +68 -0
- package/build/core/playwright/test-runner.js +10 -10
- package/build/index.d.ts +59 -4
- package/build/index.js +10 -9
- package/build/lib/cli.js +10 -1
- package/build/parser/parser.js +0 -1
- package/build/setup-folder-structure/helper.js +34 -0
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +8 -4
- package/build/setup-folder-structure/samples/uat-config-sample.js +3 -2
- package/build/setup-folder-structure/setupProject.js +10 -5
- package/build/utils/fileUtils.js +15 -4
- package/build/utils/logger.js +1 -2
- package/build/utils/stepDefinitionsFormatter.js +1 -2
- package/changelog.md +57 -0
- package/npm-shrinkwrap.json +1426 -2172
- package/package.json +5 -4
- package/build/bdd-poc/main.js +0 -10
- /package/build/bdd-poc/{runner.js → core-runner/runner.js} +0 -0
|
@@ -4,5 +4,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CUSTOM_COMMANDS = void 0;
|
|
7
|
-
const CUSTOM_COMMANDS = ['mode', 'tags'];
|
|
8
|
-
exports.CUSTOM_COMMANDS = CUSTOM_COMMANDS;
|
|
7
|
+
const CUSTOM_COMMANDS = exports.CUSTOM_COMMANDS = ['mode', 'tags', 'edition'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -12,89 +13,19 @@ Object.defineProperty(exports, "expect", {
|
|
|
12
13
|
exports.test = void 0;
|
|
13
14
|
var _test = require("@playwright/test");
|
|
14
15
|
var _readConfigFile = require("./readConfigFile");
|
|
16
|
+
var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
|
|
15
17
|
// import { createBdd, test as bddBase } from '../../bdd-framework';
|
|
16
18
|
|
|
17
|
-
// function test(descrition, callback) {
|
|
18
|
-
// return test(descrition, ({ page }) => {
|
|
19
|
-
// const { locator, ...custompage } = page
|
|
20
|
-
// callback({ page: custompage })
|
|
21
|
-
// })
|
|
22
|
-
// }
|
|
23
|
-
|
|
24
|
-
// class FilteredPage {
|
|
25
|
-
// constructor(page) {
|
|
26
|
-
// this.page = page;
|
|
27
|
-
// this.allowedMethods = ['getByText', 'getByTitle'];
|
|
28
|
-
// this.context = page.context;
|
|
29
|
-
// }
|
|
30
|
-
|
|
31
|
-
// goto(...args) {
|
|
32
|
-
// return this.page['goto'](...args);
|
|
33
|
-
// }
|
|
34
|
-
|
|
35
|
-
// getByRole(...args) {
|
|
36
|
-
// return this.page['getByRole'](...args);
|
|
37
|
-
// }
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
|
-
// function FilteredPage(page) {
|
|
41
|
-
// return {
|
|
42
|
-
// getByRole: () => {
|
|
43
|
-
// throw new Error('You cannnot use getByRole property')
|
|
44
|
-
// }
|
|
45
|
-
// }
|
|
46
|
-
// }
|
|
47
19
|
const {
|
|
48
|
-
additionalPages,
|
|
20
|
+
additionalPages: userFixtures,
|
|
49
21
|
bddMode
|
|
50
22
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// get: function (obj, prop) {
|
|
58
|
-
// console.log('Gettig Priop', prop);
|
|
59
|
-
// let filterMethod = FilteredPage(page)[prop];
|
|
60
|
-
// if (filterMethod) {
|
|
61
|
-
// return filterMethod;
|
|
62
|
-
// } else {
|
|
63
|
-
// return obj[prop] ? obj[prop] : 'property does not exist';
|
|
64
|
-
// }
|
|
65
|
-
// }
|
|
66
|
-
// })
|
|
67
|
-
page.getBaseUrl = function () {
|
|
68
|
-
if (process.env.mode === 'dev') {
|
|
69
|
-
return `${process.env.domain}?devURL=${process.env.devUrl}`;
|
|
70
|
-
}
|
|
71
|
-
return `${process.env.domain}`;
|
|
72
|
-
};
|
|
73
|
-
page.getCustomPageUrl = function (url) {
|
|
74
|
-
if (process.env.mode === 'dev') {
|
|
75
|
-
return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`;
|
|
76
|
-
}
|
|
77
|
-
return `${process.env.domain}/${url}`;
|
|
78
|
-
};
|
|
79
|
-
await use(page);
|
|
80
|
-
|
|
81
|
-
//await use(new FilteredPage(page));
|
|
82
|
-
|
|
83
|
-
// await use(async (page) => {
|
|
84
|
-
// delete page.getByTestId;
|
|
85
|
-
// await page;
|
|
86
|
-
// });
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
context: async ({
|
|
90
|
-
context
|
|
91
|
-
}, use) => {
|
|
92
|
-
// eslint-disable-next-line no-undef
|
|
93
|
-
await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
|
|
94
|
-
await use(context);
|
|
95
|
-
},
|
|
96
|
-
...additionalPages
|
|
23
|
+
// In house BDD testing. so, use playwright test
|
|
24
|
+
let base = _test.test;
|
|
25
|
+
const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
|
|
26
|
+
const test = exports.test = base.extend({
|
|
27
|
+
...buildInFixtures,
|
|
28
|
+
...userFixtures
|
|
97
29
|
});
|
|
98
30
|
|
|
99
|
-
// const { Given, When, Then } = createBdd();
|
|
100
|
-
exports.test = test;
|
|
31
|
+
// const { Given, When, Then } = createBdd();
|
|
@@ -11,10 +11,10 @@ exports.isUserConfigFileAvailable = isUserConfigFileAvailable;
|
|
|
11
11
|
var _fs = require("fs");
|
|
12
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
13
|
var _logger = require("../../utils/logger");
|
|
14
|
-
const fileName = 'uat.config.js';
|
|
15
|
-
exports.fileName = fileName;
|
|
14
|
+
const fileName = exports.fileName = 'uat.config.js';
|
|
16
15
|
function getDefaultConfig() {
|
|
17
16
|
return {
|
|
17
|
+
headless: false,
|
|
18
18
|
browsers: ['Chrome'],
|
|
19
19
|
trace: false,
|
|
20
20
|
video: false,
|
|
@@ -31,7 +31,11 @@ function getDefaultConfig() {
|
|
|
31
31
|
},
|
|
32
32
|
debug: false,
|
|
33
33
|
mode: 'dev',
|
|
34
|
-
additionalPages: {}
|
|
34
|
+
additionalPages: {},
|
|
35
|
+
featureFilesFolder: 'feature-files',
|
|
36
|
+
stepDefinitionsFolder: 'steps',
|
|
37
|
+
testIdAttribute: 'data-testid',
|
|
38
|
+
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
@@ -39,7 +43,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
39
43
|
let configurationObj = {};
|
|
40
44
|
Object.keys(userConfiguration).forEach(configKey => {
|
|
41
45
|
let configValue = userConfiguration[configKey];
|
|
42
|
-
if (configValue && configValue !==
|
|
46
|
+
if (configValue !== null && configValue !== undefined) {
|
|
43
47
|
configurationObj[configKey] = configValue;
|
|
44
48
|
} else if (defaultConfig[configKey]) {
|
|
45
49
|
configurationObj[configKey] = defaultConfig[configKey];
|
|
@@ -67,7 +71,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
67
71
|
* @property {boolean} video - video for test cases,
|
|
68
72
|
* @property {boolean} debug - debug mode
|
|
69
73
|
* @property {string} mode: mode in which the test cases needs to run
|
|
70
|
-
* @property {boolean} isAuthMode - Auth Mode
|
|
74
|
+
* @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
|
|
71
75
|
* @property {string} authFilePath - File Path where the cookies stored
|
|
72
76
|
* @property {any} browsers: List of browsers
|
|
73
77
|
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
@@ -78,7 +82,9 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
78
82
|
* @property {Object} additionalPages: custom pages configuration
|
|
79
83
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
80
84
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
81
|
-
* @property {viewportConfig} viewport: viewport configuration
|
|
85
|
+
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
86
|
+
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
87
|
+
* @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
|
|
82
88
|
*/
|
|
83
89
|
|
|
84
90
|
/**
|
|
@@ -17,7 +17,8 @@ const {
|
|
|
17
17
|
reportPath: htmlPath
|
|
18
18
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
19
19
|
const args = ['show-report', htmlPath].concat(userArgs);
|
|
20
|
-
function generateReport() {
|
|
20
|
+
async function generateReport() {
|
|
21
|
+
// await preProcessReport()
|
|
21
22
|
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
22
23
|
stdio: 'inherit'
|
|
23
24
|
});
|
|
@@ -10,7 +10,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
10
10
|
var _readConfigFile = require("../readConfigFile");
|
|
11
11
|
var _configUtils = require("./config-utils");
|
|
12
12
|
var _testDataMap = require("../../../bdd-poc/test/testDataMap");
|
|
13
|
-
var
|
|
13
|
+
var _index = require("../../../bdd-poc/index");
|
|
14
14
|
const {
|
|
15
15
|
browsers,
|
|
16
16
|
trace,
|
|
@@ -23,8 +23,7 @@ const {
|
|
|
23
23
|
testTimeout,
|
|
24
24
|
authFilePath,
|
|
25
25
|
viewport,
|
|
26
|
-
|
|
27
|
-
stepDefinitionsFolder
|
|
26
|
+
testIdAttribute
|
|
28
27
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
29
28
|
const projects = (0, _configUtils.getProjects)({
|
|
30
29
|
browsers,
|
|
@@ -36,9 +35,21 @@ const projects = (0, _configUtils.getProjects)({
|
|
|
36
35
|
});
|
|
37
36
|
// const testDir = getTestDir(bddMode, process.cwd(), { featureFilesFolder, stepDefinitionsFolder });
|
|
38
37
|
const testDir = _path.default.resolve(process.cwd(), 'uat', 'feature-gen');
|
|
38
|
+
const testOptions = (0, _configUtils.getTestUseOptions)({
|
|
39
|
+
trace,
|
|
40
|
+
video,
|
|
41
|
+
viewport,
|
|
42
|
+
testIdAttribute
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Playwright configuration object
|
|
47
|
+
*
|
|
48
|
+
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
49
|
+
*/
|
|
39
50
|
function getPlaywrightConfig() {
|
|
40
51
|
globalThis.globalStepMap = new Map();
|
|
41
|
-
(0,
|
|
52
|
+
(0, _index.stepFileMap)();
|
|
42
53
|
(0, _testDataMap.testDataCreation)().then(inputs => {
|
|
43
54
|
globalThis.globalTestdata = inputs;
|
|
44
55
|
});
|
|
@@ -52,27 +63,22 @@ function getPlaywrightConfig() {
|
|
|
52
63
|
reporter: [['html', {
|
|
53
64
|
outputFolder: reportPath,
|
|
54
65
|
open: openReportOn
|
|
55
|
-
}]],
|
|
66
|
+
}], ['list'], ['./custom-reporter.js']],
|
|
56
67
|
timeout: testTimeout,
|
|
57
68
|
expect: {
|
|
58
69
|
timeout: expectTimeout
|
|
59
70
|
},
|
|
60
|
-
use:
|
|
61
|
-
viewport,
|
|
62
|
-
trace: trace ? 'on' : 'off',
|
|
63
|
-
video: video ? {
|
|
64
|
-
mode: 'on',
|
|
65
|
-
size: {
|
|
66
|
-
...viewport
|
|
67
|
-
}
|
|
68
|
-
} : 'off'
|
|
69
|
-
},
|
|
71
|
+
use: testOptions,
|
|
70
72
|
projects: isAuthMode ? [{
|
|
71
73
|
name: 'setup',
|
|
72
74
|
testMatch: /.*\.setup\.js/,
|
|
75
|
+
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
76
|
+
teardown: 'cleanup'
|
|
77
|
+
}, {
|
|
78
|
+
name: 'cleanup',
|
|
79
|
+
testMatch: /.*\.teardown\.js/,
|
|
73
80
|
testDir: _path.default.join(process.cwd(), 'uat')
|
|
74
81
|
}, ...projects] : [...projects]
|
|
75
82
|
};
|
|
76
83
|
}
|
|
77
|
-
var _default = (0, _test.defineConfig)(getPlaywrightConfig());
|
|
78
|
-
exports.default = _default;
|
|
84
|
+
var _default = exports.default = (0, _test.defineConfig)(getPlaywrightConfig());
|
|
@@ -5,11 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getProjects = getProjects;
|
|
8
|
+
exports.getTestUseOptions = getTestUseOptions;
|
|
8
9
|
var _test = require("@playwright/test");
|
|
9
10
|
var _path = _interopRequireDefault(require("path"));
|
|
10
11
|
var _readConfigFile = require("../readConfigFile");
|
|
11
12
|
// import { defineBddConfig } from '../../../bdd-framework';
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
** Playwright project configuration
|
|
16
|
+
* @returns {import('@playwright/test').Project}
|
|
17
|
+
*/
|
|
13
18
|
function getBrowserConfig({
|
|
14
19
|
browserName,
|
|
15
20
|
isAuthMode,
|
|
@@ -81,6 +86,12 @@ function getBrowserConfig({
|
|
|
81
86
|
return false;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param {*} param0
|
|
93
|
+
* @returns {import('@playwright/test').Project[]}
|
|
94
|
+
*/
|
|
84
95
|
function getProjects({
|
|
85
96
|
browsers,
|
|
86
97
|
isAuthMode,
|
|
@@ -109,4 +120,24 @@ function getProjects({
|
|
|
109
120
|
// publish: true,
|
|
110
121
|
// })
|
|
111
122
|
// : path.join(cwd, 'uat');
|
|
112
|
-
// }
|
|
123
|
+
// }
|
|
124
|
+
|
|
125
|
+
function getTestUseOptions({
|
|
126
|
+
viewport,
|
|
127
|
+
trace,
|
|
128
|
+
video,
|
|
129
|
+
testIdAttribute
|
|
130
|
+
}) {
|
|
131
|
+
let defaultTestuseOptions = {
|
|
132
|
+
viewport,
|
|
133
|
+
testIdAttribute,
|
|
134
|
+
trace: trace ? 'on' : 'off',
|
|
135
|
+
video: video ? {
|
|
136
|
+
mode: 'on',
|
|
137
|
+
size: {
|
|
138
|
+
...viewport
|
|
139
|
+
}
|
|
140
|
+
} : 'off'
|
|
141
|
+
};
|
|
142
|
+
return defaultTestuseOptions;
|
|
143
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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 _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _readline = _interopRequireDefault(require("readline"));
|
|
10
|
+
var _fileUtils = require("../../../utils/fileUtils");
|
|
11
|
+
var _readConfigFile = require("../readConfigFile");
|
|
12
|
+
var _logger = require("../../../utils/logger");
|
|
13
|
+
class JSONSummaryReporter {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.durationInMS = -1;
|
|
16
|
+
this.passed = [];
|
|
17
|
+
this.skipped = [];
|
|
18
|
+
this.failed = [];
|
|
19
|
+
this.warned = [];
|
|
20
|
+
this.interrupted = [];
|
|
21
|
+
this.timedOut = [];
|
|
22
|
+
this.flakey = [];
|
|
23
|
+
this.failedSteps = [];
|
|
24
|
+
this.status = 'unknown';
|
|
25
|
+
this.startedAt = 0;
|
|
26
|
+
this._open = (0, _readConfigFile.generateConfigFromFile)().openReportOn;
|
|
27
|
+
}
|
|
28
|
+
onBegin() {
|
|
29
|
+
this.startedAt = Date.now();
|
|
30
|
+
}
|
|
31
|
+
onTestEnd(test, result) {
|
|
32
|
+
const title = [];
|
|
33
|
+
const fileName = [];
|
|
34
|
+
let clean = true;
|
|
35
|
+
for (const s of test.titlePath()) {
|
|
36
|
+
if (s === '' && clean) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
clean = false;
|
|
40
|
+
title.push(s);
|
|
41
|
+
if (s.includes('.ts') || s.includes('.js')) {
|
|
42
|
+
fileName.push(s);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// This will publish the file name + line number test begins on
|
|
46
|
+
const z = `${fileName[0]}:${test.location.line}:${test.location.column}`;
|
|
47
|
+
// Using the t variable in the push will push a full test name + test description
|
|
48
|
+
const t = title.join(' > ');
|
|
49
|
+
// Set the status
|
|
50
|
+
const stepTitleList = result.steps.map(step => ({
|
|
51
|
+
title: step.title,
|
|
52
|
+
error: step.error,
|
|
53
|
+
testTitle: t
|
|
54
|
+
})).filter(step => step.error !== undefined);
|
|
55
|
+
if (stepTitleList.length > 0) {
|
|
56
|
+
this.failedSteps = [...this.failedSteps, ...stepTitleList];
|
|
57
|
+
}
|
|
58
|
+
const status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn') ? 'warned' : result.status;
|
|
59
|
+
// Logic to push the results into the correct array
|
|
60
|
+
if (result.status === 'passed' && result.retry >= 1) {
|
|
61
|
+
this.flakey.push(z);
|
|
62
|
+
} else {
|
|
63
|
+
this[status].push(z);
|
|
64
|
+
}
|
|
65
|
+
this[status].push(z);
|
|
66
|
+
}
|
|
67
|
+
onEnd(result) {
|
|
68
|
+
this.durationInMS = Date.now() - this.startedAt;
|
|
69
|
+
this.status = result.status;
|
|
70
|
+
// removing duplicate tests from passed array
|
|
71
|
+
this.passed = this.passed.filter((element, index) => {
|
|
72
|
+
return this.passed.indexOf(element) === index;
|
|
73
|
+
});
|
|
74
|
+
// removing duplicate tests from the failed array
|
|
75
|
+
this.failed = this.failed.filter((element, index) => {
|
|
76
|
+
if (!this.passed.includes(element)) {
|
|
77
|
+
return this.failed.indexOf(element) === index;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
// removing duplicate tests from the skipped array
|
|
81
|
+
this.skipped = this.skipped.filter((element, index) => {
|
|
82
|
+
return this.skipped.indexOf(element) === index;
|
|
83
|
+
});
|
|
84
|
+
// removing duplicate tests from the timedOut array
|
|
85
|
+
this.timedOut = this.timedOut.filter((element, index) => {
|
|
86
|
+
return this.timedOut.indexOf(element) === index;
|
|
87
|
+
});
|
|
88
|
+
// removing duplicate tests from the interrupted array
|
|
89
|
+
this.interrupted = this.interrupted.filter((element, index) => {
|
|
90
|
+
return this.interrupted.indexOf(element) === index;
|
|
91
|
+
});
|
|
92
|
+
// fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));
|
|
93
|
+
let {
|
|
94
|
+
reportPath
|
|
95
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
96
|
+
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', 'test-summary.json'), JSON.stringify(this, null, ' '));
|
|
97
|
+
}
|
|
98
|
+
onExit() {
|
|
99
|
+
const shouldClearLastLine = this._open !== 'always' || this._open !== 'on-failure';
|
|
100
|
+
if (shouldClearLastLine) {
|
|
101
|
+
/**Below code is to replace the playwright default report commond with abstraction tool command */
|
|
102
|
+
_readline.default.moveCursor(process.stdout, 0, -2); // up two line
|
|
103
|
+
_readline.default.clearLine(process.stdout, 1); // from cursor to end
|
|
104
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'npx ZDTestingFramework report or npm run uat-report');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
var _default = exports.default = JSONSummaryReporter;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tagProcessor = tagProcessor;
|
|
7
|
+
var _logger = require("../../utils/logger");
|
|
8
|
+
/* eslint-disable dot-notation */
|
|
9
|
+
|
|
10
|
+
function getTagsString(tags, editionTags) {
|
|
11
|
+
return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
12
|
+
}
|
|
13
|
+
function getEdition(edition) {
|
|
14
|
+
if (edition.startsWith('<=')) {
|
|
15
|
+
return ['<=', edition.slice(2)];
|
|
16
|
+
} else if (edition.startsWith('>=')) {
|
|
17
|
+
return ['>=', edition.slice(2)];
|
|
18
|
+
} else if (edition.startsWith('<')) {
|
|
19
|
+
return ['<', edition.slice(1)];
|
|
20
|
+
} else if (edition.startsWith('>')) {
|
|
21
|
+
return ['>', edition.slice(1)];
|
|
22
|
+
}
|
|
23
|
+
return [null, edition];
|
|
24
|
+
}
|
|
25
|
+
function editionPreprocessing(editionOrder, selectedEdition) {
|
|
26
|
+
const [operator, editionToBeSearched] = getEdition(selectedEdition.toLowerCase());
|
|
27
|
+
const index = editionOrder.findIndex(edition => edition.toLowerCase() === editionToBeSearched);
|
|
28
|
+
if (index !== -1) {
|
|
29
|
+
let resultArray;
|
|
30
|
+
if (operator === '<=') {
|
|
31
|
+
resultArray = editionOrder.slice(index + 1);
|
|
32
|
+
} else if (operator === '>=') {
|
|
33
|
+
resultArray = editionOrder.slice(0, index);
|
|
34
|
+
} else if (operator === '<') {
|
|
35
|
+
resultArray = editionOrder.slice(index);
|
|
36
|
+
} else if (operator === '>') {
|
|
37
|
+
resultArray = editionOrder.slice(0, index + 1);
|
|
38
|
+
} else {
|
|
39
|
+
resultArray = editionOrder.filter((_, order) => order !== index);
|
|
40
|
+
}
|
|
41
|
+
return resultArray;
|
|
42
|
+
}
|
|
43
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
function buildEditionTags(editionArgs, operator) {
|
|
47
|
+
return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
|
|
48
|
+
}
|
|
49
|
+
function tagProcessor(userArgsObject, editionOrder) {
|
|
50
|
+
let tagArgs = userArgsObject['tags'];
|
|
51
|
+
const edition = userArgsObject['edition'] || null;
|
|
52
|
+
if (edition !== null) {
|
|
53
|
+
let editionsArray = edition.split(',');
|
|
54
|
+
if (editionsArray.length === 1) {
|
|
55
|
+
const editionArgs = editionPreprocessing(editionOrder, edition);
|
|
56
|
+
if (editionArgs && editionArgs.length > 0) {
|
|
57
|
+
const editionTags = buildEditionTags(editionArgs, 'or');
|
|
58
|
+
tagArgs = `${getTagsString(tagArgs, editionTags)}`;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
// More than one edition given
|
|
62
|
+
const filteredEditions = editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
63
|
+
const editionTags = buildEditionTags(filteredEditions, 'or');
|
|
64
|
+
tagArgs = `${getTagsString(tagArgs, editionTags)}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return tagArgs;
|
|
68
|
+
}
|
|
@@ -13,7 +13,8 @@ var _envInitializer = require("./env-initializer");
|
|
|
13
13
|
var _logger = require("../../utils/logger");
|
|
14
14
|
var _readConfigFile = require("./readConfigFile");
|
|
15
15
|
var _rootPath = require("../../utils/rootPath");
|
|
16
|
-
var
|
|
16
|
+
var _tagProcessor = require("./tag-processor");
|
|
17
|
+
var _bddPoc = require("../../bdd-poc");
|
|
17
18
|
function parseUserArgs() {
|
|
18
19
|
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
19
20
|
}
|
|
@@ -71,7 +72,6 @@ function runPlaywright(command, args) {
|
|
|
71
72
|
});
|
|
72
73
|
childProcessForRunningPlaywright.on('exit', (code, signal) => {
|
|
73
74
|
if (code !== 0) {
|
|
74
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
75
75
|
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
76
76
|
} else {
|
|
77
77
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
|
|
@@ -79,11 +79,11 @@ function runPlaywright(command, args) {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
process.on('exit', () => {
|
|
82
|
-
|
|
82
|
+
childProcessForRunningPlaywright.kill();
|
|
83
83
|
reject('Terminating Playwright Process...');
|
|
84
84
|
});
|
|
85
85
|
process.on('SIGINT', () => {
|
|
86
|
-
|
|
86
|
+
childProcessForRunningPlaywright.kill();
|
|
87
87
|
reject('Cleaning up...');
|
|
88
88
|
});
|
|
89
89
|
});
|
|
@@ -91,13 +91,15 @@ function runPlaywright(command, args) {
|
|
|
91
91
|
function main() {
|
|
92
92
|
const userArgsObject = parseUserArgs();
|
|
93
93
|
// eslint-disable-next-line
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
const {
|
|
96
96
|
debug,
|
|
97
97
|
mode = 'dev',
|
|
98
98
|
bddMode = false,
|
|
99
|
-
headless = false
|
|
99
|
+
headless = false,
|
|
100
|
+
editionOrder
|
|
100
101
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
102
|
+
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
101
103
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
102
104
|
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
103
105
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
@@ -106,14 +108,12 @@ function main() {
|
|
|
106
108
|
const args = ['test', '--config', configPath].concat(playwrightArgs);
|
|
107
109
|
let promises = [];
|
|
108
110
|
if (bddMode) {
|
|
109
|
-
(0,
|
|
111
|
+
(0, _bddPoc.createCucumberBDD)();
|
|
110
112
|
// promises.push(runPreprocessing(tagArgs, configPath));
|
|
111
113
|
}
|
|
112
|
-
|
|
113
114
|
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
|
114
115
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, err);
|
|
115
116
|
process.exit();
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
|
-
var _default = main;
|
|
119
|
-
exports.default = _default;
|
|
119
|
+
var _default = exports.default = main;
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
1
|
+
// import { expect, test } from './core/playwright/index';
|
|
2
|
+
// import { fireEvent, render } from '@testing-library/react';
|
|
3
|
+
// import {
|
|
4
|
+
// PlaywrightTestArgs,
|
|
5
|
+
// PlaywrightTestOptions,
|
|
6
|
+
// PlaywrightWorkerArgs,
|
|
7
|
+
// PlaywrightWorkerOptions,
|
|
8
|
+
// TestType,
|
|
9
|
+
// Page
|
|
10
|
+
// } from '@playwright/test';
|
|
11
|
+
// import { DefineStepPattern } from '@cucumber/cucumber/lib/support_code_library_builder/types';
|
|
3
12
|
|
|
4
|
-
export
|
|
5
|
-
|
|
13
|
+
// export type KeyValue = { [key: string]: any };
|
|
14
|
+
|
|
15
|
+
// export type BuiltInFixturesWorker = PlaywrightWorkerArgs &
|
|
16
|
+
// PlaywrightWorkerOptions;
|
|
17
|
+
// export type BuiltInFixtures = PlaywrightTestArgs &
|
|
18
|
+
// PlaywrightTestOptions &
|
|
19
|
+
// BuiltInFixturesWorker;
|
|
20
|
+
|
|
21
|
+
// export type FixturesArg<T extends KeyValue = {}, W extends KeyValue = {}> = T &
|
|
22
|
+
// W &
|
|
23
|
+
// BuiltInFixtures;
|
|
24
|
+
|
|
25
|
+
// export declare let hasCustomTest: boolean;
|
|
26
|
+
|
|
27
|
+
// export declare function createBdd<
|
|
28
|
+
// T extends KeyValue = BuiltInFixtures,
|
|
29
|
+
// W extends KeyValue = BuiltInFixturesWorker,
|
|
30
|
+
// World
|
|
31
|
+
// >(
|
|
32
|
+
// customTest?: TestType<T, W> | null,
|
|
33
|
+
// _CustomWorld?: new (...args: any[]) => World
|
|
34
|
+
// ): {
|
|
35
|
+
// Given: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
36
|
+
// When: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
37
|
+
// Then: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
38
|
+
// And: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
39
|
+
// But: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
40
|
+
// Step: (pattern: DefineStepPattern, fn: StepFunction<T, W>) => void;
|
|
41
|
+
// Before: any;
|
|
42
|
+
// After: any;
|
|
43
|
+
// BeforeAll: any;
|
|
44
|
+
// AfterAll: any;
|
|
45
|
+
// };
|
|
46
|
+
|
|
47
|
+
// type StepFunctionFixturesArg<
|
|
48
|
+
// T extends KeyValue,
|
|
49
|
+
// W extends KeyValue
|
|
50
|
+
// > = FixturesArg<T, W>;
|
|
51
|
+
// type StepFunction<T extends KeyValue, W extends KeyValue> = (
|
|
52
|
+
// fixtures: StepFunctionFixturesArg<T, W>,
|
|
53
|
+
// ...args: any[]
|
|
54
|
+
// ) => unknown;
|
|
55
|
+
|
|
56
|
+
// const { Given, Then, When, Step, And, But } = createBdd();
|
|
57
|
+
|
|
58
|
+
// export { Given, Then, When, Step, And, But, expect, test, createBdd, Page };
|
|
59
|
+
|
|
60
|
+
// export * from '@playwright/test/types/test';
|
package/build/index.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.When = exports.Then = exports.Step = exports.Given = void 0;
|
|
6
|
+
exports.When = exports.Then = exports.Step = exports.Given = exports.But = exports.And = void 0;
|
|
7
7
|
Object.defineProperty(exports, "createBdd", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
|
-
return
|
|
10
|
+
return _bddPoc.createBdd;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "createNativeBDD", {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
get: function () {
|
|
16
|
-
return
|
|
16
|
+
return _bddPoc.createNativeBDD;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "expect", {
|
|
@@ -29,16 +29,17 @@ Object.defineProperty(exports, "test", {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
var _index = require("./core/playwright/index");
|
|
32
|
-
var
|
|
33
|
-
var _stepDefinitions = require("./bdd-poc/core-runner/stepDefinitions");
|
|
32
|
+
var _bddPoc = require("./bdd-poc");
|
|
34
33
|
// import { fireEvent, render } from '@testing-library/react';
|
|
35
34
|
const {
|
|
36
35
|
Given,
|
|
37
36
|
Then,
|
|
38
37
|
When,
|
|
39
|
-
|
|
40
|
-
} = (0,
|
|
41
|
-
exports.
|
|
38
|
+
And
|
|
39
|
+
} = (0, _bddPoc.createBdd)();
|
|
40
|
+
exports.And = And;
|
|
42
41
|
exports.When = When;
|
|
43
42
|
exports.Then = Then;
|
|
44
|
-
exports.Given = Given;
|
|
43
|
+
exports.Given = Given;
|
|
44
|
+
const Step = exports.Step = Then;
|
|
45
|
+
const But = exports.But = Then;
|