@zohodesk/testinglibrary 0.1.4 → 0.1.5-exp.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/.eslintrc.js +1 -1
- package/build/bdd-framework/cli/commands/env.js +1 -2
- package/build/bdd-framework/cli/commands/export.js +1 -2
- package/build/bdd-framework/cli/commands/test.js +1 -2
- package/build/bdd-framework/cli/options.js +1 -2
- package/build/bdd-framework/config/index.js +1 -2
- package/build/bdd-framework/decorators.js +4 -8
- package/build/bdd-framework/playwright/utils.js +1 -4
- package/build/bdd-framework/run/bddFixtures.js +1 -2
- package/build/bdd-framework/snippets/index.js +0 -1
- package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -1
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -1
- package/build/bdd-framework/utils/logger.js +1 -2
- package/build/core/jest/preprocessor/jsPreprocessor.js +2 -3
- package/build/core/playwright/clear-caches.js +29 -0
- package/build/core/playwright/custom-commands.js +1 -2
- package/build/core/playwright/index.js +1 -3
- package/build/core/playwright/readConfigFile.js +4 -3
- package/build/core/playwright/setup/config-creator.js +2 -3
- package/build/core/playwright/setup/custom-reporter.js +100 -0
- package/build/core/playwright/tag-processor.js +64 -0
- package/build/core/playwright/test-runner.js +8 -7
- package/build/index.d.ts +58 -3
- package/build/index.js +4 -2
- 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/samples/git-ignore.sample.js +8 -4
- package/build/setup-folder-structure/setupProject.js +10 -5
- package/build/utils/fileUtils.js +12 -0
- package/build/utils/logger.js +1 -2
- package/build/utils/stepDefinitionsFormatter.js +1 -2
- package/changelog.md +22 -0
- package/npm-shrinkwrap.json +981 -2280
- package/package.json +8 -6
package/.eslintrc.js
CHANGED
|
@@ -15,7 +15,7 @@ var _loadConfig = require("../../playwright/loadConfig");
|
|
|
15
15
|
const logger = new _logger.Logger({
|
|
16
16
|
verbose: true
|
|
17
17
|
});
|
|
18
|
-
const envCommand = new _commander.Command('env').description('Prints environment info').addOption(_options.configOption).action(opts => {
|
|
18
|
+
const envCommand = exports.envCommand = new _commander.Command('env').description('Prints environment info').addOption(_options.configOption).action(opts => {
|
|
19
19
|
logger.log(`Playwright-bdd environment info:\n`);
|
|
20
20
|
logger.log(`platform: ${process.platform}`);
|
|
21
21
|
logger.log(`node: ${process.version}`);
|
|
@@ -24,7 +24,6 @@ const envCommand = new _commander.Command('env').description('Prints environment
|
|
|
24
24
|
showPackageVersion('@cucumber/cucumber');
|
|
25
25
|
showPlaywrightConfigPath(opts.config);
|
|
26
26
|
});
|
|
27
|
-
exports.envCommand = envCommand;
|
|
28
27
|
function showPackageVersion(packageName) {
|
|
29
28
|
const version = packageName === 'playwright-bdd' ? getOwnVersion() : (0, _utils.getPackageVersion)(packageName);
|
|
30
29
|
logger.log(`${packageName}: v${version}`);
|
|
@@ -16,7 +16,7 @@ var _gen = require("../../gen");
|
|
|
16
16
|
const logger = new _logger.Logger({
|
|
17
17
|
verbose: true
|
|
18
18
|
});
|
|
19
|
-
const exportCommand = new _commander.Command('export').description('Prints all step definitions').addOption(_options.configOption).action(async opts => {
|
|
19
|
+
const exportCommand = exports.exportCommand = new _commander.Command('export').description('Prints all step definitions').addOption(_options.configOption).action(async opts => {
|
|
20
20
|
const {
|
|
21
21
|
resolvedConfigFile
|
|
22
22
|
} = await (0, _loadConfig.loadConfig)(opts.config);
|
|
@@ -25,7 +25,6 @@ const exportCommand = new _commander.Command('export').description('Prints all s
|
|
|
25
25
|
(0, _test.assertConfigsCount)(configs);
|
|
26
26
|
await showStepsForConfigs(configs);
|
|
27
27
|
});
|
|
28
|
-
exports.exportCommand = exportCommand;
|
|
29
28
|
async function showStepsForConfigs(configs) {
|
|
30
29
|
// here we don't need workers (as in test command) because if some step files
|
|
31
30
|
// are already in node cache, we collected them.
|
|
@@ -17,13 +17,12 @@ var _config = require("../../config");
|
|
|
17
17
|
var _options = require("../options");
|
|
18
18
|
var _exit = require("../../utils/exit");
|
|
19
19
|
const GEN_WORKER_PATH = _path.default.resolve(__dirname, '..', 'worker.js');
|
|
20
|
-
const testCommand = new _commander.Command('test').description('Generate Playwright test files from Gherkin documents').addOption(_options.configOption).option('--tags <expression>', `Tags expression to filter scenarios for generation`).option('--verbose', `Verbose mode (default: ${Boolean(_config.defaults.verbose)})`).action(async opts => {
|
|
20
|
+
const testCommand = exports.testCommand = new _commander.Command('test').description('Generate Playwright test files from Gherkin documents').addOption(_options.configOption).option('--tags <expression>', `Tags expression to filter scenarios for generation`).option('--verbose', `Verbose mode (default: ${Boolean(_config.defaults.verbose)})`).action(async opts => {
|
|
21
21
|
await (0, _loadConfig.loadConfig)(opts.config);
|
|
22
22
|
const configs = readConfigsFromEnv();
|
|
23
23
|
mergeCliOptions(configs, opts);
|
|
24
24
|
await generateFilesForConfigs(configs);
|
|
25
25
|
});
|
|
26
|
-
exports.testCommand = testCommand;
|
|
27
26
|
function readConfigsFromEnv() {
|
|
28
27
|
const configs = Object.values((0, _env.getEnvConfigs)());
|
|
29
28
|
assertConfigsCount(configs);
|
|
@@ -10,11 +10,10 @@ var _commander = require("commander");
|
|
|
10
10
|
* Config option moved to separate file as it used in test run.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
const configOption = new _commander.Option(`-c, --config <file>`, `Path to Playwright configuration file (default: playwright.config.(js|ts))`);
|
|
13
|
+
const configOption = exports.configOption = new _commander.Option(`-c, --config <file>`, `Path to Playwright configuration file (default: playwright.config.(js|ts))`);
|
|
14
14
|
/**
|
|
15
15
|
* Helper used in test run to detect config location.
|
|
16
16
|
*/
|
|
17
|
-
exports.configOption = configOption;
|
|
18
17
|
function getCliConfigPath() {
|
|
19
18
|
return new _commander.Command().allowUnknownOption().addOption(configOption).parse().getOptionValue('config');
|
|
20
19
|
}
|
|
@@ -15,14 +15,13 @@ var _utils = require("../utils");
|
|
|
15
15
|
* BDD Config.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
const defaults = {
|
|
18
|
+
const defaults = exports.defaults = {
|
|
19
19
|
outputDir: '.features-gen',
|
|
20
20
|
verbose: false,
|
|
21
21
|
examplesTitleFormat: 'Example #<_index_>',
|
|
22
22
|
publishQuiet: true,
|
|
23
23
|
quotes: 'double'
|
|
24
24
|
};
|
|
25
|
-
exports.defaults = defaults;
|
|
26
25
|
function defineBddConfig(inputConfig) {
|
|
27
26
|
const config = getConfig(inputConfig);
|
|
28
27
|
// In main process store config in env to be accessible by workers
|
|
@@ -12,11 +12,7 @@ Object.defineProperty(exports, "Fixture", {
|
|
|
12
12
|
exports.When = exports.Then = exports.Step = exports.Given = void 0;
|
|
13
13
|
var _poms = require("./stepDefinitions/decorators/poms");
|
|
14
14
|
var _steps = require("./stepDefinitions/decorators/steps");
|
|
15
|
-
const Given = (0, _steps.createStepDecorator)('Given');
|
|
16
|
-
exports.
|
|
17
|
-
const
|
|
18
|
-
exports.
|
|
19
|
-
const Then = (0, _steps.createStepDecorator)('Then');
|
|
20
|
-
exports.Then = Then;
|
|
21
|
-
const Step = (0, _steps.createStepDecorator)('Unknown');
|
|
22
|
-
exports.Step = Step;
|
|
15
|
+
const Given = exports.Given = (0, _steps.createStepDecorator)('Given');
|
|
16
|
+
const When = exports.When = (0, _steps.createStepDecorator)('When');
|
|
17
|
+
const Then = exports.Then = (0, _steps.createStepDecorator)('Then');
|
|
18
|
+
const Step = exports.Step = (0, _steps.createStepDecorator)('Unknown');
|
|
@@ -28,10 +28,7 @@ function getPlaywrightRoot() {
|
|
|
28
28
|
// See: https://github.com/microsoft/playwright/pull/26946
|
|
29
29
|
const playwrightTestRoot = (0, _utils.resolvePackageRoot)('@playwright/test');
|
|
30
30
|
const libDir = _path.default.join(playwrightTestRoot, 'lib');
|
|
31
|
-
|
|
32
|
-
// Recently added functionality in playwright
|
|
33
|
-
const playwrightDir = _path.default.join(playwrightTestRoot, 'node_modules', 'playwright');
|
|
34
|
-
playwrightRoot = _fs.default.existsSync(libDir) ? playwrightTestRoot : playwrightDir;
|
|
31
|
+
playwrightRoot = _fs.default.existsSync(libDir) ? playwrightTestRoot : (0, _utils.resolvePackageRoot)('playwright');
|
|
35
32
|
}
|
|
36
33
|
return playwrightRoot;
|
|
37
34
|
}
|
|
@@ -13,7 +13,7 @@ var _config = require("../config");
|
|
|
13
13
|
var _env = require("../config/env");
|
|
14
14
|
var _steps = require("../stepDefinitions/decorators/steps");
|
|
15
15
|
var _dir = require("../config/dir");
|
|
16
|
-
const test = _test.test.extend({
|
|
16
|
+
const test = exports.test = _test.test.extend({
|
|
17
17
|
$bddWorldBase: async ({
|
|
18
18
|
$tags,
|
|
19
19
|
$test
|
|
@@ -101,7 +101,6 @@ const test = _test.test.extend({
|
|
|
101
101
|
// eslint-disable-next-line
|
|
102
102
|
$test: ({}, use) => use(_test.test)
|
|
103
103
|
});
|
|
104
|
-
exports.test = test;
|
|
105
104
|
const BDD_AUTO_INJECT_FIXTURES = ['$testInfo', '$test', '$tags'];
|
|
106
105
|
function isBddAutoInjectFixture(name) {
|
|
107
106
|
return BDD_AUTO_INJECT_FIXTURES.includes(name);
|
|
@@ -65,7 +65,6 @@ function appendDecoratorSteps(supportCodeLibrary) {
|
|
|
65
65
|
decoratedSteps.clear();
|
|
66
66
|
// todo: fill supportCodeLibrary.originalCoordinates as it is used in snippets?
|
|
67
67
|
}
|
|
68
|
-
|
|
69
68
|
function getPomNodeByFixtureName(fixtureName) {
|
|
70
69
|
for (const pomNode of pomGraph.values()) {
|
|
71
70
|
if (pomNode.fixtureName === fixtureName) return pomNode;
|
|
@@ -73,7 +73,6 @@ function appendDecoratorSteps(supportCodeLibrary) {
|
|
|
73
73
|
decoratedSteps.clear();
|
|
74
74
|
// todo: fill supportCodeLibrary.originalCoordinates as it is used in snippets?
|
|
75
75
|
}
|
|
76
|
-
|
|
77
76
|
function getFirstNonAutoInjectFixture(fixturesArg, stepConfig) {
|
|
78
77
|
// there should be exatcly one suitable fixture in fixturesArg
|
|
79
78
|
const fixtureNames = Object.keys(fixturesArg).filter(fixtureName => !(0, _bddFixtures.isBddAutoInjectFixture)(fixtureName));
|
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _babelJest = _interopRequireDefault(require("babel-jest"));
|
|
9
|
-
var _default = _babelJest.default.createTransformer({
|
|
9
|
+
var _default = exports.default = _babelJest.default.createTransformer({
|
|
10
10
|
presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
|
|
11
11
|
plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
|
|
12
|
-
});
|
|
13
|
-
exports.default = _default;
|
|
12
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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 _fileUtils = require("../../utils/fileUtils");
|
|
10
|
+
var _logger = require("../../utils/logger");
|
|
11
|
+
var _readConfigFile = require("./readConfigFile");
|
|
12
|
+
function clearCaches() {
|
|
13
|
+
try {
|
|
14
|
+
const {
|
|
15
|
+
authFilePath,
|
|
16
|
+
reportPath
|
|
17
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
18
|
+
authFilePath.split('/').pop();
|
|
19
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting auth files present in ${authFilePath}`);
|
|
20
|
+
(0, _fileUtils.deleteFolder)(_path.default.resolve(process.cwd(), authFilePath));
|
|
21
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Deleting Playwright report ${reportPath}`);
|
|
22
|
+
(0, _fileUtils.deleteFolder)(reportPath);
|
|
23
|
+
(0, _fileUtils.deleteFolder)(_path.default.resolve(process.cwd(), 'uat', '.features-gen'));
|
|
24
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Caches Cleared');
|
|
25
|
+
} catch (err) {
|
|
26
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Error While clearing cookies');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
var _default = exports.default = clearCaches;
|
|
@@ -55,7 +55,7 @@ const {
|
|
|
55
55
|
bddMode
|
|
56
56
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
57
57
|
let base = bddMode ? _bddFramework.test : _test.test;
|
|
58
|
-
const test = base.extend({
|
|
58
|
+
const test = exports.test = base.extend({
|
|
59
59
|
page: async ({
|
|
60
60
|
page
|
|
61
61
|
}, use) => {
|
|
@@ -91,7 +91,6 @@ const test = base.extend({
|
|
|
91
91
|
// await page;
|
|
92
92
|
// });
|
|
93
93
|
},
|
|
94
|
-
|
|
95
94
|
context: async ({
|
|
96
95
|
context
|
|
97
96
|
}, use) => {
|
|
@@ -101,7 +100,6 @@ const test = base.extend({
|
|
|
101
100
|
},
|
|
102
101
|
...additionalPages
|
|
103
102
|
});
|
|
104
|
-
exports.test = test;
|
|
105
103
|
const {
|
|
106
104
|
Given,
|
|
107
105
|
When,
|
|
@@ -11,8 +11,7 @@ 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 {
|
|
18
17
|
headless: false,
|
|
@@ -35,7 +34,8 @@ function getDefaultConfig() {
|
|
|
35
34
|
additionalPages: {},
|
|
36
35
|
featureFilesFolder: 'feature-files',
|
|
37
36
|
stepDefinitionsFolder: 'steps',
|
|
38
|
-
testIdAttribute: 'data-testid'
|
|
37
|
+
testIdAttribute: 'data-testid',
|
|
38
|
+
editionOrder: ['Free', 'Express', 'Standard', 'Professional', 'Enterprise']
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
@@ -84,6 +84,7 @@ function combineDefaultConfigWithUserConfig(userConfiguration) {
|
|
|
84
84
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
85
85
|
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
86
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
|
|
87
88
|
*/
|
|
88
89
|
|
|
89
90
|
/**
|
|
@@ -60,7 +60,7 @@ function getPlaywrightConfig() {
|
|
|
60
60
|
reporter: [['html', {
|
|
61
61
|
outputFolder: reportPath,
|
|
62
62
|
open: openReportOn
|
|
63
|
-
}]],
|
|
63
|
+
}], ['list'], ['./custom-reporter.js']],
|
|
64
64
|
timeout: testTimeout,
|
|
65
65
|
expect: {
|
|
66
66
|
timeout: expectTimeout
|
|
@@ -73,5 +73,4 @@ function getPlaywrightConfig() {
|
|
|
73
73
|
}, ...projects] : [...projects]
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
var _default = (0, _test.defineConfig)(getPlaywrightConfig());
|
|
77
|
-
exports.default = _default;
|
|
76
|
+
var _default = exports.default = (0, _test.defineConfig)(getPlaywrightConfig());
|
|
@@ -0,0 +1,100 @@
|
|
|
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.status = 'unknown';
|
|
24
|
+
this.startedAt = 0;
|
|
25
|
+
this._open = (0, _readConfigFile.generateConfigFromFile)().openReportOn;
|
|
26
|
+
}
|
|
27
|
+
onBegin() {
|
|
28
|
+
this.startedAt = Date.now();
|
|
29
|
+
}
|
|
30
|
+
onTestEnd(test, result) {
|
|
31
|
+
const title = [];
|
|
32
|
+
const fileName = [];
|
|
33
|
+
let clean = true;
|
|
34
|
+
for (const s of test.titlePath()) {
|
|
35
|
+
if (s === '' && clean) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
clean = false;
|
|
39
|
+
title.push(s);
|
|
40
|
+
if (s.includes('.ts') || s.includes('.js')) {
|
|
41
|
+
fileName.push(s);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// This will publish the file name + line number test begins on
|
|
45
|
+
const z = `${fileName[0]}:${test.location.line}:${test.location.column}`;
|
|
46
|
+
// Using the t variable in the push will push a full test name + test description
|
|
47
|
+
const t = title.join(' > ');
|
|
48
|
+
// Set the status
|
|
49
|
+
const status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn') ? 'warned' : result.status;
|
|
50
|
+
// Logic to push the results into the correct array
|
|
51
|
+
if (result.status === 'passed' && result.retry >= 1) {
|
|
52
|
+
this.flakey.push(z);
|
|
53
|
+
} else {
|
|
54
|
+
this[status].push(z);
|
|
55
|
+
}
|
|
56
|
+
this[status].push(z);
|
|
57
|
+
}
|
|
58
|
+
onEnd(result) {
|
|
59
|
+
this.durationInMS = Date.now() - this.startedAt;
|
|
60
|
+
this.status = result.status;
|
|
61
|
+
// removing duplicate tests from passed array
|
|
62
|
+
this.passed = this.passed.filter((element, index) => {
|
|
63
|
+
return this.passed.indexOf(element) === index;
|
|
64
|
+
});
|
|
65
|
+
// removing duplicate tests from the failed array
|
|
66
|
+
this.failed = this.failed.filter((element, index) => {
|
|
67
|
+
if (!this.passed.includes(element)) {
|
|
68
|
+
return this.failed.indexOf(element) === index;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
// removing duplicate tests from the skipped array
|
|
72
|
+
this.skipped = this.skipped.filter((element, index) => {
|
|
73
|
+
return this.skipped.indexOf(element) === index;
|
|
74
|
+
});
|
|
75
|
+
// removing duplicate tests from the timedOut array
|
|
76
|
+
this.timedOut = this.timedOut.filter((element, index) => {
|
|
77
|
+
return this.timedOut.indexOf(element) === index;
|
|
78
|
+
});
|
|
79
|
+
// removing duplicate tests from the interrupted array
|
|
80
|
+
this.interrupted = this.interrupted.filter((element, index) => {
|
|
81
|
+
return this.interrupted.indexOf(element) === index;
|
|
82
|
+
});
|
|
83
|
+
// fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));
|
|
84
|
+
let {
|
|
85
|
+
reportPath
|
|
86
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
87
|
+
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', 'test-summary.json'), JSON.stringify(this, null, ' '));
|
|
88
|
+
}
|
|
89
|
+
onExit() {
|
|
90
|
+
const shouldClearLastLine = this._open !== 'always' || this._open !== 'on-failure';
|
|
91
|
+
if (shouldClearLastLine) {
|
|
92
|
+
/**Below code is to replace the playwright default report commond with abstraction tool command */
|
|
93
|
+
_readline.default.moveCursor(process.stdout, 0, -2); // up two line
|
|
94
|
+
_readline.default.clearLine(process.stdout, 1); // from cursor to end
|
|
95
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'npx ZDTestingFramework report or npm run uat-report');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
var _default = exports.default = JSONSummaryReporter;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tagProcessor = tagProcessor;
|
|
7
|
+
function getTagsString(tags) {
|
|
8
|
+
return tags && tags !== '' ? `${tags} or ` : '';
|
|
9
|
+
}
|
|
10
|
+
function getEdition(edition) {
|
|
11
|
+
if (edition.startsWith('<=')) {
|
|
12
|
+
return ['<=', edition.slice(2)];
|
|
13
|
+
} else if (edition.startsWith('>=')) {
|
|
14
|
+
return ['>=', edition.slice(2)];
|
|
15
|
+
} else if (edition.startsWith('<')) {
|
|
16
|
+
return ['<', edition.slice(1)];
|
|
17
|
+
} else if (edition.startsWith('>')) {
|
|
18
|
+
return ['>', edition.slice(1)];
|
|
19
|
+
}
|
|
20
|
+
return [null, edition];
|
|
21
|
+
}
|
|
22
|
+
function editionPreprocessing(editionOrder, selectedEdition) {
|
|
23
|
+
const [operator, editionToBeSearched] = getEdition(selectedEdition.toLowerCase());
|
|
24
|
+
const index = editionOrder.findIndex(edition => edition.toLowerCase() === editionToBeSearched);
|
|
25
|
+
if (index !== -1) {
|
|
26
|
+
let resultArray;
|
|
27
|
+
if (operator === '>') {
|
|
28
|
+
resultArray = editionOrder.slice(index + 1);
|
|
29
|
+
} else if (operator === '<') {
|
|
30
|
+
resultArray = editionOrder.slice(0, index);
|
|
31
|
+
} else if (operator === '>=') {
|
|
32
|
+
resultArray = editionOrder.slice(index);
|
|
33
|
+
} else if (operator === '<=') {
|
|
34
|
+
resultArray = editionOrder.slice(0, index + 1);
|
|
35
|
+
} else {
|
|
36
|
+
resultArray = [editionOrder[index]];
|
|
37
|
+
}
|
|
38
|
+
return resultArray;
|
|
39
|
+
}
|
|
40
|
+
Logger.log(Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
function buildEditionTags(editionArgs) {
|
|
44
|
+
return editionArgs.map(edition => `@edition_${edition}`).join(' or ');
|
|
45
|
+
}
|
|
46
|
+
function tagProcessor(userArgsObject, editionOrder) {
|
|
47
|
+
let tagArgs = userArgsObject['tags'];
|
|
48
|
+
const edition = userArgsObject['edition'] || null;
|
|
49
|
+
if (edition !== null) {
|
|
50
|
+
let editionsArray = edition.split(',');
|
|
51
|
+
if (editionArray.length === 1) {
|
|
52
|
+
const editionArgs = editionPreprocessing(editionOrder, edition);
|
|
53
|
+
if (editionArgs && editionArgs.length > 0) {
|
|
54
|
+
const editionTags = buildEditionTags(editionArgs);
|
|
55
|
+
tagArgs = `${getTagsString(tagArgs)}${editionTags}`;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
// More than one edition given
|
|
59
|
+
const editionTags = editionArray.join(' And ');
|
|
60
|
+
tagArgs = `${getTagsString(tagArgs)}(${editionTags})`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return tagArgs;
|
|
64
|
+
}
|
|
@@ -13,6 +13,7 @@ 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 _tagProcessor = require("./tag-processor");
|
|
16
17
|
function parseUserArgs() {
|
|
17
18
|
return (0, _cliArgsToObject.cliArgsToObject)(process.argv.slice(2));
|
|
18
19
|
}
|
|
@@ -66,7 +67,6 @@ function runPlaywright(command, args) {
|
|
|
66
67
|
});
|
|
67
68
|
childProcessForRunningPlaywright.on('exit', (code, signal) => {
|
|
68
69
|
if (code !== 0) {
|
|
69
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
70
70
|
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
71
71
|
} else {
|
|
72
72
|
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
|
|
@@ -74,11 +74,11 @@ function runPlaywright(command, args) {
|
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
process.on('exit', () => {
|
|
77
|
-
|
|
77
|
+
childProcessForRunningPlaywright.kill();
|
|
78
78
|
reject('Terminating Playwright Process...');
|
|
79
79
|
});
|
|
80
80
|
process.on('SIGINT', () => {
|
|
81
|
-
|
|
81
|
+
childProcessForRunningPlaywright.kill();
|
|
82
82
|
reject('Cleaning up...');
|
|
83
83
|
});
|
|
84
84
|
});
|
|
@@ -86,13 +86,15 @@ function runPlaywright(command, args) {
|
|
|
86
86
|
function main() {
|
|
87
87
|
const userArgsObject = parseUserArgs();
|
|
88
88
|
// eslint-disable-next-line
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
const {
|
|
91
91
|
debug,
|
|
92
92
|
mode = 'dev',
|
|
93
93
|
bddMode = false,
|
|
94
|
-
headless = false
|
|
94
|
+
headless = false,
|
|
95
|
+
editionOrder
|
|
95
96
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
97
|
+
const tagArgs = (0, _tagProcessor.tagProcessor)(userArgsObject, editionOrder);
|
|
96
98
|
const playwrightArgs = getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless);
|
|
97
99
|
(0, _envInitializer.initializeEnvConfig)(userArgsObject.mode ? userArgsObject.mode : mode);
|
|
98
100
|
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
@@ -108,5 +110,4 @@ function main() {
|
|
|
108
110
|
process.exit();
|
|
109
111
|
});
|
|
110
112
|
}
|
|
111
|
-
var _default = main;
|
|
112
|
-
exports.default = _default;
|
|
113
|
+
var _default = exports.default = main;
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { expect, test } from './core/playwright/index';
|
|
2
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,7 +3,7 @@
|
|
|
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 () {
|
|
@@ -45,4 +45,6 @@ const {
|
|
|
45
45
|
exports.Step = Step;
|
|
46
46
|
exports.When = When;
|
|
47
47
|
exports.Then = Then;
|
|
48
|
-
exports.Given = Given;
|
|
48
|
+
exports.Given = Given;
|
|
49
|
+
const And = exports.And = Then;
|
|
50
|
+
const But = exports.But = Then;
|
package/build/lib/cli.js
CHANGED
|
@@ -7,6 +7,8 @@ var _codegen = _interopRequireDefault(require("../core/playwright/codegen"));
|
|
|
7
7
|
var _logger = require("../utils/logger");
|
|
8
8
|
var _setupProject = _interopRequireDefault(require("../setup-folder-structure/setupProject"));
|
|
9
9
|
var _parser = require("../parser/parser");
|
|
10
|
+
var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
|
|
11
|
+
var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
|
|
10
12
|
// import createJestRunner from '../core/jest/runner/jest-runner';
|
|
11
13
|
|
|
12
14
|
const [,, option, ...otherOptions] = process.argv;
|
|
@@ -46,9 +48,16 @@ switch (option) {
|
|
|
46
48
|
(0, _parser.generateSpecCodeForFeatureFile)(otherOptions);
|
|
47
49
|
break;
|
|
48
50
|
}
|
|
51
|
+
case 'clearCaches':
|
|
52
|
+
{
|
|
53
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Clearing caches...');
|
|
54
|
+
(0, _clearCaches.default)();
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'help':
|
|
49
58
|
default:
|
|
50
59
|
{
|
|
51
|
-
|
|
60
|
+
(0, _helper.default)();
|
|
52
61
|
break;
|
|
53
62
|
}
|
|
54
63
|
}
|