@zohodesk/testinglibrary 0.1.8 → 0.1.9
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 +69 -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 +47 -0
- package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
- package/build/core/playwright/helpers/auth/getUsers.js +72 -0
- package/build/core/playwright/helpers/auth/index.js +58 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +36 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +17 -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 +51 -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 +19 -8
- package/build/core/playwright/types.js +43 -0
- package/build/index.d.ts +21 -2
- package/build/index.js +48 -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/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
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.getBrowsersList = getBrowsersList;
|
|
7
8
|
exports.getProjects = getProjects;
|
|
8
9
|
exports.getTestDir = getTestDir;
|
|
9
10
|
exports.getTestUseOptions = getTestUseOptions;
|
|
@@ -11,6 +12,10 @@ var _test = require("@playwright/test");
|
|
|
11
12
|
var _path = _interopRequireDefault(require("path"));
|
|
12
13
|
var _readConfigFile = require("../readConfigFile");
|
|
13
14
|
var _bddFramework = require("../../../bdd-framework");
|
|
15
|
+
var _logger = require("../../../utils/logger");
|
|
16
|
+
var _browserTypes = require("../constants/browserTypes");
|
|
17
|
+
var _configFileNameProvider = require("../helpers/configFileNameProvider");
|
|
18
|
+
var _fileUtils = require("../../../utils/fileUtils");
|
|
14
19
|
/**
|
|
15
20
|
** Playwright project configuration
|
|
16
21
|
* @returns {import('@playwright/test').Project}
|
|
@@ -31,7 +36,7 @@ function getBrowserConfig({
|
|
|
31
36
|
const dependencies = isAuthMode ? ['setup'] : [];
|
|
32
37
|
if (browser === 'chrome') {
|
|
33
38
|
return {
|
|
34
|
-
name:
|
|
39
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.CHROME,
|
|
35
40
|
use: {
|
|
36
41
|
..._test.devices['Desktop Chrome'],
|
|
37
42
|
...commonConfig
|
|
@@ -44,7 +49,7 @@ function getBrowserConfig({
|
|
|
44
49
|
};
|
|
45
50
|
} else if (browser === 'edge') {
|
|
46
51
|
return {
|
|
47
|
-
name:
|
|
52
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.EDGE,
|
|
48
53
|
timeout: testTimeout,
|
|
49
54
|
expect: {
|
|
50
55
|
timeout: expectTimeout
|
|
@@ -58,7 +63,7 @@ function getBrowserConfig({
|
|
|
58
63
|
};
|
|
59
64
|
} else if (browser === 'firefox') {
|
|
60
65
|
return {
|
|
61
|
-
name:
|
|
66
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.FIREFOX,
|
|
62
67
|
timeout: 2 * testTimeout,
|
|
63
68
|
expect: {
|
|
64
69
|
timeout: 2 * expectTimeout
|
|
@@ -71,7 +76,7 @@ function getBrowserConfig({
|
|
|
71
76
|
};
|
|
72
77
|
} else if (browser === 'safari') {
|
|
73
78
|
return {
|
|
74
|
-
name:
|
|
79
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.SAFARI,
|
|
75
80
|
timeout: 4 * testTimeout,
|
|
76
81
|
expect: {
|
|
77
82
|
timeout: 4 * expectTimeout
|
|
@@ -88,8 +93,8 @@ function getBrowserConfig({
|
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
/**
|
|
91
|
-
*
|
|
92
|
-
* @param {*} param0
|
|
96
|
+
*
|
|
97
|
+
* @param {*} param0
|
|
93
98
|
* @returns {import('@playwright/test').Project[]}
|
|
94
99
|
*/
|
|
95
100
|
function getProjects({
|
|
@@ -109,11 +114,42 @@ function getProjects({
|
|
|
109
114
|
viewport
|
|
110
115
|
})).filter(Boolean);
|
|
111
116
|
}
|
|
117
|
+
function getBrowsersList(browserFromArgs) {
|
|
118
|
+
if (browserFromArgs) {
|
|
119
|
+
if (typeof browserFromArgs === 'string') {
|
|
120
|
+
let listOfbrowsers = browserFromArgs.split(',').map(browser => browser.trim().toLowerCase());
|
|
121
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Using browsers from command line args');
|
|
122
|
+
return listOfbrowsers;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
function getPathsForFeatureFiles(cwd) {
|
|
128
|
+
if (process.env.isRerunFailedCases) {
|
|
129
|
+
let {
|
|
130
|
+
reportPath
|
|
131
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
132
|
+
let filePathFromArgs = process.env.filePath;
|
|
133
|
+
let filePath = filePathFromArgs ? filePathFromArgs : reportPath;
|
|
134
|
+
const testSummary = (0, _fileUtils.readFileContents)(filePath);
|
|
135
|
+
if (testSummary !== null) {
|
|
136
|
+
const {
|
|
137
|
+
failed = []
|
|
138
|
+
} = JSON.parse(testSummary);
|
|
139
|
+
const casesToRun = failed.map(filePath => _path.default.join(cwd, 'uat', filePath.replace(/\.spec\.js$|\.js$/, '')));
|
|
140
|
+
return casesToRun;
|
|
141
|
+
} else {
|
|
142
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Unable to read test summary from the ${reportPath}. Verify If File Exists in the path`);
|
|
143
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Going to run all test cases');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return [_path.default.join(cwd, 'uat', '**', '*.feature')];
|
|
147
|
+
}
|
|
112
148
|
function getTestDir(bddMode, cwd, {
|
|
113
149
|
stepDefinitionsFolder
|
|
114
150
|
}) {
|
|
115
151
|
return bddMode ? (0, _bddFramework.defineBddConfig)({
|
|
116
|
-
paths:
|
|
152
|
+
paths: getPathsForFeatureFiles(cwd),
|
|
117
153
|
import: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
|
|
118
154
|
featuresRoot: _path.default.join(cwd, 'uat'),
|
|
119
155
|
outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
|
|
@@ -10,6 +10,7 @@ var _readline = _interopRequireDefault(require("readline"));
|
|
|
10
10
|
var _fileUtils = require("../../../utils/fileUtils");
|
|
11
11
|
var _readConfigFile = require("../readConfigFile");
|
|
12
12
|
var _logger = require("../../../utils/logger");
|
|
13
|
+
var _configFileNameProvider = require("../helpers/configFileNameProvider");
|
|
13
14
|
class JSONSummaryReporter {
|
|
14
15
|
constructor() {
|
|
15
16
|
this.durationInMS = -1;
|
|
@@ -43,7 +44,7 @@ class JSONSummaryReporter {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
// This will publish the file name + line number test begins on
|
|
46
|
-
const z = `${fileName[0]}
|
|
47
|
+
const z = `${fileName[0]}`;
|
|
47
48
|
// Using the t variable in the push will push a full test name + test description
|
|
48
49
|
const t = title.join(' > ');
|
|
49
50
|
// Set the status
|
|
@@ -93,7 +94,7 @@ class JSONSummaryReporter {
|
|
|
93
94
|
let {
|
|
94
95
|
reportPath
|
|
95
96
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
96
|
-
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './',
|
|
97
|
+
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', (0, _configFileNameProvider.getReportFileName)()), JSON.stringify(this, null, ' '));
|
|
97
98
|
}
|
|
98
99
|
onExit() {
|
|
99
100
|
const shouldClearLastLine = this._open !== 'always' || this._open !== 'on-failure';
|
|
@@ -14,10 +14,14 @@ var _logger = require("../../utils/logger");
|
|
|
14
14
|
var _readConfigFile = require("./readConfigFile");
|
|
15
15
|
var _rootPath = require("../../utils/rootPath");
|
|
16
16
|
var _tagProcessor = require("./tag-processor");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
var _configUtils = require("./setup/config-utils");
|
|
18
|
+
var _browserTypes = require("./constants/browserTypes");
|
|
19
|
+
var _parseUserArgs = _interopRequireDefault(require("./helpers/parseUserArgs"));
|
|
20
20
|
function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
21
|
+
const {
|
|
22
|
+
browsers = null
|
|
23
|
+
} = userArgsObject;
|
|
24
|
+
let browserList = (0, _configUtils.getBrowsersList)(browsers);
|
|
21
25
|
const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
|
|
22
26
|
if (debug) {
|
|
23
27
|
playwrightArgs.push('--debug');
|
|
@@ -29,6 +33,9 @@ function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
|
29
33
|
if (!headless && !userArgsObject.headed) {
|
|
30
34
|
playwrightArgs.push('--headed');
|
|
31
35
|
}
|
|
36
|
+
if (browserList && browserList.length > 0) {
|
|
37
|
+
browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
|
|
38
|
+
}
|
|
32
39
|
return playwrightArgs;
|
|
33
40
|
}
|
|
34
41
|
function runPreprocessing(tagArgs, configPath) {
|
|
@@ -41,7 +48,10 @@ function runPreprocessing(tagArgs, configPath) {
|
|
|
41
48
|
}
|
|
42
49
|
return new Promise((resolve, reject) => {
|
|
43
50
|
const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
|
|
44
|
-
stdio: 'inherit'
|
|
51
|
+
stdio: 'inherit',
|
|
52
|
+
env: {
|
|
53
|
+
...process.env
|
|
54
|
+
}
|
|
45
55
|
});
|
|
46
56
|
childProcessForPreprocessing.on('error', data => {
|
|
47
57
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
@@ -60,7 +70,10 @@ function runPreprocessing(tagArgs, configPath) {
|
|
|
60
70
|
function runPlaywright(command, args) {
|
|
61
71
|
return new Promise((resolve, reject) => {
|
|
62
72
|
const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
|
|
63
|
-
stdio: 'inherit'
|
|
73
|
+
stdio: 'inherit',
|
|
74
|
+
env: {
|
|
75
|
+
...process.env
|
|
76
|
+
}
|
|
64
77
|
});
|
|
65
78
|
childProcessForRunningPlaywright.on('error', error => {
|
|
66
79
|
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
@@ -84,9 +97,7 @@ function runPlaywright(command, args) {
|
|
|
84
97
|
});
|
|
85
98
|
}
|
|
86
99
|
function main() {
|
|
87
|
-
const userArgsObject =
|
|
88
|
-
// eslint-disable-next-line
|
|
89
|
-
|
|
100
|
+
const userArgsObject = (0, _parseUserArgs.default)();
|
|
90
101
|
const {
|
|
91
102
|
debug,
|
|
92
103
|
mode = 'dev',
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object|null} viewportConfig
|
|
3
|
+
* @property {number} width - width of the viewport
|
|
4
|
+
* @property {number} height - height of the viewport
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object|null} viewportConfig
|
|
8
|
+
* @property {number} width - width of the viewport
|
|
9
|
+
* @property {number} height - height of the viewport
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object|null} testSetupConfig
|
|
14
|
+
* @property {any} page - Function that will be called while setting up page fixtures
|
|
15
|
+
* @property {any} context - Function that will be called while setting up context fixtures
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Represents the user configuration object.
|
|
20
|
+
* @typedef {Object} UserConfig
|
|
21
|
+
* @property {string} uatDirectory - Directory in which uat configuration is places.
|
|
22
|
+
* @property {string} headless - Headless Browsers mode.
|
|
23
|
+
* @property {number} trace - trace for test cases.
|
|
24
|
+
* @property {boolean} video - video for test cases,
|
|
25
|
+
* @property {boolean} debug - debug mode
|
|
26
|
+
* @property {string} mode: mode in which the test cases needs to run
|
|
27
|
+
* @property {boolean} isAuthMode - Auth Mode. config whether authentication step needed before running test cases
|
|
28
|
+
* @property {string} authFilePath - File Path where the cookies stored
|
|
29
|
+
* @property {any} browsers: List of browsers
|
|
30
|
+
* @property {string} openReportOn: default Option value (never, on-failure and always)
|
|
31
|
+
* @property {any} reportPath : directory where report is generate
|
|
32
|
+
* @property {boolean} bddMode: Feature files needs to be processed
|
|
33
|
+
* @property {number} expectTimeout: time in milliseconds which the expect condition should fail
|
|
34
|
+
* @property {number} testTimeout: time in milliseconds which the test should fail
|
|
35
|
+
* @property {Object} additionalPages: custom pages configuration
|
|
36
|
+
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
37
|
+
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
38
|
+
* @property {viewportConfig} viewport: viewport configuration for the browser. Default is { width: 1280, height: 720 }
|
|
39
|
+
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
40
|
+
* @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
|
|
41
|
+
* @property {testSetupConfig} testSetup: Specify page and context functions that will be called while intilaizing fixtures.
|
|
42
|
+
*/
|
|
43
|
+
"use strict";
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { expect, test
|
|
1
|
+
import { expect, test, accountLogin,
|
|
2
|
+
getListOfUsers,
|
|
3
|
+
getPrimaryUser,
|
|
4
|
+
getUserForSelectedEditionAndProfile,
|
|
5
|
+
isCI,
|
|
6
|
+
loadCookiesIfPresent,
|
|
7
|
+
performLoginSteps,
|
|
8
|
+
verifyIfCookieFileExists } from './core/playwright/index';
|
|
2
9
|
import { fireEvent, render } from '@testing-library/react';
|
|
3
10
|
import {
|
|
4
11
|
PlaywrightTestArgs,
|
|
@@ -55,6 +62,18 @@ type StepFunction<T extends KeyValue, W extends KeyValue> = (
|
|
|
55
62
|
|
|
56
63
|
const { Given, Then, When, Step, And, But } = createBdd();
|
|
57
64
|
|
|
58
|
-
|
|
65
|
+
type UserConfig = import('./core/playwright/readConfigFile').UserConfig;
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
UserConfig,
|
|
69
|
+
Given, Then, When, Step, And, But, expect, test,
|
|
70
|
+
createBdd, Page, accountLogin,
|
|
71
|
+
getListOfUsers,
|
|
72
|
+
getPrimaryUser,
|
|
73
|
+
getUserForSelectedEditionAndProfile,
|
|
74
|
+
isCI,
|
|
75
|
+
loadCookiesIfPresent,
|
|
76
|
+
performLoginSteps,
|
|
77
|
+
verifyIfCookieFileExists };
|
|
59
78
|
|
|
60
79
|
export * from '@playwright/test/types/test';
|
package/build/index.js
CHANGED
|
@@ -4,6 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.When = exports.Then = exports.Step = exports.Given = exports.But = exports.And = void 0;
|
|
7
|
+
Object.defineProperty(exports, "accountLogin", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _index.accountLogin;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
7
13
|
Object.defineProperty(exports, "createBdd", {
|
|
8
14
|
enumerable: true,
|
|
9
15
|
get: function () {
|
|
@@ -16,24 +22,55 @@ Object.defineProperty(exports, "expect", {
|
|
|
16
22
|
return _index.expect;
|
|
17
23
|
}
|
|
18
24
|
});
|
|
25
|
+
Object.defineProperty(exports, "getListOfUsers", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _index.getListOfUsers;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "getPrimaryUser", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _index.getPrimaryUser;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "getUserForSelectedEditionAndProfile", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _index.getUserForSelectedEditionAndProfile;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "isCI", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _index.isCI;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "loadCookiesIfPresent", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return _index.loadCookiesIfPresent;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "performLoginSteps", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _index.performLoginSteps;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
19
61
|
Object.defineProperty(exports, "test", {
|
|
20
62
|
enumerable: true,
|
|
21
63
|
get: function () {
|
|
22
64
|
return _index.test;
|
|
23
65
|
}
|
|
24
66
|
});
|
|
67
|
+
Object.defineProperty(exports, "verifyIfCookieFileExists", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return _index.verifyIfCookieFileExists;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
25
73
|
var _index = require("./core/playwright/index");
|
|
26
|
-
// const { expect, test, createBdd } = require('./core/playwright/index');
|
|
27
|
-
// const { fireEvent, render } = require('@testing-library/react');
|
|
28
|
-
|
|
29
|
-
// module.exports = {
|
|
30
|
-
// expect,
|
|
31
|
-
// test,
|
|
32
|
-
// fireEvent,
|
|
33
|
-
// render,
|
|
34
|
-
// createBdd
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
74
|
// import { fireEvent, render } from '@testing-library/react';
|
|
38
75
|
|
|
39
76
|
const {
|
package/build/lib/cli.js
CHANGED
|
@@ -9,12 +9,10 @@ var _setupProject = _interopRequireDefault(require("../setup-folder-structure/se
|
|
|
9
9
|
var _parser = require("../parser/parser");
|
|
10
10
|
var _clearCaches = _interopRequireDefault(require("../core/playwright/clear-caches"));
|
|
11
11
|
var _helper = _interopRequireDefault(require("../setup-folder-structure/helper"));
|
|
12
|
+
var _parseUserArgs = _interopRequireDefault(require("../core/playwright/helpers/parseUserArgs"));
|
|
12
13
|
// import createJestRunner from '../core/jest/runner/jest-runner';
|
|
13
14
|
|
|
14
15
|
const [,, option, ...otherOptions] = process.argv;
|
|
15
|
-
// const args = process.argv.slice(3);
|
|
16
|
-
// const appPath = process.cwd();
|
|
17
|
-
|
|
18
16
|
switch (option) {
|
|
19
17
|
case 'test':
|
|
20
18
|
{
|
|
@@ -23,6 +21,17 @@ switch (option) {
|
|
|
23
21
|
//createJestRunner();
|
|
24
22
|
break;
|
|
25
23
|
}
|
|
24
|
+
case 're-run-failed':
|
|
25
|
+
{
|
|
26
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Failed Tests..');
|
|
27
|
+
let {
|
|
28
|
+
filePath
|
|
29
|
+
} = (0, _parseUserArgs.default)();
|
|
30
|
+
process.env.isRerunFailedCases = true;
|
|
31
|
+
process.env.filePath = filePath;
|
|
32
|
+
(0, _testRunner.default)();
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
26
35
|
case 'report':
|
|
27
36
|
{
|
|
28
37
|
// console.log('\x1b[36mGenerating Reports...\x1b[0m');
|
|
@@ -5,13 +5,21 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
5
5
|
var _child_process = require("child_process");
|
|
6
6
|
var _logger = require("../utils/logger");
|
|
7
7
|
var _rootPath = require("../utils/rootPath");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
// We are skipping the download of browsers when NODE_ENV is set to production or flag SKIP_BROWSER_DOWNLOAD is set to true
|
|
9
|
+
|
|
10
|
+
let isSkipDownloadingBrowsers = Boolean(process.env.SKIP_BROWSER_DOWNLOAD);
|
|
11
|
+
let isProductionMode = process.env.NODE_ENV === 'production';
|
|
12
|
+
if (isSkipDownloadingBrowsers || isProductionMode) {
|
|
13
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Skipping browsers download in production mode');
|
|
14
|
+
} else {
|
|
15
|
+
const playwrightPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('playwright'));
|
|
16
|
+
const command = playwrightPath;
|
|
17
|
+
const args = ['install'];
|
|
18
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Downloading browsers for running tests`);
|
|
19
|
+
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
20
|
+
stdio: 'inherit'
|
|
21
|
+
});
|
|
22
|
+
childProcess.on('error', error => {
|
|
23
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -24,11 +24,14 @@ function helpercmd() {
|
|
|
24
24
|
_commander.program.command('test').description('This command is used to execute tests');
|
|
25
25
|
_commander.program.command('init').description('This command will initialize Project');
|
|
26
26
|
_commander.program.command('report').description('This command is used to generate a report summarizing the results of executed tests.');
|
|
27
|
+
_commander.program.command('re-run-failed').description('This command will re-run the failed test cases based on test summary');
|
|
27
28
|
_commander.program.command('codegen').description('This command is used to assist developer to write test case');
|
|
28
29
|
_commander.program.option('--headed', 'Run tests with a headed browser.');
|
|
29
30
|
_commander.program.option('--debug', 'This command is used to initiate a debugging session');
|
|
30
31
|
_commander.program.option('--tags', 'Run specific test case with mentioned tags (Usage: -- --tags="@live")');
|
|
31
32
|
_commander.program.option('--workers', 'Specify number of workers to run the test case parallely (Usage: -- --workers=2)');
|
|
33
|
+
_commander.program.option('--edition', 'Specify edition to run the test cases (Usage: -- --edition="standard". This will run the test cases with either no edition mentioned or edition standard)');
|
|
34
|
+
_commander.program.option('--browsers', 'Specify the browsers on which the test case should run (Usage: -- --browsers="chrome,firefox,safari")');
|
|
32
35
|
_commander.program.parse(process.argv);
|
|
33
36
|
}
|
|
34
37
|
var _default = exports.default = helpercmd;
|
|
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.cliArgsToObject = cliArgsToObject;
|
|
7
7
|
exports.objectToCliArgs = objectToCliArgs;
|
|
8
|
+
function isMatchForOption(option) {
|
|
9
|
+
return /^--./.test(option);
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* Converts an array of command-line arguments into an object.
|
|
10
14
|
*
|
|
@@ -23,7 +27,7 @@ exports.objectToCliArgs = objectToCliArgs;
|
|
|
23
27
|
function cliArgsToObject(cliArgs, isKeyNeedToBeAdded) {
|
|
24
28
|
const processEnv = {};
|
|
25
29
|
cliArgs.forEach(option => {
|
|
26
|
-
if (
|
|
30
|
+
if (isMatchForOption(option)) {
|
|
27
31
|
const equIndex = option.indexOf('=');
|
|
28
32
|
let key = option.slice(2, equIndex);
|
|
29
33
|
let value = option.slice(equIndex + 1);
|
package/build/utils/fileUtils.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.readFileContents = readFileContents;
|
|
|
11
11
|
exports.writeFileContents = writeFileContents;
|
|
12
12
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
13
|
var _path = _interopRequireDefault(require("path"));
|
|
14
|
+
var _logger = require("./logger");
|
|
14
15
|
function checkIfFileExists(file) {
|
|
15
16
|
try {
|
|
16
17
|
_fs.default.accessSync(file, _fs.default.constants.F_OK);
|
|
@@ -49,6 +50,8 @@ function deleteFile(filePath) {
|
|
|
49
50
|
} catch (err) {
|
|
50
51
|
throw new Error(`Error while deleting the test data file: ${filePath}`);
|
|
51
52
|
}
|
|
53
|
+
} else {
|
|
54
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `File Does not Exist in the path ${filePath}`);
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
function deleteFolder(folderPath) {
|
package/build/utils/rootPath.js
CHANGED
|
@@ -12,24 +12,31 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
12
12
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
13
|
var _logger = require("./logger");
|
|
14
14
|
var _getFilePath = _interopRequireDefault(require("./getFilePath"));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
// TODO: Publish and check this change of finding package.json working fine.
|
|
16
|
+
function findPath(directory, pathToFind) {
|
|
17
|
+
const filePath = _path.default.join(directory, pathToFind);
|
|
18
|
+
if (_fs.default.existsSync(filePath)) {
|
|
19
|
+
return filePath;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
// Recursively search parent directories. Might be time-consuming ?? Can we look for npm module like which?
|
|
22
21
|
const parentDir = _path.default.dirname(directory);
|
|
23
22
|
if (parentDir === directory) {
|
|
24
23
|
return null;
|
|
25
24
|
}
|
|
26
|
-
return
|
|
25
|
+
return findPath(parentDir, pathToFind);
|
|
26
|
+
}
|
|
27
|
+
function findPackageJSON(startDir) {
|
|
28
|
+
return findPath(startDir, 'package.json');
|
|
29
|
+
}
|
|
30
|
+
function findBinaryPath(directory, command) {
|
|
31
|
+
const binaryPath = _path.default.join('.bin', (0, _getFilePath.default)(command));
|
|
32
|
+
return findPath(directory, binaryPath);
|
|
27
33
|
}
|
|
28
34
|
function getRootPath() {
|
|
29
|
-
return _path.default.resolve(__dirname
|
|
35
|
+
return findPackageJSON(_path.default.resolve(__dirname));
|
|
30
36
|
}
|
|
31
37
|
function getRootNodeModulesPath() {
|
|
32
|
-
|
|
38
|
+
const rootPath = getRootPath();
|
|
39
|
+
return _path.default.resolve(_path.default.dirname(rootPath), 'node_modules');
|
|
33
40
|
}
|
|
34
41
|
function getBinPath(command) {
|
|
35
42
|
const packageNodeModulesPath = getRootNodeModulesPath();
|
package/changelog.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Testing Framework
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
|
+
|
|
5
|
+
# 0.1.9
|
|
6
|
+
**Enhancements**
|
|
7
|
+
- Added option to specify browsers in command line.
|
|
8
|
+
- npm run uat -- --browsers='chrome,firefox'
|
|
9
|
+
- Playwright version updated to 1.41.1
|
|
10
|
+
- Added option to Skip Browser download
|
|
11
|
+
- Added New Command re-run-failed to run only the failed cases
|
|
12
|
+
**Major Change**
|
|
13
|
+
- Default fixtures moved inside the library.(Page, Context, i18N, unauthenticatedPage)
|
|
14
|
+
**Internal Library Change**
|
|
15
|
+
Examples folder updated to latest testing library version.
|
|
16
|
+
|
|
4
17
|
# 0.1.8
|
|
5
18
|
**Issue Fixes**
|
|
6
19
|
- Fix #9 Custom report generate Error on Windows
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -2074,11 +2074,11 @@
|
|
|
2074
2074
|
"integrity": "sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q=="
|
|
2075
2075
|
},
|
|
2076
2076
|
"@playwright/test": {
|
|
2077
|
-
"version": "1.
|
|
2078
|
-
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.
|
|
2079
|
-
"integrity": "sha512-
|
|
2077
|
+
"version": "1.42.1",
|
|
2078
|
+
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.42.1.tgz",
|
|
2079
|
+
"integrity": "sha512-Gq9rmS54mjBL/7/MvBaNOBwbfnh7beHvS6oS4srqXFcQHpQCV1+c8JXWE8VLPyRDhgS3H8x8A7hztqI9VnwrAQ==",
|
|
2080
2080
|
"requires": {
|
|
2081
|
-
"playwright": "1.
|
|
2081
|
+
"playwright": "1.42.1"
|
|
2082
2082
|
}
|
|
2083
2083
|
},
|
|
2084
2084
|
"@sinclair/typebox": {
|
|
@@ -5387,18 +5387,18 @@
|
|
|
5387
5387
|
}
|
|
5388
5388
|
},
|
|
5389
5389
|
"playwright": {
|
|
5390
|
-
"version": "1.
|
|
5391
|
-
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.
|
|
5392
|
-
"integrity": "sha512-
|
|
5390
|
+
"version": "1.42.1",
|
|
5391
|
+
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.42.1.tgz",
|
|
5392
|
+
"integrity": "sha512-PgwB03s2DZBcNRoW+1w9E+VkLBxweib6KTXM0M3tkiT4jVxKSi6PmVJ591J+0u10LUrgxB7dLRbiJqO5s2QPMg==",
|
|
5393
5393
|
"requires": {
|
|
5394
5394
|
"fsevents": "2.3.2",
|
|
5395
|
-
"playwright-core": "1.
|
|
5395
|
+
"playwright-core": "1.42.1"
|
|
5396
5396
|
}
|
|
5397
5397
|
},
|
|
5398
5398
|
"playwright-core": {
|
|
5399
|
-
"version": "1.
|
|
5400
|
-
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.
|
|
5401
|
-
"integrity": "sha512
|
|
5399
|
+
"version": "1.42.1",
|
|
5400
|
+
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.42.1.tgz",
|
|
5401
|
+
"integrity": "sha512-mxz6zclokgrke9p1vtdy/COWBH+eOZgYUVVU34C73M+4j4HLlQJHtfcqiqqxpP0o8HhMkflvfbquLX5dg6wlfA=="
|
|
5402
5402
|
},
|
|
5403
5403
|
"pretty-format": {
|
|
5404
5404
|
"version": "29.7.0",
|
|
@@ -6133,6 +6133,12 @@
|
|
|
6133
6133
|
"is-typed-array": "^1.1.9"
|
|
6134
6134
|
}
|
|
6135
6135
|
},
|
|
6136
|
+
"typescript": {
|
|
6137
|
+
"version": "5.4.2",
|
|
6138
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
|
|
6139
|
+
"integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
|
|
6140
|
+
"dev": true
|
|
6141
|
+
},
|
|
6136
6142
|
"unbox-primitive": {
|
|
6137
6143
|
"version": "1.0.2",
|
|
6138
6144
|
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@babel/preset-react": "7.22.5",
|
|
24
24
|
"@cucumber/cucumber": "9.2.0",
|
|
25
|
-
"@playwright/test": "1.
|
|
25
|
+
"@playwright/test": "1.42.1",
|
|
26
26
|
"@testing-library/jest-dom": "5.11.9",
|
|
27
27
|
"@testing-library/react": "11.2.7",
|
|
28
28
|
"@testing-library/react-hooks": "7.0.2",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"jest": "29.6.2",
|
|
33
33
|
"jest-environment-jsdom": "29.6.2",
|
|
34
34
|
"msw": "1.2.3",
|
|
35
|
-
"playwright": "1.
|
|
35
|
+
"playwright": "1.42.1",
|
|
36
|
+
"supports-color": "8.1.1"
|
|
36
37
|
},
|
|
37
38
|
"bin": {
|
|
38
39
|
"ZDTestingFramework": "./bin/cli.js"
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"@babel/polyfill": "7.12.1",
|
|
51
52
|
"@babel/preset-env": "7.22.15",
|
|
52
53
|
"@babel/runtime": "7.22.15",
|
|
53
|
-
"commander": "^11.0.0"
|
|
54
|
+
"commander": "^11.0.0",
|
|
55
|
+
"typescript": "^5.4.2"
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getPlaywrightConfigDir = getPlaywrightConfigDir;
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _loadConfig = require("../playwright/loadConfig");
|
|
10
|
-
var _options = require("../cli/options");
|
|
11
|
-
/**
|
|
12
|
-
* Store playwright config dir in env to provide access to it in workers.
|
|
13
|
-
* Important that in workers there is different process.argv, that's why we save it to env.
|
|
14
|
-
* Config dir is needed to resolve all paths.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Resolve playwright config dir considering cli flags.
|
|
19
|
-
*/
|
|
20
|
-
function getPlaywrightConfigDir() {
|
|
21
|
-
if (!process.env.PLAYWRIGHT_BDD_CONFIG_DIR) {
|
|
22
|
-
const cliConfigPath = (0, _options.getCliConfigPath)();
|
|
23
|
-
const playwrightConfigFile = (0, _loadConfig.resolveConfigFile)(cliConfigPath);
|
|
24
|
-
process.env.PLAYWRIGHT_BDD_CONFIG_DIR = playwrightConfigFile ? _path.default.dirname(playwrightConfigFile) : process.cwd();
|
|
25
|
-
}
|
|
26
|
-
return process.env.PLAYWRIGHT_BDD_CONFIG_DIR;
|
|
27
|
-
}
|