@zohodesk/testinglibrary 0.0.5-exp.9 → 0.0.5-n20-experimental
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 +9 -1
- package/.eslintrc.js +31 -0
- package/.gitlab-ci.yml +191 -0
- package/.prettierrc +6 -0
- package/README.md +151 -1
- package/build/common/data-generator/steps/DataGenerator.spec.js +19 -0
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +19 -0
- package/build/common/multi-actor/steps/multiActorHandling.spec.js +26 -0
- package/build/common/searchFake/helpers/rpcRequestHelper.js +41 -0
- package/build/common/searchFake/steps/searchFake.spec.js +26 -0
- package/build/core/dataGenerator/DataGenerator.js +108 -0
- package/build/core/dataGenerator/DataGeneratorError.js +50 -0
- package/build/core/dataGenerator/DataGeneratorHelper.js +49 -0
- package/build/core/jest/preprocessor/jsPreprocessor.js +3 -9
- package/build/core/jest/runner/jest-runner.js +1 -0
- package/build/core/jest/setup/index.js +1 -7
- package/build/core/playwright/builtInFixtures/actorContext.js +75 -0
- 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 +32 -0
- package/build/core/playwright/builtInFixtures/executionContext.js +17 -0
- package/build/core/playwright/builtInFixtures/i18N.js +41 -0
- package/build/core/playwright/builtInFixtures/index.js +46 -0
- package/build/core/playwright/builtInFixtures/page.js +38 -0
- package/build/core/playwright/builtInFixtures/unauthenticatedPage.js +18 -0
- package/build/core/playwright/clear-caches.js +49 -0
- package/build/core/playwright/codegen.js +5 -6
- package/build/core/playwright/configuration/Configuration.js +25 -0
- package/build/core/playwright/configuration/ConfigurationHelper.js +43 -0
- package/build/core/playwright/configuration/UserArgs.js +12 -0
- package/build/core/playwright/constants/browserTypes.js +12 -0
- package/build/core/playwright/constants/fileMutexConfig.js +9 -0
- package/build/core/playwright/custom-commands.js +1 -2
- package/build/core/playwright/env-initializer.js +28 -6
- package/build/core/playwright/fixtures.js +24 -0
- package/build/core/playwright/helpers/additionalProfiles.js +25 -0
- package/build/core/playwright/helpers/auth/accountLogin.js +21 -0
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +41 -0
- package/build/core/playwright/helpers/auth/getUrlOrigin.js +13 -0
- package/build/core/playwright/helpers/auth/getUsers.js +118 -0
- package/build/core/playwright/helpers/auth/index.js +76 -0
- package/build/core/playwright/helpers/auth/loginDefaultStepsHelper.js +54 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +50 -0
- package/build/core/playwright/helpers/checkAuthDirectory.js +27 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +31 -0
- package/build/core/playwright/helpers/customFixturesHelper.js +58 -0
- package/build/core/playwright/helpers/fileMutex.js +71 -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 +10 -0
- package/build/core/playwright/index.js +10 -89
- package/build/core/playwright/readConfigFile.js +97 -14
- package/build/core/playwright/report-generator.js +9 -10
- package/build/core/playwright/runner/Runner.js +22 -0
- package/build/core/playwright/runner/RunnerHelper.js +43 -0
- package/build/core/playwright/runner/RunnerTypes.js +17 -0
- package/build/core/playwright/runner/SpawnRunner.js +113 -0
- package/build/core/playwright/setup/config-creator.js +101 -90
- package/build/core/playwright/setup/config-utils.js +188 -0
- package/build/core/playwright/setup/custom-reporter.js +136 -0
- package/build/core/playwright/setup/qc-custom-reporter.js +291 -0
- package/build/core/playwright/tagProcessor.js +69 -0
- package/build/core/playwright/test-runner.js +84 -67
- package/build/core/playwright/types.js +44 -0
- package/build/core/playwright/validateFeature.js +28 -0
- package/build/decorators.d.ts +1 -0
- package/build/decorators.js +16 -0
- package/build/index.d.ts +78 -0
- package/build/index.js +73 -5
- package/build/lib/cli.js +38 -5
- package/build/lib/post-install.js +19 -11
- package/build/lint/index.js +3 -6
- package/build/parser/parser.js +205 -0
- package/build/parser/sample.feature +34 -0
- package/build/parser/sample.spec.js +37 -0
- package/build/parser/verifier.js +130 -0
- package/build/setup-folder-structure/helper.js +37 -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/accountLogin-sample.js +19 -0
- package/build/setup-folder-structure/samples/actors-index.js +2 -0
- package/build/setup-folder-structure/samples/auth-setup-sample.js +15 -0
- package/build/setup-folder-structure/samples/editions-index.js +3 -0
- package/build/setup-folder-structure/samples/free-sample.json +25 -0
- package/build/setup-folder-structure/samples/git-ignore.sample.js +37 -0
- package/build/setup-folder-structure/samples/settings.json +7 -0
- package/build/setup-folder-structure/samples/testSetup-sample.js +14 -0
- package/build/setup-folder-structure/samples/uat-config-sample.js +46 -0
- package/build/setup-folder-structure/setupProject.js +36 -18
- package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
- package/build/test/core/playwright/__tests__/validateFeature.test.js +69 -0
- package/build/test/core/playwright/buildInFixtures/__tests__/executionContext.test.js +27 -0
- package/build/test/core/playwright/configuration/__tests__/Configuration.test.js +53 -0
- package/build/test/core/playwright/helpers/__tests__/additionalProfiles.test.js +45 -0
- package/build/test/core/playwright/helpers/__tests__/configFileNameProvider.test.js +34 -0
- package/build/test/core/playwright/helpers/__tests__/customFixturesHelper.test.js +51 -0
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +79 -0
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +80 -0
- package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +16 -0
- package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +27 -0
- package/build/utils/cliArgsToObject.js +9 -1
- package/build/utils/commonUtils.js +17 -0
- package/build/utils/fileUtils.js +109 -0
- package/build/utils/logger.js +7 -35
- package/build/utils/rootPath.js +16 -9
- package/build/utils/stepDefinitionsFormatter.js +11 -0
- package/changelog.md +136 -10
- package/jest.config.js +29 -11
- package/npm-shrinkwrap.json +10241 -6175
- package/package.json +40 -26
- package/playwright.config.js +5 -55
- package/test-results/.last-run.json +4 -0
- package/unit_reports/unit-report.html +277 -0
- package/build/bdd-framework/cli/commands/env.js +0 -44
- package/build/bdd-framework/cli/commands/export.js +0 -47
- package/build/bdd-framework/cli/commands/test.js +0 -60
- package/build/bdd-framework/cli/index.js +0 -11
- package/build/bdd-framework/cli/options.js +0 -21
- package/build/bdd-framework/cli/worker.js +0 -13
- package/build/bdd-framework/config/dir.js +0 -27
- package/build/bdd-framework/config/env.js +0 -49
- package/build/bdd-framework/config/index.js +0 -92
- package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -45
- package/build/bdd-framework/cucumber/gherkin.d.ts +0 -45
- package/build/bdd-framework/cucumber/loadConfig.js +0 -17
- package/build/bdd-framework/cucumber/loadFeatures.js +0 -39
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
- package/build/bdd-framework/cucumber/loadSources.js +0 -58
- package/build/bdd-framework/cucumber/loadSteps.js +0 -41
- package/build/bdd-framework/decorators.js +0 -21
- package/build/bdd-framework/gen/formatter.js +0 -92
- package/build/bdd-framework/gen/i18n.js +0 -44
- package/build/bdd-framework/gen/index.js +0 -150
- package/build/bdd-framework/gen/poms.js +0 -47
- package/build/bdd-framework/gen/testFile.js +0 -356
- package/build/bdd-framework/gen/testNode.js +0 -50
- package/build/bdd-framework/index.js +0 -33
- package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -103
- package/build/bdd-framework/playwright/getLocationInFile.js +0 -50
- package/build/bdd-framework/playwright/loadConfig.js +0 -42
- package/build/bdd-framework/playwright/testTypeImpl.js +0 -47
- package/build/bdd-framework/playwright/transform.js +0 -85
- package/build/bdd-framework/playwright/utils.js +0 -24
- package/build/bdd-framework/run/bddFixtures.js +0 -109
- package/build/bdd-framework/run/bddWorld.js +0 -91
- package/build/bdd-framework/snippets/index.js +0 -132
- package/build/bdd-framework/snippets/snippetSyntax.js +0 -50
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -32
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
- package/build/bdd-framework/stepDefinitions/createBdd.js +0 -52
- package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -110
- package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
- package/build/bdd-framework/utils/index.js +0 -52
- package/build/bdd-framework/utils/jsStringWrap.js +0 -44
- package/build/bdd-framework/utils/logger.js +0 -21
- package/build/setup-folder-structure/env-config-sample.json +0 -17
- package/build/setup-folder-structure/uat-config-sample.js +0 -31
- package/build/setup-folder-structure/user-example.json +0 -3
|
@@ -7,100 +7,111 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _test = require("@playwright/test");
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _bddFramework = require("../../../bdd-framework");
|
|
11
10
|
var _readConfigFile = require("../readConfigFile");
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
// @ts-check
|
|
15
|
-
|
|
16
|
-
const numOfCpus = (0, _os.cpus)().length;
|
|
17
|
-
const defaultBrowser = ['Chrome'];
|
|
11
|
+
var _configUtils = require("./config-utils");
|
|
12
|
+
const uatConfig = (0, _readConfigFile.generateConfigFromFile)();
|
|
18
13
|
const {
|
|
19
|
-
browsers
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
browsers,
|
|
15
|
+
isSmokeTest,
|
|
16
|
+
trace,
|
|
17
|
+
video,
|
|
22
18
|
isAuthMode,
|
|
23
19
|
openReportOn,
|
|
24
|
-
reportPath
|
|
25
|
-
bddMode
|
|
26
|
-
expectTimeout
|
|
27
|
-
testTimeout
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
20
|
+
reportPath,
|
|
21
|
+
bddMode,
|
|
22
|
+
expectTimeout,
|
|
23
|
+
testTimeout,
|
|
24
|
+
authFilePath,
|
|
25
|
+
viewport,
|
|
26
|
+
featureFilesFolder,
|
|
27
|
+
stepDefinitionsFolder,
|
|
28
|
+
testIdAttribute,
|
|
29
|
+
globalTimeout,
|
|
30
|
+
customReporter
|
|
31
|
+
} = uatConfig;
|
|
32
|
+
const projects = (0, _configUtils.getProjects)({
|
|
33
|
+
browsers,
|
|
34
|
+
isAuthMode,
|
|
35
|
+
isSmokeTest,
|
|
36
|
+
authFilePath,
|
|
37
|
+
expectTimeout,
|
|
38
|
+
testTimeout,
|
|
39
|
+
viewport
|
|
40
|
+
});
|
|
41
|
+
const testDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
42
|
+
featureFilesFolder: (0, _configUtils.getPathsForFeatureFiles)(process.cwd()),
|
|
43
|
+
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
44
|
+
outputDir: _path.default.join(process.cwd(), 'uat', '.features-gen'),
|
|
45
|
+
uatPath: _path.default.join(process.cwd(), 'uat')
|
|
46
|
+
});
|
|
47
|
+
const use = {
|
|
48
|
+
trace,
|
|
49
|
+
video,
|
|
50
|
+
viewport,
|
|
51
|
+
testIdAttribute
|
|
52
|
+
};
|
|
53
|
+
let reporter = [['html', {
|
|
54
|
+
outputFolder: reportPath,
|
|
55
|
+
open: openReportOn
|
|
56
|
+
}], ['list'], ['json', {
|
|
57
|
+
outputFile: _path.default.join(process.cwd(), 'uat', 'test-results', 'playwright-test-results.json')
|
|
58
|
+
}], ['./custom-reporter.js'], ['./qc-custom-reporter.js']];
|
|
59
|
+
if (customReporter) {
|
|
60
|
+
reporter = [customReporter, ...reporter];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Playwright configuration object
|
|
65
|
+
*
|
|
66
|
+
* @returns {import('@playwright/test').PlaywrightTestConfig}
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
function getPlaywrightConfig() {
|
|
70
|
+
const commonConfig = {
|
|
71
|
+
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
72
|
+
};
|
|
73
|
+
const dependencies = isAuthMode ? ['setup'] : [];
|
|
74
|
+
const smokeTestProject = isSmokeTest ? smokeTestConfig() : [];
|
|
75
|
+
function smokeTestConfig() {
|
|
76
|
+
const smokeTestDir = (0, _configUtils.getTestDir)(bddMode, {
|
|
77
|
+
featureFilesFolder: _path.default.join(process.cwd(), 'uat', 'smokeTest', '**', '*.feature'),
|
|
78
|
+
stepDefinitionsFolder: _path.default.join(process.cwd(), 'uat', '**', 'steps', '*.spec.js'),
|
|
79
|
+
outputDir: _path.default.join(process.cwd(), 'uat', '.features-smoke-gen'),
|
|
80
|
+
uatPath: _path.default.join(process.cwd(), 'uat', 'smokeTest')
|
|
81
|
+
});
|
|
82
|
+
return [{
|
|
83
|
+
name: 'smokeTest',
|
|
84
|
+
testDir: smokeTestDir,
|
|
59
85
|
use: {
|
|
60
|
-
...
|
|
61
|
-
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), 'playwright/.auth/user.json')) : {}
|
|
86
|
+
...commonConfig
|
|
62
87
|
},
|
|
63
|
-
dependencies:
|
|
64
|
-
|
|
88
|
+
dependencies: dependencies,
|
|
89
|
+
retries: 0
|
|
90
|
+
}];
|
|
65
91
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
video: video ? {
|
|
93
|
-
mode: 'on',
|
|
94
|
-
size: {
|
|
95
|
-
width: 640,
|
|
96
|
-
height: 480
|
|
97
|
-
}
|
|
98
|
-
} : 'off'
|
|
99
|
-
},
|
|
100
|
-
projects: isAuthMode ? [{
|
|
101
|
-
name: 'setup',
|
|
102
|
-
testMatch: /.*\.setup\.js/,
|
|
103
|
-
testDir: _path.default.join(_path.default.resolve(process.cwd()), 'uat')
|
|
104
|
-
}, ...projects] : [...projects]
|
|
105
|
-
});
|
|
106
|
-
exports.default = _default;
|
|
92
|
+
const playwrightConfig = {
|
|
93
|
+
testDir,
|
|
94
|
+
globalTimeout: globalTimeout || 3600000,
|
|
95
|
+
outputDir: _path.default.join(process.cwd(), 'uat', 'test-results'),
|
|
96
|
+
fullyParallel: true,
|
|
97
|
+
reporter,
|
|
98
|
+
timeout: testTimeout,
|
|
99
|
+
expect: {
|
|
100
|
+
timeout: expectTimeout
|
|
101
|
+
},
|
|
102
|
+
use,
|
|
103
|
+
projects: isAuthMode ? [{
|
|
104
|
+
name: 'setup',
|
|
105
|
+
testMatch: /.*\.setup\.js/,
|
|
106
|
+
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
107
|
+
teardown: 'cleanup'
|
|
108
|
+
}, ...smokeTestProject, {
|
|
109
|
+
name: 'cleanup',
|
|
110
|
+
testMatch: /.*\.teardown\.js/,
|
|
111
|
+
testDir: _path.default.join(process.cwd(), 'uat')
|
|
112
|
+
}, ...projects] : [...projects, ...smokeTestProject],
|
|
113
|
+
...uatConfig
|
|
114
|
+
};
|
|
115
|
+
return playwrightConfig;
|
|
116
|
+
}
|
|
117
|
+
var _default = exports.default = (0, _test.defineConfig)(getPlaywrightConfig());
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getBrowsersList = getBrowsersList;
|
|
8
|
+
exports.getModulePathForFeatureFiles = getModulePathForFeatureFiles;
|
|
9
|
+
exports.getPathsForFeatureFiles = getPathsForFeatureFiles;
|
|
10
|
+
exports.getProjects = getProjects;
|
|
11
|
+
exports.getTestDir = getTestDir;
|
|
12
|
+
var _test = require("@playwright/test");
|
|
13
|
+
var _path = _interopRequireDefault(require("path"));
|
|
14
|
+
var _readConfigFile = require("../readConfigFile");
|
|
15
|
+
var _playwrightBdd = require("playwright-bdd");
|
|
16
|
+
var _logger = require("../../../utils/logger");
|
|
17
|
+
var _browserTypes = require("../constants/browserTypes");
|
|
18
|
+
var _fileUtils = require("../../../utils/fileUtils");
|
|
19
|
+
/**
|
|
20
|
+
** Playwright project configuration
|
|
21
|
+
* @returns {import('@playwright/test').Project}
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function getBrowserConfig({
|
|
25
|
+
browserName,
|
|
26
|
+
isAuthMode,
|
|
27
|
+
isSmokeTest,
|
|
28
|
+
authFilePath,
|
|
29
|
+
expectTimeout,
|
|
30
|
+
testTimeout,
|
|
31
|
+
viewport
|
|
32
|
+
}) {
|
|
33
|
+
const browser = browserName.toLowerCase();
|
|
34
|
+
const commonConfig = {
|
|
35
|
+
viewport,
|
|
36
|
+
storageState: isAuthMode ? (0, _readConfigFile.getAuthFilePath)(_path.default.resolve(process.cwd(), authFilePath)) : {}
|
|
37
|
+
};
|
|
38
|
+
// Determine dependencies based on the mode and smoke test status
|
|
39
|
+
let dependencies = isAuthMode ? ['setup'] : [];
|
|
40
|
+
dependencies = isSmokeTest ? [...dependencies, 'smokeTest'] : dependencies;
|
|
41
|
+
if (browser === 'chrome') {
|
|
42
|
+
return {
|
|
43
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.CHROME,
|
|
44
|
+
use: {
|
|
45
|
+
..._test.devices['Desktop Chrome'],
|
|
46
|
+
...commonConfig
|
|
47
|
+
},
|
|
48
|
+
dependencies,
|
|
49
|
+
timeout: testTimeout,
|
|
50
|
+
expect: {
|
|
51
|
+
timeout: expectTimeout
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
} else if (browser === 'edge') {
|
|
55
|
+
return {
|
|
56
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.EDGE,
|
|
57
|
+
timeout: testTimeout,
|
|
58
|
+
expect: {
|
|
59
|
+
timeout: expectTimeout
|
|
60
|
+
},
|
|
61
|
+
use: {
|
|
62
|
+
..._test.devices['Desktop Chrome'],
|
|
63
|
+
channel: 'msedge',
|
|
64
|
+
...commonConfig
|
|
65
|
+
},
|
|
66
|
+
dependencies
|
|
67
|
+
};
|
|
68
|
+
} else if (browser === 'firefox') {
|
|
69
|
+
return {
|
|
70
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.FIREFOX,
|
|
71
|
+
timeout: 2 * testTimeout,
|
|
72
|
+
expect: {
|
|
73
|
+
timeout: 2 * expectTimeout
|
|
74
|
+
},
|
|
75
|
+
use: {
|
|
76
|
+
..._test.devices['Desktop Firefox'],
|
|
77
|
+
...commonConfig
|
|
78
|
+
},
|
|
79
|
+
dependencies
|
|
80
|
+
};
|
|
81
|
+
} else if (browser === 'safari') {
|
|
82
|
+
return {
|
|
83
|
+
name: _browserTypes.BROWSER_PROJECT_MAPPING.SAFARI,
|
|
84
|
+
timeout: 4 * testTimeout,
|
|
85
|
+
expect: {
|
|
86
|
+
timeout: 4 * expectTimeout
|
|
87
|
+
},
|
|
88
|
+
use: {
|
|
89
|
+
..._test.devices['Desktop Safari'],
|
|
90
|
+
...commonConfig
|
|
91
|
+
},
|
|
92
|
+
dependencies
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
* @param {*} param0
|
|
102
|
+
* @returns {import('@playwright/test').Project[]}
|
|
103
|
+
*/
|
|
104
|
+
function getProjects({
|
|
105
|
+
browsers,
|
|
106
|
+
isAuthMode,
|
|
107
|
+
isSmokeTest,
|
|
108
|
+
authFilePath,
|
|
109
|
+
expectTimeout,
|
|
110
|
+
testTimeout,
|
|
111
|
+
viewport
|
|
112
|
+
}) {
|
|
113
|
+
return browsers.map(browserName => getBrowserConfig({
|
|
114
|
+
browserName,
|
|
115
|
+
isAuthMode,
|
|
116
|
+
isSmokeTest,
|
|
117
|
+
authFilePath,
|
|
118
|
+
expectTimeout,
|
|
119
|
+
testTimeout,
|
|
120
|
+
viewport
|
|
121
|
+
})).filter(Boolean);
|
|
122
|
+
}
|
|
123
|
+
function getBrowsersList(browserFromArgs) {
|
|
124
|
+
if (browserFromArgs) {
|
|
125
|
+
if (typeof browserFromArgs === 'string') {
|
|
126
|
+
let listOfbrowsers = browserFromArgs.split(',').map(browser => browser.trim().toLowerCase());
|
|
127
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Using browsers from command line args');
|
|
128
|
+
return listOfbrowsers;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
function getPathsForFeatureFiles(cwd) {
|
|
134
|
+
if (process.env.isRerunFailedCases) {
|
|
135
|
+
let {
|
|
136
|
+
reportPath
|
|
137
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
138
|
+
let filePathFromArgs = process.env.filePath;
|
|
139
|
+
let filePath = filePathFromArgs ? filePathFromArgs : reportPath;
|
|
140
|
+
const testSummary = (0, _fileUtils.readFileContents)(filePath);
|
|
141
|
+
if (testSummary !== null) {
|
|
142
|
+
const {
|
|
143
|
+
failed = []
|
|
144
|
+
} = JSON.parse(testSummary);
|
|
145
|
+
const casesToRun = failed.map(filePath => _path.default.join(cwd, 'uat', filePath.replace(/\.spec\.js$|\.js$/, '')));
|
|
146
|
+
return casesToRun;
|
|
147
|
+
} else {
|
|
148
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `Unable to read test summary from the ${reportPath}. Verify If File Exists in the path`);
|
|
149
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Going to run all test cases');
|
|
150
|
+
}
|
|
151
|
+
} else if (process.env.modules !== 'undefined' && process.env.modules.length > 0) {
|
|
152
|
+
let modules = process.env.modules;
|
|
153
|
+
let moduleList = modules.split(',');
|
|
154
|
+
return getModulePathForFeatureFiles(moduleList);
|
|
155
|
+
}
|
|
156
|
+
return [_path.default.join(cwd, 'uat', 'modules', '**', '*.feature')];
|
|
157
|
+
}
|
|
158
|
+
function getModulePathForFeatureFiles(moduleList) {
|
|
159
|
+
let validModuleList = [];
|
|
160
|
+
moduleList.forEach(moduleName => {
|
|
161
|
+
let modulePath = _path.default.join(process.cwd(), 'uat', 'modules', '**', `${moduleName}`);
|
|
162
|
+
if ((0, _fileUtils.checkIfFolderExistsWithPattern)(modulePath)) {
|
|
163
|
+
validModuleList.push(_path.default.join(modulePath, '**', '*.feature'));
|
|
164
|
+
} else {
|
|
165
|
+
validModuleList = [];
|
|
166
|
+
throw new Error(`Module ${moduleName} does not exist. We have not triggered the execution for this module`);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return validModuleList;
|
|
170
|
+
}
|
|
171
|
+
function getTestDir(bddMode, {
|
|
172
|
+
featureFilesFolder,
|
|
173
|
+
stepDefinitionsFolder,
|
|
174
|
+
outputDir,
|
|
175
|
+
uatPath
|
|
176
|
+
}) {
|
|
177
|
+
return bddMode ? (0, _playwrightBdd.defineBddConfig)({
|
|
178
|
+
features: featureFilesFolder,
|
|
179
|
+
steps: [stepDefinitionsFolder, require.resolve('../fixtures.js')],
|
|
180
|
+
importTestFrom: require.resolve('../fixtures.js'),
|
|
181
|
+
featuresRoot: uatPath,
|
|
182
|
+
outputDir: outputDir,
|
|
183
|
+
disableWarnings: {
|
|
184
|
+
importTestFrom: true
|
|
185
|
+
},
|
|
186
|
+
publish: true
|
|
187
|
+
}) : uatPath;
|
|
188
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
var _configFileNameProvider = require("../helpers/configFileNameProvider");
|
|
14
|
+
class JSONSummaryReporter {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.durationInMS = -1;
|
|
17
|
+
this.passed = [];
|
|
18
|
+
this.skipped = [];
|
|
19
|
+
this.failed = [];
|
|
20
|
+
this.warned = [];
|
|
21
|
+
this.errored = [];
|
|
22
|
+
this.interrupted = [];
|
|
23
|
+
this.timedOut = [];
|
|
24
|
+
this.flakey = [];
|
|
25
|
+
this.failedSteps = [];
|
|
26
|
+
this.status = 'unknown';
|
|
27
|
+
this.startedAt = 0;
|
|
28
|
+
this._open = (0, _readConfigFile.generateConfigFromFile)().openReportOn;
|
|
29
|
+
}
|
|
30
|
+
onBegin() {
|
|
31
|
+
this.startedAt = Date.now();
|
|
32
|
+
}
|
|
33
|
+
getTitle(test) {
|
|
34
|
+
const title = [];
|
|
35
|
+
const fileName = [];
|
|
36
|
+
let clean = true;
|
|
37
|
+
for (const s of test.titlePath()) {
|
|
38
|
+
if (s === '' && clean) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
clean = false;
|
|
42
|
+
title.push(s);
|
|
43
|
+
if (s.endsWith('.ts') || s.endsWith('.js')) {
|
|
44
|
+
fileName.push(s);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//Using the fullTitle variable in the push will push a full test name + test description
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
fullTitle: title.join(' > '),
|
|
52
|
+
fileName: fileName[0] || ''
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
onTestEnd(test, result) {
|
|
56
|
+
const {
|
|
57
|
+
fullTitle,
|
|
58
|
+
fileName
|
|
59
|
+
} = this.getTitle(test);
|
|
60
|
+
|
|
61
|
+
// Set the status
|
|
62
|
+
const stepTitleList = result.steps.filter(step => step.error).map(step => ({
|
|
63
|
+
title: step.title,
|
|
64
|
+
error: step.error,
|
|
65
|
+
testTitle: fullTitle
|
|
66
|
+
}));
|
|
67
|
+
if (stepTitleList.length > 0) {
|
|
68
|
+
this.failedSteps = [...this.failedSteps, ...stepTitleList];
|
|
69
|
+
}
|
|
70
|
+
const status = !['passed', 'skipped'].includes(result.status) && fullTitle.includes('@warn') ? 'warned' : result.status;
|
|
71
|
+
// Logic to push the results into the correct array
|
|
72
|
+
if (result.status === 'passed' && result.retry >= 1) {
|
|
73
|
+
this.flakey.push(fileName);
|
|
74
|
+
} else {
|
|
75
|
+
this[status].push(fileName);
|
|
76
|
+
}
|
|
77
|
+
this[status].push(fileName);
|
|
78
|
+
}
|
|
79
|
+
onError(error) {
|
|
80
|
+
this.errored.push({
|
|
81
|
+
error: error.message,
|
|
82
|
+
stack: error.stack
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
onEnd(result) {
|
|
86
|
+
this.durationInMS = Date.now() - this.startedAt;
|
|
87
|
+
this.status = result.status;
|
|
88
|
+
|
|
89
|
+
// removing duplicate tests from passed array
|
|
90
|
+
this.passed = this.passed.filter((element, index) => {
|
|
91
|
+
return this.passed.indexOf(element) === index;
|
|
92
|
+
});
|
|
93
|
+
// removing duplicate tests from the failed array
|
|
94
|
+
this.failed = this.failed.filter((element, index) => {
|
|
95
|
+
if (!this.passed.includes(element)) {
|
|
96
|
+
return this.failed.indexOf(element) === index;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
// removing duplicate tests from the skipped array
|
|
100
|
+
this.skipped = this.skipped.filter((element, index) => {
|
|
101
|
+
return this.skipped.indexOf(element) === index;
|
|
102
|
+
});
|
|
103
|
+
// removing duplicate tests from the timedOut array
|
|
104
|
+
this.timedOut = this.timedOut.filter((element, index) => {
|
|
105
|
+
return this.timedOut.indexOf(element) === index;
|
|
106
|
+
});
|
|
107
|
+
// removing duplicate tests from the interrupted array
|
|
108
|
+
this.interrupted = this.interrupted.filter((element, index) => {
|
|
109
|
+
return this.interrupted.indexOf(element) === index;
|
|
110
|
+
});
|
|
111
|
+
this.errored = this.errored.filter((element, index) => {
|
|
112
|
+
return this.errored.indexOf(element) === index;
|
|
113
|
+
});
|
|
114
|
+
if (this.errored.length > 0) {
|
|
115
|
+
// Reflect setup failures in the final report status
|
|
116
|
+
this.status = "failed";
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));
|
|
120
|
+
let {
|
|
121
|
+
reportPath
|
|
122
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
123
|
+
(0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', (0, _configFileNameProvider.getReportFileName)()), JSON.stringify(this, null, ' '));
|
|
124
|
+
}
|
|
125
|
+
onExit() {
|
|
126
|
+
const shouldClearLastLine = this._open !== 'always' || this._open !== 'on-failure';
|
|
127
|
+
if (shouldClearLastLine) {
|
|
128
|
+
/**Below code is to replace the playwright default report commond with abstraction tool command */
|
|
129
|
+
_readline.default.moveCursor(process.stdout, 0, -2); // up two line
|
|
130
|
+
_readline.default.clearLine(process.stdout, 1); // from cursor to end
|
|
131
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'npx ZDTestingFramework report or npm run uat-report');
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
var _default = exports.default = JSONSummaryReporter;
|