@zohodesk/testinglibrary 0.1.9 → 0.1.12-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 +4 -2
- package/.claude/settings.local.json +14 -0
- package/.gitlab-ci.yml +206 -0
- package/README.md +264 -1
- package/build/common/data-generator/steps/DataGenerator.spec.js +19 -0
- package/build/common/data-generator/steps/DataGeneratorStepsHelper.js +21 -0
- package/build/common/multi-actor/steps/multiActorHandling.spec.js +26 -0
- package/build/common/searchFake/helpers/rpcRequestHelper.js +52 -0
- package/build/common/searchFake/steps/searchFake.spec.js +85 -0
- package/build/core/dataGenerator/DataGenerator.js +161 -0
- package/build/core/dataGenerator/DataGeneratorError.js +60 -0
- package/build/core/dataGenerator/DataGeneratorHelper.js +121 -0
- package/build/core/dataGenerator/authenticator/Authenticator.js +37 -0
- package/build/core/dataGenerator/authenticator/CookieAuthenticator.js +48 -0
- package/build/core/dataGenerator/authenticator/JWTauthenticator.js +59 -0
- package/build/core/dataGenerator/authenticator/OAuthAuthenticator.js +26 -0
- package/build/core/dataGenerator/authenticator/OrgOAuthAuthenticator.js +26 -0
- package/build/core/dataGenerator/authenticator/cookieAuthConfig.js +11 -0
- package/build/core/jest/preprocessor/jsPreprocessor.js +2 -7
- package/build/core/jest/setup/index.js +1 -7
- package/build/core/playwright/builtInFixtures/actorContext.js +78 -0
- package/build/core/playwright/builtInFixtures/caseTimeout.js +20 -0
- package/build/core/playwright/builtInFixtures/context.js +34 -16
- package/build/core/playwright/builtInFixtures/executionContext.js +17 -0
- package/build/core/playwright/builtInFixtures/i18N.js +8 -0
- package/build/core/playwright/builtInFixtures/index.js +7 -1
- package/build/core/playwright/builtInFixtures/page.js +22 -66
- package/build/core/playwright/clear-caches.js +17 -5
- package/build/core/playwright/codegen.js +4 -21
- package/build/core/playwright/configuration/Configuration.js +25 -0
- package/build/core/playwright/configuration/ConfigurationHelper.js +45 -0
- package/build/core/playwright/configuration/UserArgs.js +12 -0
- package/build/core/playwright/constants/configConstants.js +17 -0
- package/build/core/playwright/constants/failureTagConstants.js +17 -0
- package/build/core/playwright/constants/fileMutexConfig.js +9 -0
- package/build/core/playwright/constants/reporterConstants.js +20 -0
- package/build/core/playwright/constants/retryConstants.js +8 -0
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/env-initializer.js +28 -9
- 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 +4 -1
- package/build/core/playwright/helpers/auth/checkAuthCookies.js +27 -23
- package/build/core/playwright/helpers/auth/getUsers.js +92 -45
- package/build/core/playwright/helpers/auth/index.js +30 -5
- package/build/core/playwright/helpers/auth/loginDefaultStepsHelper.js +62 -0
- package/build/core/playwright/helpers/auth/loginSteps.js +40 -22
- package/build/core/playwright/helpers/browserTimeoutFactor.js +16 -0
- package/build/core/playwright/helpers/caseTimeoutResolver.js +37 -0
- package/build/core/playwright/helpers/checkAuthDirectory.js +27 -0
- package/build/core/playwright/helpers/configFileNameProvider.js +26 -5
- package/build/core/playwright/helpers/configPathResolver.js +38 -0
- package/build/core/playwright/helpers/contextFailureHandler.js +81 -0
- package/build/core/playwright/helpers/customFixturesHelper.js +58 -0
- package/build/core/playwright/helpers/failureTagClassifier.js +197 -0
- package/build/core/playwright/helpers/fileMutex.js +71 -0
- package/build/core/playwright/helpers/logCollector.js +147 -0
- package/build/core/playwright/helpers/parseUserArgs.js +2 -3
- package/build/core/playwright/helpers/runtimeLogAnnotator.js +140 -0
- package/build/core/playwright/helpers/runtimeLogPath.js +61 -0
- package/build/core/playwright/helpers/runtimeLogReader.js +54 -0
- package/build/core/playwright/helpers/thirdPartyLib.js +13 -0
- package/build/core/playwright/index.js +8 -76
- package/build/core/playwright/patterns/casePatterns.js +9 -0
- package/build/core/playwright/patterns/codePatterns.js +9 -0
- package/build/core/playwright/patterns/environmentPatterns.js +15 -0
- package/build/core/playwright/patterns/index.js +33 -0
- package/build/core/playwright/patterns/logCollectorIgnorePatterns.js +15 -0
- package/build/core/playwright/patterns/toolPatterns.js +26 -0
- package/build/core/playwright/readConfigFile.js +49 -16
- package/build/core/playwright/reporter/PlaywrightReporter.js +58 -0
- package/build/core/playwright/reporter/Reporter.js +65 -0
- package/build/core/playwright/reporter/ShardReporter.js +58 -0
- package/build/core/playwright/reporter/UnitReporter.js +27 -0
- package/build/core/playwright/reporter/helpers/mergeAbortedTests.js +78 -0
- 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 +93 -0
- package/build/core/playwright/setup/Project.js +35 -0
- package/build/core/playwright/setup/ProjectConfiguration.js +66 -0
- package/build/core/playwright/setup/config-creator.js +58 -40
- package/build/core/playwright/setup/config-utils.js +68 -37
- package/build/core/playwright/setup/custom-reporter.js +137 -14
- package/build/core/playwright/setup/merge-config.js +32 -0
- package/build/core/playwright/setup/qc-custom-reporter.js +342 -0
- package/build/core/playwright/spawnInheritChild.js +71 -0
- package/build/core/playwright/tagProcessor.js +69 -0
- package/build/core/playwright/test-runner.js +44 -98
- package/build/core/playwright/types.js +4 -1
- package/build/core/playwright/validateFeature.js +28 -0
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +1 -1
- package/build/index.d.ts +17 -19
- package/build/index.js +28 -6
- package/build/lib/cli.js +42 -7
- package/build/setup-folder-structure/helper.js +2 -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 +10 -67
- 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/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 +7 -2
- package/build/setup-folder-structure/setupProject.js +23 -5
- package/build/test/core/dataGenerator/__tests__/DataGenerator.test.js +311 -0
- package/build/test/core/dataGenerator/__tests__/DataGeneratorHelper.test.js +204 -0
- package/build/test/core/dataGenerator/__tests__/DataGeneratorResolution.test.js +126 -0
- package/build/test/core/dataGenerator/authenticator/__tests__/Authenticator.test.js +88 -0
- package/build/test/core/dataGenerator/authenticator/__tests__/JWTauthenticator.test.js +136 -0
- package/build/test/core/dataGenerator/authenticator/__tests__/OAuthAuthenticator.test.js +39 -0
- package/build/test/core/dataGenerator/authenticator/__tests__/OrgOAuthAuthenticator.test.js +39 -0
- package/build/test/core/playwright/__tests__/spawnInheritChild.test.js +148 -0
- package/build/test/core/playwright/__tests__/tagProcessor.test.js +94 -0
- package/build/test/core/playwright/__tests__/validateFeature.test.js +72 -0
- package/build/test/core/playwright/buildInFixtures/__tests__/caseTimeout.test.js +96 -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 +75 -0
- package/build/test/core/playwright/helpers/__tests__/configPathResolver.test.js +55 -0
- package/build/test/core/playwright/helpers/__tests__/customFixturesHelper.test.js +51 -0
- package/build/test/core/playwright/helpers/__tests__/failureTagClassifier.test.js +604 -0
- package/build/test/core/playwright/helpers/__tests__/fileMutex.test.js +79 -0
- package/build/test/core/playwright/helpers/__tests__/getUsers_ListOfActors.test.js +83 -0
- package/build/test/core/playwright/helpers/__tests__/logCollector.test.js +163 -0
- package/build/test/core/playwright/helpers/__tests__/runtimeLogReader.test.js +112 -0
- package/build/test/core/playwright/helpers/auth/__tests__/checkAuthCookies.test.js +92 -0
- package/build/test/core/playwright/runner/__tests__/RunnerHelper.test.js +19 -0
- package/build/test/core/playwright/runner/__tests__/SpawnRunner.test.js +30 -0
- package/build/utils/cliArgsToObject.js +3 -0
- package/build/utils/commonUtils.js +20 -0
- package/build/utils/fileUtils.js +43 -1
- package/build/utils/logger.js +1 -30
- package/changelog.md +23 -0
- package/docs/CODE-REVIEW-AGENT.md +399 -0
- package/docs/code-review-instructions.md +157 -0
- package/jest.config.js +29 -11
- package/npm-shrinkwrap.json +14994 -4793
- package/package.json +39 -28
- package/playwright.config.js +13 -57
- package/unit_reports/unit-report.html +277 -0
- package/build/bdd-framework/cli/commands/env.js +0 -42
- package/build/bdd-framework/cli/commands/export.js +0 -47
- package/build/bdd-framework/cli/commands/test.js +0 -64
- package/build/bdd-framework/cli/index.js +0 -11
- package/build/bdd-framework/cli/options.js +0 -19
- package/build/bdd-framework/cli/worker.js +0 -13
- package/build/bdd-framework/config/configDir.js +0 -35
- package/build/bdd-framework/config/enrichReporterData.js +0 -23
- package/build/bdd-framework/config/env.js +0 -50
- package/build/bdd-framework/config/index.js +0 -94
- package/build/bdd-framework/config/lang.js +0 -14
- package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
- package/build/bdd-framework/cucumber/createTestStep.js +0 -43
- package/build/bdd-framework/cucumber/formatter/EventDataCollector.js +0 -126
- package/build/bdd-framework/cucumber/formatter/GherkinDocumentParser.js +0 -72
- package/build/bdd-framework/cucumber/formatter/PickleParser.js +0 -25
- package/build/bdd-framework/cucumber/formatter/durationHelpers.js +0 -13
- package/build/bdd-framework/cucumber/formatter/getColorFns.js +0 -57
- package/build/bdd-framework/cucumber/formatter/index.js +0 -16
- package/build/bdd-framework/cucumber/formatter/locationHelpers.js +0 -16
- package/build/bdd-framework/cucumber/loadConfig.js +0 -17
- package/build/bdd-framework/cucumber/loadFeatures.js +0 -70
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
- package/build/bdd-framework/cucumber/loadSteps.js +0 -47
- package/build/bdd-framework/cucumber/resolveFeaturePaths.js +0 -62
- package/build/bdd-framework/cucumber/stepArguments.js +0 -21
- package/build/bdd-framework/cucumber/types.js +0 -5
- package/build/bdd-framework/cucumber/valueChecker.js +0 -23
- package/build/bdd-framework/decorators.js +0 -18
- package/build/bdd-framework/gen/fixtures.js +0 -48
- package/build/bdd-framework/gen/formatter.js +0 -123
- package/build/bdd-framework/gen/i18n.js +0 -39
- package/build/bdd-framework/gen/index.js +0 -185
- package/build/bdd-framework/gen/testFile.js +0 -465
- package/build/bdd-framework/gen/testMeta.js +0 -60
- package/build/bdd-framework/gen/testNode.js +0 -60
- package/build/bdd-framework/gen/testPoms.js +0 -133
- package/build/bdd-framework/hooks/scenario.js +0 -130
- package/build/bdd-framework/hooks/worker.js +0 -89
- package/build/bdd-framework/index.js +0 -52
- package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -93
- package/build/bdd-framework/playwright/getLocationInFile.js +0 -79
- package/build/bdd-framework/playwright/loadConfig.js +0 -42
- package/build/bdd-framework/playwright/loadUtils.js +0 -33
- package/build/bdd-framework/playwright/testTypeImpl.js +0 -61
- package/build/bdd-framework/playwright/transform.js +0 -88
- package/build/bdd-framework/playwright/types.js +0 -5
- package/build/bdd-framework/playwright/utils.js +0 -34
- package/build/bdd-framework/reporter/cucumber/base.js +0 -57
- package/build/bdd-framework/reporter/cucumber/custom.js +0 -73
- package/build/bdd-framework/reporter/cucumber/helper.js +0 -12
- package/build/bdd-framework/reporter/cucumber/html.js +0 -35
- package/build/bdd-framework/reporter/cucumber/index.js +0 -74
- package/build/bdd-framework/reporter/cucumber/json.js +0 -312
- package/build/bdd-framework/reporter/cucumber/junit.js +0 -205
- package/build/bdd-framework/reporter/cucumber/message.js +0 -20
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/AttachmentMapper.js +0 -64
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Builder.js +0 -196
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocument.js +0 -43
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocumentClone.js +0 -52
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/GherkinDocuments.js +0 -105
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Hook.js +0 -70
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Meta.js +0 -45
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Pickles.js +0 -27
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/Projects.js +0 -38
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCase.js +0 -128
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRun.js +0 -126
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestCaseRunHooks.js +0 -102
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepAttachments.js +0 -50
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/TestStepRun.js +0 -88
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/index.js +0 -30
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/pwUtils.js +0 -51
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/timing.js +0 -35
- package/build/bdd-framework/reporter/cucumber/messagesBuilder/types.js +0 -5
- package/build/bdd-framework/run/StepInvoker.js +0 -68
- package/build/bdd-framework/run/bddDataAttachment.js +0 -46
- package/build/bdd-framework/run/bddFixtures.js +0 -191
- package/build/bdd-framework/run/bddWorld.js +0 -79
- package/build/bdd-framework/run/bddWorldInternal.js +0 -15
- package/build/bdd-framework/snippets/index.js +0 -132
- package/build/bdd-framework/snippets/snippetSyntax.js +0 -43
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
- package/build/bdd-framework/stepDefinitions/createBdd.js +0 -66
- package/build/bdd-framework/stepDefinitions/decorators/class.js +0 -68
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -99
- package/build/bdd-framework/stepDefinitions/defineStep.js +0 -62
- package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
- package/build/bdd-framework/utils/AutofillMap.js +0 -20
- package/build/bdd-framework/utils/exit.js +0 -62
- package/build/bdd-framework/utils/index.js +0 -93
- package/build/bdd-framework/utils/jsStringWrap.js +0 -44
- package/build/bdd-framework/utils/logger.js +0 -30
- package/build/bdd-framework/utils/stripAnsiEscapes.js +0 -20
- package/build/core/playwright/report-generator.js +0 -42
- package/build/core/playwright/tag-processor.js +0 -68
- package/build/setup-folder-structure/samples/authUsers-sample.json +0 -9
- package/build/setup-folder-structure/samples/env-config-sample.json +0 -21
|
@@ -0,0 +1,342 @@
|
|
|
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 _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _codeFrame = require("@babel/code-frame");
|
|
11
|
+
var _configConstants = _interopRequireDefault(require("../constants/configConstants"));
|
|
12
|
+
var _ConfigurationHelper = require("../configuration/ConfigurationHelper");
|
|
13
|
+
var _readConfigFile = require("../readConfigFile");
|
|
14
|
+
var _failureTagClassifier = require("../helpers/failureTagClassifier");
|
|
15
|
+
const stage = (0, _ConfigurationHelper.getRunStage)();
|
|
16
|
+
const {
|
|
17
|
+
failureSegregation = true
|
|
18
|
+
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
19
|
+
|
|
20
|
+
// Walks the built suite tree and appends derived failure tags (CASE_failure, CODE_failure, ENVIRONMENT_failure) into each spec's tags array.
|
|
21
|
+
const applyFailureTags = suite => {
|
|
22
|
+
for (const spec of suite.specs ?? []) {
|
|
23
|
+
const failureTags = (0, _failureTagClassifier.classifyFailureTags)(spec.tests, spec.title);
|
|
24
|
+
if (failureTags.length > 0) {
|
|
25
|
+
spec.tags = (0, _failureTagClassifier.mergeFailureTags)(spec.tags, failureTags);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const child of suite.suites ?? []) {
|
|
29
|
+
applyFailureTags(child);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
class CustomJsonReporter {
|
|
33
|
+
constructor({
|
|
34
|
+
outputFile = 'test-results.json'
|
|
35
|
+
} = {}) {
|
|
36
|
+
this.outputFile = _path.default.resolve(process.cwd(), _configConstants.default.TEST_SLICE_FOLDER, stage, 'test-results/', outputFile);
|
|
37
|
+
this.rootSuite = null;
|
|
38
|
+
this.report = {
|
|
39
|
+
config: {},
|
|
40
|
+
suites: []
|
|
41
|
+
};
|
|
42
|
+
this.testResultsById = new Map();
|
|
43
|
+
this.failureSegregation = failureSegregation;
|
|
44
|
+
}
|
|
45
|
+
onBegin = (config, suite) => {
|
|
46
|
+
this.rootSuite = suite;
|
|
47
|
+
this.report.config = config;
|
|
48
|
+
};
|
|
49
|
+
onTestEnd(test, result) {
|
|
50
|
+
var _result$errors, _result$steps;
|
|
51
|
+
const key = `${test.location.file}:${test.location.line}:${test.title}`;
|
|
52
|
+
let attachments = result.attachments ?? [];
|
|
53
|
+
if (this.failureSegregation && (0, _failureTagClassifier.isFailingResultStatus)(result.status)) {
|
|
54
|
+
const metadata = (0, _failureTagClassifier.classifyFailureDetailsFromResult)({
|
|
55
|
+
status: result.status,
|
|
56
|
+
workerIndex: result.workerIndex,
|
|
57
|
+
retry: result.retry,
|
|
58
|
+
stdout: result.stdout.map(out => stdioEntry(out)),
|
|
59
|
+
stderr: result.stderr.map(err => stdioEntry(err))
|
|
60
|
+
}, test.title);
|
|
61
|
+
attachments = (0, _failureTagClassifier.upsertFailureTagMetadataAttachment)(attachments, metadata);
|
|
62
|
+
}
|
|
63
|
+
const testResult = {
|
|
64
|
+
status: result.status,
|
|
65
|
+
attachments,
|
|
66
|
+
startTime: result.startTime,
|
|
67
|
+
retry: result.retry,
|
|
68
|
+
stderr: result.stderr.map(err => stdioEntry(err)),
|
|
69
|
+
stdout: result.stdout.map(out => stdioEntry(out)),
|
|
70
|
+
workerIndex: result.workerIndex,
|
|
71
|
+
duration: result.duration,
|
|
72
|
+
error: result.error,
|
|
73
|
+
errors: (_result$errors = result.errors) === null || _result$errors === void 0 ? void 0 : _result$errors.map(processError),
|
|
74
|
+
steps: ((_result$steps = result.steps) === null || _result$steps === void 0 ? void 0 : _result$steps.map(step => extractMergedSteps(this.report.config.rootDir, step))) ?? []
|
|
75
|
+
};
|
|
76
|
+
const existingResults = this.testResultsById.get(key) ?? [];
|
|
77
|
+
this.testResultsById.set(key, [...existingResults, testResult]);
|
|
78
|
+
}
|
|
79
|
+
onEnd() {
|
|
80
|
+
var _this$rootSuite;
|
|
81
|
+
(_this$rootSuite = this.rootSuite) === null || _this$rootSuite === void 0 || (_this$rootSuite = _this$rootSuite.suites) === null || _this$rootSuite === void 0 || _this$rootSuite.map(suite => {
|
|
82
|
+
const extracted = suite.suites.map(suite => extractMergedSuite(this.report.config.rootDir, suite, this.testResultsById));
|
|
83
|
+
this.report.suites.push(...extracted);
|
|
84
|
+
});
|
|
85
|
+
if (this.failureSegregation) {
|
|
86
|
+
this.report.suites.forEach(suite => applyFailureTags(suite));
|
|
87
|
+
}
|
|
88
|
+
const outputDirectory = _path.default.dirname(this.outputFile);
|
|
89
|
+
if (!_fs.default.existsSync(outputDirectory)) {
|
|
90
|
+
_fs.default.mkdirSync(outputDirectory, {
|
|
91
|
+
recursive: true
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const writableStream = _fs.default.createWriteStream(this.outputFile);
|
|
95
|
+
|
|
96
|
+
// Playwright ends the process once onEnd settles. While merging the shard blob
|
|
97
|
+
// reports there is no further work keeping it alive, so the stream has to be
|
|
98
|
+
// flushed before returning. Reject on stream errors so Playwright cannot hang.
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
writableStream.on('error', reject);
|
|
101
|
+
writableStream.write('{\n');
|
|
102
|
+
writableStream.write(` "config": ${JSON.stringify(this.report.config, null, 2)},\n`);
|
|
103
|
+
writableStream.write(' "suites": [\n');
|
|
104
|
+
for (let i = 0; i < this.report.suites.length; i++) {
|
|
105
|
+
const suite = this.report.suites[i];
|
|
106
|
+
let suiteStr = JSON.stringify(suite, null, 2).split('\n').map(line => ' ' + line).join('\n');
|
|
107
|
+
if (i < this.report.suites.length - 1) {
|
|
108
|
+
suiteStr += ',';
|
|
109
|
+
}
|
|
110
|
+
suiteStr += '\n';
|
|
111
|
+
writableStream.write(suiteStr);
|
|
112
|
+
}
|
|
113
|
+
writableStream.write(' ]\n');
|
|
114
|
+
writableStream.write('}\n');
|
|
115
|
+
writableStream.end(() => {
|
|
116
|
+
console.log(`Custom JSON report written to: ${this.outputFile}`);
|
|
117
|
+
resolve();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.default = CustomJsonReporter;
|
|
123
|
+
const extractMergedSuite = (rootDir, suite, testResultsById) => {
|
|
124
|
+
var _suite$suites;
|
|
125
|
+
const specMap = new Map();
|
|
126
|
+
for (const test of suite.tests ?? []) {
|
|
127
|
+
const existingSpec = specMap.get(test.title);
|
|
128
|
+
if (existingSpec) {
|
|
129
|
+
const newTestInfo = extractTestDetails(test, testResultsById);
|
|
130
|
+
existingSpec.tests.push(newTestInfo);
|
|
131
|
+
} else {
|
|
132
|
+
const newSpec = createSpecEntry(rootDir, test, testResultsById);
|
|
133
|
+
specMap.set(test.title, newSpec);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
title: suite.title,
|
|
138
|
+
...parseLocation(rootDir, suite.location),
|
|
139
|
+
...(suite.location && {
|
|
140
|
+
snippet: formSnippet(rootDir, suite.location)
|
|
141
|
+
}),
|
|
142
|
+
...(((_suite$suites = suite.suites) === null || _suite$suites === void 0 ? void 0 : _suite$suites.length) > 0 && {
|
|
143
|
+
suites: suite.suites.map(child => extractMergedSuite(rootDir, child, testResultsById))
|
|
144
|
+
}),
|
|
145
|
+
...(specMap.size > 0 && {
|
|
146
|
+
specs: Array.from(specMap.values())
|
|
147
|
+
})
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
const createSpecEntry = (rootDir, test, testResultsById) => ({
|
|
151
|
+
title: test.title,
|
|
152
|
+
...parseLocation(rootDir, test.location),
|
|
153
|
+
...(test.location && {
|
|
154
|
+
snippet: formSnippet(test.location)
|
|
155
|
+
}),
|
|
156
|
+
tags: test.tags,
|
|
157
|
+
tests: [extractTestDetails(test, testResultsById)]
|
|
158
|
+
});
|
|
159
|
+
const extractTestDetails = (test, testResultsById) => {
|
|
160
|
+
var _test$location, _test$location2;
|
|
161
|
+
const key = `${(_test$location = test.location) === null || _test$location === void 0 ? void 0 : _test$location.file}:${(_test$location2 = test.location) === null || _test$location2 === void 0 ? void 0 : _test$location2.line}:${test.title}`;
|
|
162
|
+
return {
|
|
163
|
+
annotations: test.annotations,
|
|
164
|
+
expectedStatus: test.expectedStatus,
|
|
165
|
+
timeout: test.timeout,
|
|
166
|
+
retries: test.retries,
|
|
167
|
+
results: testResultsById.get(key) ?? [],
|
|
168
|
+
status: test.outcome()
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
const extractMergedSteps = (rootDir, step) => ({
|
|
172
|
+
title: step.title,
|
|
173
|
+
duration: step.duration,
|
|
174
|
+
...(step.error && {
|
|
175
|
+
error: {
|
|
176
|
+
message: step.error.message,
|
|
177
|
+
stack: step.error.stack,
|
|
178
|
+
snippet: step.error.snippet
|
|
179
|
+
}
|
|
180
|
+
}),
|
|
181
|
+
...parseLocation(rootDir, step.location),
|
|
182
|
+
status: step.status,
|
|
183
|
+
...(step.location && {
|
|
184
|
+
snippet: formSnippet(rootDir, step.location)
|
|
185
|
+
}),
|
|
186
|
+
...(step.steps && step.steps.length > 0 && {
|
|
187
|
+
steps: step.steps.map(subStep => extractMergedSteps(rootDir, subStep))
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
const formSnippet = (rootDir, location) => {
|
|
191
|
+
if (location && !(location !== null && location !== void 0 && location.file)) return '';
|
|
192
|
+
try {
|
|
193
|
+
const {
|
|
194
|
+
file,
|
|
195
|
+
line,
|
|
196
|
+
column
|
|
197
|
+
} = parseLocation(rootDir, location, false);
|
|
198
|
+
const raw = _fs.default.readFileSync(file, 'utf8');
|
|
199
|
+
return (0, _codeFrame.codeFrameColumns)(raw, {
|
|
200
|
+
start: {
|
|
201
|
+
line,
|
|
202
|
+
column
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
linesAbove: 2,
|
|
206
|
+
linesBelow: 2,
|
|
207
|
+
highlightCode: true
|
|
208
|
+
});
|
|
209
|
+
} catch {
|
|
210
|
+
return '';
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const parseLocation = (rootDir, {
|
|
214
|
+
file,
|
|
215
|
+
line,
|
|
216
|
+
column
|
|
217
|
+
} = {}, isRelative = true) => file ? {
|
|
218
|
+
file: isRelative ? _path.default.relative(rootDir, file) : file,
|
|
219
|
+
line,
|
|
220
|
+
column
|
|
221
|
+
} : {};
|
|
222
|
+
const stdioEntry = s => typeof s === 'string' ? {
|
|
223
|
+
text: s
|
|
224
|
+
} : {
|
|
225
|
+
buffer: s.toString('base64')
|
|
226
|
+
};
|
|
227
|
+
const processError = error => {
|
|
228
|
+
const message = error.message || error.value || '';
|
|
229
|
+
const stack = error.stack;
|
|
230
|
+
if (!stack && !error.location) return {
|
|
231
|
+
message
|
|
232
|
+
};
|
|
233
|
+
const tokens = [];
|
|
234
|
+
const parsedStack = stack ? constructErrorStack(stack) : undefined;
|
|
235
|
+
tokens.push((parsedStack === null || parsedStack === void 0 ? void 0 : parsedStack.message) || message);
|
|
236
|
+
if (error.snippet) {
|
|
237
|
+
tokens.push('');
|
|
238
|
+
tokens.push(error.snippet);
|
|
239
|
+
}
|
|
240
|
+
if (parsedStack && parsedStack.stackLines.length) {
|
|
241
|
+
const dimmedStackLines = parsedStack.stackLines.split('\n').map(line => dimify(line));
|
|
242
|
+
tokens.push(dimmedStackLines.join('\n'));
|
|
243
|
+
}
|
|
244
|
+
let location = error.location;
|
|
245
|
+
if (parsedStack && !location) location = parsedStack.location;
|
|
246
|
+
if (error.cause) tokens.push(dimify('[cause]: ') + processError(error.cause).message);
|
|
247
|
+
return {
|
|
248
|
+
location,
|
|
249
|
+
message: tokens.join('\n')
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
const constructErrorStack = stack => parseErrorStack(stack, _path.default.sep, false);
|
|
253
|
+
const dimify = text => `\x1b[2m${text}\x1b[22m`;
|
|
254
|
+
const parseErrorStack = (stack, pathSeparator, showInternalStackFrames = false) => {
|
|
255
|
+
const lines = stack.split("\n");
|
|
256
|
+
let firstStackLineIndex = lines.findIndex(line => line.startsWith(" at "));
|
|
257
|
+
if (firstStackLineIndex === -1) firstStackLineIndex = lines.length;
|
|
258
|
+
const message = lines.slice(0, firstStackLineIndex).join("\n");
|
|
259
|
+
const stackStartIndex = indexLocator(stack, '\n', firstStackLineIndex) + 1 || 0;
|
|
260
|
+
const stackLinesString = stackStartIndex ? stack.slice(stackStartIndex) : '';
|
|
261
|
+
let location;
|
|
262
|
+
const stackLinesArr = stackLinesString.split('\n');
|
|
263
|
+
for (const line of stackLinesArr) {
|
|
264
|
+
const frame = parseStackFrame(line, pathSeparator, showInternalStackFrames);
|
|
265
|
+
if (!frame || !frame.file) continue;
|
|
266
|
+
if (isInNodeModules(frame.file, pathSeparator)) continue;
|
|
267
|
+
location = {
|
|
268
|
+
file: frame.file,
|
|
269
|
+
column: frame.column || 0,
|
|
270
|
+
line: frame.line || 0
|
|
271
|
+
};
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
message,
|
|
276
|
+
stackLines: stackLinesString,
|
|
277
|
+
location
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
const indexLocator = (str, pat, n) => {
|
|
281
|
+
let L = str.length,
|
|
282
|
+
i = -1;
|
|
283
|
+
while (n-- && i++ < L) {
|
|
284
|
+
i = str.indexOf(pat, i);
|
|
285
|
+
if (i < 0) break;
|
|
286
|
+
}
|
|
287
|
+
return i;
|
|
288
|
+
};
|
|
289
|
+
const isInNodeModules = (file, pathSeparator) => file.includes(`${pathSeparator}node_modules${pathSeparator}`);
|
|
290
|
+
const parseStackFrame = (text, pathSeparator, showInternalStackFrames) => {
|
|
291
|
+
const re = new RegExp("^(?:\\s*at )?(?:(new) )?(?:(.*?) \\()?(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?(?:(.+?):(\\d+):(\\d+)|(native))(\\)?)$");
|
|
292
|
+
const methodRe = /^(.*?) \[as (.*?)\]$/;
|
|
293
|
+
const match = text && text.match(re);
|
|
294
|
+
if (!match) return null;
|
|
295
|
+
let fname = match[2];
|
|
296
|
+
let file = match[7];
|
|
297
|
+
if (!file) return null;
|
|
298
|
+
if (!showInternalStackFrames && (file.startsWith("internal") || file.startsWith("node:"))) return null;
|
|
299
|
+
const line = match[8];
|
|
300
|
+
const column = match[9];
|
|
301
|
+
const closeParen = match[11] === ")";
|
|
302
|
+
const frame = {
|
|
303
|
+
file: "",
|
|
304
|
+
line: 0,
|
|
305
|
+
column: 0
|
|
306
|
+
};
|
|
307
|
+
if (line) frame.line = Number(line);
|
|
308
|
+
if (column) frame.column = Number(column);
|
|
309
|
+
if (closeParen && file) {
|
|
310
|
+
let closes = 0;
|
|
311
|
+
for (let i = file.length - 1; i > 0; i--) {
|
|
312
|
+
if (file.charAt(i) === ")") {
|
|
313
|
+
closes++;
|
|
314
|
+
} else if (file.charAt(i) === "(" && file.charAt(i - 1) === " ") {
|
|
315
|
+
closes--;
|
|
316
|
+
if (closes === -1 && file.charAt(i - 1) === " ") {
|
|
317
|
+
const before = file.slice(0, i - 1);
|
|
318
|
+
const after = file.slice(i + 1);
|
|
319
|
+
file = after;
|
|
320
|
+
fname += ` (${before}`;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (fname) {
|
|
327
|
+
const methodMatch = fname.match(methodRe);
|
|
328
|
+
if (methodMatch) fname = methodMatch[1];
|
|
329
|
+
}
|
|
330
|
+
if (file) {
|
|
331
|
+
if (file.startsWith("file://")) file = fileURLToPath(file, pathSeparator);
|
|
332
|
+
frame.file = file;
|
|
333
|
+
}
|
|
334
|
+
if (fname) frame.function = fname;
|
|
335
|
+
return frame;
|
|
336
|
+
};
|
|
337
|
+
const fileURLToPath = (fileUrl, pathSeparator) => {
|
|
338
|
+
if (!fileUrl.startsWith("file://")) return fileUrl;
|
|
339
|
+
let path = decodeURIComponent(fileUrl.slice(7));
|
|
340
|
+
if (path.startsWith("/") && /^[a-zA-Z]:/.test(path.slice(1))) path = path.slice(1);
|
|
341
|
+
return path.replace(/\//g, pathSeparator);
|
|
342
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.spawnInheritChild = spawnInheritChild;
|
|
7
|
+
var _child_process = require("child_process");
|
|
8
|
+
var _logger = require("../../utils/logger");
|
|
9
|
+
function spawnInheritChild(command, args, options = {}) {
|
|
10
|
+
const {
|
|
11
|
+
successMessage,
|
|
12
|
+
failureMessage,
|
|
13
|
+
killOnParentExit,
|
|
14
|
+
exitOnSuccess
|
|
15
|
+
} = options;
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
18
|
+
stdio: 'inherit',
|
|
19
|
+
env: {
|
|
20
|
+
...process.env
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
childProcess.on('error', error => {
|
|
24
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
25
|
+
if (!exitOnSuccess) {
|
|
26
|
+
reject(error);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
childProcess.on('exit', (code, signal) => {
|
|
30
|
+
if (code !== 0) {
|
|
31
|
+
if (exitOnSuccess) {
|
|
32
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
} else if (failureMessage) {
|
|
35
|
+
reject(failureMessage(code));
|
|
36
|
+
} else {
|
|
37
|
+
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
if (successMessage) {
|
|
41
|
+
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, successMessage);
|
|
42
|
+
}
|
|
43
|
+
if (exitOnSuccess) {
|
|
44
|
+
process.exit(code);
|
|
45
|
+
} else {
|
|
46
|
+
resolve();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (killOnParentExit) {
|
|
51
|
+
process.on('exit', () => {
|
|
52
|
+
if (exitOnSuccess) {
|
|
53
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Terminating Playwright Process...');
|
|
54
|
+
childProcess.kill();
|
|
55
|
+
} else {
|
|
56
|
+
childProcess.kill();
|
|
57
|
+
reject('Terminating Playwright Process...');
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
process.on('SIGINT', () => {
|
|
61
|
+
childProcess.kill();
|
|
62
|
+
if (exitOnSuccess) {
|
|
63
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, 'Cleaning up...');
|
|
64
|
+
process.exit();
|
|
65
|
+
} else {
|
|
66
|
+
reject('Cleaning up...');
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _logger = require("../../utils/logger");
|
|
4
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
5
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
6
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
7
|
+
var _TagProcessor_brand = /*#__PURE__*/new WeakSet();
|
|
8
|
+
class TagProcessor {
|
|
9
|
+
constructor(editionOrder) {
|
|
10
|
+
_classPrivateMethodInitSpec(this, _TagProcessor_brand);
|
|
11
|
+
this.editionOrder = editionOrder;
|
|
12
|
+
}
|
|
13
|
+
processTags(userArgs) {
|
|
14
|
+
const tagArgs = userArgs['tags'] || '';
|
|
15
|
+
const edition = userArgs['edition'] || null;
|
|
16
|
+
if (!edition) return tagArgs;
|
|
17
|
+
const editionsArray = edition.split(',');
|
|
18
|
+
const editionTags = editionsArray.length === 1 ? _assertClassBrand(_TagProcessor_brand, this, _processSingleEdition).call(this, editionsArray[0], tagArgs) : _assertClassBrand(_TagProcessor_brand, this, _processMultipleEditions).call(this, editionsArray, tagArgs);
|
|
19
|
+
return editionTags;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function _buildTagsString(tags, editionTags) {
|
|
23
|
+
return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
24
|
+
}
|
|
25
|
+
function _parseEdition(edition) {
|
|
26
|
+
if (edition.startsWith('<=')) return ['<=', edition.slice(2)];
|
|
27
|
+
if (edition.startsWith('>=')) return ['>=', edition.slice(2)];
|
|
28
|
+
if (edition.startsWith('<')) return ['<', edition.slice(1)];
|
|
29
|
+
if (edition.startsWith('>')) return ['>', edition.slice(1)];
|
|
30
|
+
return [null, edition];
|
|
31
|
+
}
|
|
32
|
+
function _processSingleEdition(selectedEdition, tagArgs) {
|
|
33
|
+
const editionArgs = _assertClassBrand(_TagProcessor_brand, this, _getEditionArgs).call(this, selectedEdition);
|
|
34
|
+
if (editionArgs && editionArgs.length > 0) {
|
|
35
|
+
const editionTags = _assertClassBrand(_TagProcessor_brand, this, _buildEditionTags).call(this, editionArgs, 'or');
|
|
36
|
+
return _assertClassBrand(_TagProcessor_brand, this, _buildTagsString).call(this, tagArgs, editionTags);
|
|
37
|
+
}
|
|
38
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
|
|
39
|
+
return tagArgs;
|
|
40
|
+
}
|
|
41
|
+
function _processMultipleEditions(editionsArray, tagArgs) {
|
|
42
|
+
const filteredEditions = this.editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
43
|
+
const editionTags = _assertClassBrand(_TagProcessor_brand, this, _buildEditionTags).call(this, filteredEditions, 'or');
|
|
44
|
+
return _assertClassBrand(_TagProcessor_brand, this, _buildTagsString).call(this, tagArgs, editionTags);
|
|
45
|
+
}
|
|
46
|
+
function _getEditionArgs(selectedEdition) {
|
|
47
|
+
const [operator, editionValue] = _assertClassBrand(_TagProcessor_brand, this, _parseEdition).call(this, selectedEdition.toLowerCase());
|
|
48
|
+
const index = this.editionOrder.findIndex(edition => edition.toLowerCase() === editionValue);
|
|
49
|
+
if (index === -1) {
|
|
50
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions for ${selectedEdition} found. Running with default edition`);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
switch (operator) {
|
|
54
|
+
case '<=':
|
|
55
|
+
return this.editionOrder.slice(index + 1);
|
|
56
|
+
case '>=':
|
|
57
|
+
return this.editionOrder.slice(0, index);
|
|
58
|
+
case '<':
|
|
59
|
+
return this.editionOrder.slice(index);
|
|
60
|
+
case '>':
|
|
61
|
+
return this.editionOrder.slice(0, index + 1);
|
|
62
|
+
default:
|
|
63
|
+
return this.editionOrder.filter((_, i) => i !== index);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function _buildEditionTags(editionArgs, operator = 'or') {
|
|
67
|
+
return editionArgs.map(edition => `@edition_${edition}`).join(` ${operator} `);
|
|
68
|
+
}
|
|
69
|
+
module.exports = TagProcessor;
|
|
@@ -5,120 +5,66 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
|
|
8
|
+
exports.runPreprocessing = runPreprocessing;
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _customCommands = require("./custom-commands");
|
|
11
|
-
var _cliArgsToObject = require("../../utils/cliArgsToObject");
|
|
12
10
|
var _envInitializer = require("./env-initializer");
|
|
13
|
-
var _logger = require("../../utils/logger");
|
|
14
11
|
var _readConfigFile = require("./readConfigFile");
|
|
15
12
|
var _rootPath = require("../../utils/rootPath");
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} = userArgsObject;
|
|
24
|
-
let browserList = (0, _configUtils.getBrowsersList)(browsers);
|
|
25
|
-
const playwrightArgs = (0, _cliArgsToObject.objectToCliArgs)(userArgsObject, key => !_customCommands.CUSTOM_COMMANDS.includes(key));
|
|
26
|
-
if (debug) {
|
|
27
|
-
playwrightArgs.push('--debug');
|
|
28
|
-
}
|
|
29
|
-
if (!bddMode && tagArgs) {
|
|
30
|
-
playwrightArgs.push('--grep');
|
|
31
|
-
playwrightArgs.push(tagArgs);
|
|
32
|
-
}
|
|
33
|
-
if (!headless && !userArgsObject.headed) {
|
|
34
|
-
playwrightArgs.push('--headed');
|
|
35
|
-
}
|
|
36
|
-
if (browserList && browserList.length > 0) {
|
|
37
|
-
browserList.map(browser => playwrightArgs.push(`--project=${_browserTypes.BROWSER_PROJECT_MAPPING[browser.toUpperCase()]}`));
|
|
38
|
-
}
|
|
39
|
-
return playwrightArgs;
|
|
40
|
-
}
|
|
13
|
+
var _spawnInheritChild = require("./spawnInheritChild");
|
|
14
|
+
var _tagProcessor = _interopRequireDefault(require("./tagProcessor"));
|
|
15
|
+
var _ConfigurationHelper = require("./configuration/ConfigurationHelper");
|
|
16
|
+
var _Configuration = _interopRequireDefault(require("./configuration/Configuration"));
|
|
17
|
+
var _UserArgs = _interopRequireDefault(require("./configuration/UserArgs"));
|
|
18
|
+
var _RunnerHelper = _interopRequireDefault(require("./runner/RunnerHelper"));
|
|
19
|
+
var _Runner = _interopRequireDefault(require("./runner/Runner"));
|
|
41
20
|
function runPreprocessing(tagArgs, configPath) {
|
|
42
21
|
const beforeCommand = 'node';
|
|
43
|
-
const bddGenPath = _path.default.resolve(
|
|
22
|
+
const bddGenPath = _path.default.resolve((0, _rootPath.getExecutableBinaryPath)('bddgen'));
|
|
44
23
|
const beforeArgs = [bddGenPath, '-c', configPath];
|
|
45
24
|
if (tagArgs) {
|
|
46
25
|
beforeArgs.push('--tags');
|
|
47
26
|
beforeArgs.push(tagArgs);
|
|
48
27
|
}
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
env: {
|
|
53
|
-
...process.env
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
childProcessForPreprocessing.on('error', data => {
|
|
57
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
|
|
58
|
-
reject();
|
|
59
|
-
});
|
|
60
|
-
childProcessForPreprocessing.on('exit', code => {
|
|
61
|
-
if (code === 0) {
|
|
62
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
|
|
63
|
-
resolve();
|
|
64
|
-
} else {
|
|
65
|
-
reject(`BddGen exited with code ${code}`);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function runPlaywright(command, args) {
|
|
71
|
-
return new Promise((resolve, reject) => {
|
|
72
|
-
const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
|
|
73
|
-
stdio: 'inherit',
|
|
74
|
-
env: {
|
|
75
|
-
...process.env
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
childProcessForRunningPlaywright.on('error', error => {
|
|
79
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
|
|
80
|
-
});
|
|
81
|
-
childProcessForRunningPlaywright.on('exit', (code, signal) => {
|
|
82
|
-
if (code !== 0) {
|
|
83
|
-
reject(`Child Process Exited with Code ${code} and Signal ${signal}`);
|
|
84
|
-
} else {
|
|
85
|
-
_logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Test Ran Successfully');
|
|
86
|
-
resolve();
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
process.on('exit', () => {
|
|
90
|
-
childProcessForRunningPlaywright.kill();
|
|
91
|
-
reject('Terminating Playwright Process...');
|
|
92
|
-
});
|
|
93
|
-
process.on('SIGINT', () => {
|
|
94
|
-
childProcessForRunningPlaywright.kill();
|
|
95
|
-
reject('Cleaning up...');
|
|
96
|
-
});
|
|
28
|
+
return (0, _spawnInheritChild.spawnInheritChild)(beforeCommand, beforeArgs, {
|
|
29
|
+
successMessage: 'Feature Files Processed Successfully',
|
|
30
|
+
failureMessage: code => `BddGen exited with code ${code}`
|
|
97
31
|
});
|
|
98
32
|
}
|
|
99
33
|
function main() {
|
|
100
|
-
|
|
34
|
+
// Getting the default config's from framework
|
|
35
|
+
const uatConfig = new _Configuration.default((0, _readConfigFile.getDefaultConfig)());
|
|
36
|
+
// overriding the application config's from project
|
|
37
|
+
const userArgConfig = new _Configuration.default(_UserArgs.default.parseToObject(process.argv.slice(2)));
|
|
38
|
+
const mode = userArgConfig.get("mode");
|
|
39
|
+
const stage = userArgConfig.get("stage");
|
|
40
|
+
uatConfig.addAll(new _Configuration.default((0, _ConfigurationHelper.getApplicationConfig)(stage, mode)));
|
|
41
|
+
// overriding the user config's from CLI
|
|
42
|
+
uatConfig.addAll(userArgConfig);
|
|
43
|
+
const modules = uatConfig.get('modules');
|
|
44
|
+
const tearDown = uatConfig.get('isTearDown');
|
|
45
|
+
|
|
46
|
+
//We need to change this process.env variable to pass the module name in future.
|
|
47
|
+
process.env.modules = modules;
|
|
48
|
+
process.env.tearDown = tearDown;
|
|
49
|
+
process.env.stage = stage;
|
|
101
50
|
const {
|
|
51
|
+
isAuthMode,
|
|
52
|
+
editionOrder,
|
|
102
53
|
debug,
|
|
103
|
-
mode = 'dev',
|
|
104
54
|
bddMode = false,
|
|
105
|
-
headless = false
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
Promise.all(promises).then(() => runPlaywright(command, args)).catch(err => {
|
|
120
|
-
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, err);
|
|
121
|
-
process.exit();
|
|
122
|
-
});
|
|
55
|
+
headless = false
|
|
56
|
+
} = uatConfig.getAll();
|
|
57
|
+
(0, _envInitializer.initializeEnvConfig)(stage, mode, isAuthMode);
|
|
58
|
+
|
|
59
|
+
//This is only used for pass the user arguments to need places in legacy code. We need to rewamp that also.
|
|
60
|
+
const userArgsObject = userArgConfig.getAll();
|
|
61
|
+
const tagProcessor = new _tagProcessor.default(editionOrder);
|
|
62
|
+
const tagArgs = tagProcessor.processTags(uatConfig.getAll());
|
|
63
|
+
const runnerObj = new _Runner.default();
|
|
64
|
+
runnerObj.setTagArgs(tagArgs);
|
|
65
|
+
runnerObj.setUserArgs(userArgsObject);
|
|
66
|
+
runnerObj.setConfig(uatConfig);
|
|
67
|
+
const runner = _RunnerHelper.default.createRunner('spawn', runnerObj);
|
|
68
|
+
runner.run();
|
|
123
69
|
}
|
|
124
70
|
var _default = exports.default = main;
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* @property {string} uatDirectory - Directory in which uat configuration is places.
|
|
22
22
|
* @property {string} headless - Headless Browsers mode.
|
|
23
23
|
* @property {number} trace - trace for test cases.
|
|
24
|
+
* @property {string} smokeTestTrace - trace mode for the smokeTest project (e.g. 'on', 'off', 'retain-on-failure'). Default is 'on'.
|
|
24
25
|
* @property {boolean} video - video for test cases,
|
|
25
26
|
* @property {boolean} debug - debug mode
|
|
26
27
|
* @property {string} mode: mode in which the test cases needs to run
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
* @property {any} reportPath : directory where report is generate
|
|
32
33
|
* @property {boolean} bddMode: Feature files needs to be processed
|
|
33
34
|
* @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 {number} testTimeout: time in milliseconds which the test should fail. Can be overridden per-scenario by tagging the scenario with `@timeout_<seconds>` (e.g. `@timeout_180`). `@timeout_0` disables the timeout. Browser scaling (Firefox 2x, Safari 4x) is preserved.
|
|
35
36
|
* @property {Object} additionalPages: custom pages configuration
|
|
36
37
|
* @property {string} featureFilesFolder: folder name under which feature-files will be placed. Default is feature-files
|
|
37
38
|
* @property {string} stepDefinitionsFolder: folder name under which step implementations will be placed. Default is steps
|
|
@@ -39,5 +40,7 @@
|
|
|
39
40
|
* @property {string} testIdAttribute: Change the default data-testid attribute. configure what attribute to search while calling getByTestId
|
|
40
41
|
* @property {Array} editionOrder: Order in the form of larger editions in the back. Edition with the most privelages should be last
|
|
41
42
|
* @property {testSetupConfig} testSetup: Specify page and context functions that will be called while intilaizing fixtures.
|
|
43
|
+
* @property {string} modules: Modules name to be used for running the specific module test cases.
|
|
44
|
+
* @property {boolean} failureSegregation: When true, collect runtime browser logs on failure, classify failing tests into CODE/CASE/TOOL/ENVIRONMENT, attach additional_logs, and merge tags like CODE_failure into the report. Default: true.
|
|
42
45
|
*/
|
|
43
46
|
"use strict";
|