@zohodesk/testinglibrary 0.1.6 → 0.1.7-exp.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -1
- package/build/bdd-framework/cli/commands/env.js +1 -1
- package/build/bdd-framework/cli/commands/test.js +9 -3
- package/build/bdd-framework/config/env.js +2 -1
- package/build/bdd-framework/config/lang.js +14 -0
- package/build/bdd-framework/cucumber/loadSteps.js +8 -3
- package/build/bdd-framework/decorators.js +2 -2
- package/build/bdd-framework/gen/fixtures.js +48 -0
- package/build/bdd-framework/gen/formatter.js +57 -10
- package/build/bdd-framework/gen/i18n.js +6 -2
- package/build/bdd-framework/gen/index.js +7 -6
- package/build/bdd-framework/gen/testFile.js +105 -39
- package/build/bdd-framework/gen/testNode.js +16 -3
- package/build/bdd-framework/gen/testPoms.js +18 -8
- package/build/bdd-framework/hooks/scenario.js +107 -0
- package/build/bdd-framework/hooks/worker.js +83 -0
- package/build/bdd-framework/playwright/fixtureParameterNames.js +24 -8
- package/build/bdd-framework/playwright/getLocationInFile.js +13 -7
- package/build/bdd-framework/playwright/testTypeImpl.js +11 -7
- package/build/bdd-framework/playwright/transform.js +6 -2
- package/build/bdd-framework/run/StepInvoker.js +73 -0
- package/build/bdd-framework/run/bddFixtures.js +118 -55
- package/build/bdd-framework/run/bddWorld.js +24 -36
- package/build/bdd-framework/snippets/index.js +3 -1
- package/build/bdd-framework/snippets/snippetSyntax.js +3 -1
- package/build/bdd-framework/stepDefinitions/createBdd.js +28 -11
- package/build/bdd-framework/stepDefinitions/decorators/{poms.js → class.js} +7 -3
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +8 -2
- package/build/bdd-framework/stepDefinitions/defineStep.js +2 -1
- package/build/bdd-framework/utils/exit.js +14 -4
- package/build/bdd-framework/utils/index.js +27 -1
- package/build/bdd-framework/utils/logger.js +3 -1
- package/build/core/playwright/builtInFixtures/addTags.js +19 -0
- package/build/core/playwright/builtInFixtures/cacheLayer.js +12 -0
- package/build/core/playwright/builtInFixtures/context.js +15 -0
- package/build/core/playwright/builtInFixtures/index.js +26 -0
- package/build/core/playwright/builtInFixtures/page.js +51 -0
- package/build/core/playwright/index.js +6 -80
- package/build/core/playwright/report-generator.js +2 -1
- package/build/core/playwright/setup/config-creator.js +5 -0
- package/build/core/playwright/setup/custom-reporter.js +9 -0
- package/build/core/playwright/tag-processor.js +6 -2
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +25 -0
- package/build/setup-folder-structure/reportEnhancement/reportAlteration.js +25 -0
- package/build/utils/fileUtils.js +3 -4
- package/changelog.md +10 -0
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
- package/build/bdd-framework/cucumber/gherkin.d.ts +0 -45
- package/build/bdd-framework/gen/poms.js +0 -46
- package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -108
|
@@ -6,58 +6,46 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.BddWorld = void 0;
|
|
7
7
|
exports.getWorldConstructor = getWorldConstructor;
|
|
8
8
|
var _cucumber = require("@cucumber/cucumber");
|
|
9
|
-
var _loadSteps = require("../cucumber/loadSteps");
|
|
10
|
-
var _getLocationInFile = require("../playwright/getLocationInFile");
|
|
11
|
-
var _testTypeImpl = require("../playwright/testTypeImpl");
|
|
12
|
-
var _defineStep = require("../stepDefinitions/defineStep");
|
|
13
9
|
class BddWorld extends _cucumber.World {
|
|
14
10
|
options;
|
|
15
|
-
|
|
16
|
-
customFixtures;
|
|
11
|
+
stepFixtures = {};
|
|
17
12
|
constructor(options) {
|
|
18
13
|
super(options);
|
|
19
14
|
this.options = options;
|
|
20
|
-
this.invokeStep = this.invokeStep.bind(this);
|
|
21
15
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
world: this
|
|
42
|
-
});
|
|
43
|
-
const res = await (0, _testTypeImpl.runStepWithCustomLocation)(this.test, text, location, () => code.apply(this, parameters));
|
|
44
|
-
delete this.customFixtures;
|
|
45
|
-
return res;
|
|
16
|
+
/**
|
|
17
|
+
* Use particular fixture in cucumber-style steps.
|
|
18
|
+
*
|
|
19
|
+
* Note: TS does not support partial generic inference,
|
|
20
|
+
* that's why we can't use this.useFixture<typeof test>('xxx');
|
|
21
|
+
* The solution is to pass TestType as a generic to BddWorld
|
|
22
|
+
* and call useFixture without explicit generic params.
|
|
23
|
+
* Finally, it looks even better as there is no need to pass `typeof test`
|
|
24
|
+
* in every `this.useFixture` call.
|
|
25
|
+
*
|
|
26
|
+
* The downside - it's impossible to pass fixtures type directly to `this.useFixture`
|
|
27
|
+
* like it's done in @Fixture decorator.
|
|
28
|
+
*
|
|
29
|
+
* See: https://stackoverflow.com/questions/45509621/specify-only-first-type-argument
|
|
30
|
+
* See: https://github.com/Microsoft/TypeScript/pull/26349
|
|
31
|
+
*/
|
|
32
|
+
useFixture(fixtureName) {
|
|
33
|
+
return this.stepFixtures[fixtureName];
|
|
46
34
|
}
|
|
47
35
|
get page() {
|
|
48
|
-
return this.
|
|
36
|
+
return this.options.$bddWorldFixtures.page;
|
|
49
37
|
}
|
|
50
38
|
get context() {
|
|
51
|
-
return this.
|
|
39
|
+
return this.options.$bddWorldFixtures.context;
|
|
52
40
|
}
|
|
53
41
|
get browser() {
|
|
54
|
-
return this.
|
|
42
|
+
return this.options.$bddWorldFixtures.browser;
|
|
55
43
|
}
|
|
56
44
|
get browserName() {
|
|
57
|
-
return this.
|
|
45
|
+
return this.options.$bddWorldFixtures.browserName;
|
|
58
46
|
}
|
|
59
47
|
get request() {
|
|
60
|
-
return this.
|
|
48
|
+
return this.options.$bddWorldFixtures.request;
|
|
61
49
|
}
|
|
62
50
|
get testInfo() {
|
|
63
51
|
return this.options.testInfo;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Snippets = void 0;
|
|
7
|
+
var _url = require("url");
|
|
7
8
|
var _loadSnippetBuilder = require("../cucumber/loadSnippetBuilder");
|
|
8
9
|
var _logger = require("../utils/logger");
|
|
9
10
|
var _stepConfig = require("../stepDefinitions/stepConfig");
|
|
@@ -43,7 +44,8 @@ class Snippets {
|
|
|
43
44
|
} = this.runConfiguration.formats.options;
|
|
44
45
|
if (!snippetSyntax && this.isPlaywrightStyle()) {
|
|
45
46
|
this.bddBuiltInSyntax = true;
|
|
46
|
-
|
|
47
|
+
const filePath = this.isDecorators() ? require.resolve('./snippetSyntaxDecorators.js') : this.isTypeScript() ? require.resolve('./snippetSyntaxTs.js') : require.resolve('./snippetSyntax.js');
|
|
48
|
+
return (0, _url.pathToFileURL)(filePath).toString();
|
|
47
49
|
} else {
|
|
48
50
|
return snippetSyntax;
|
|
49
51
|
}
|
|
@@ -27,7 +27,9 @@ class _default {
|
|
|
27
27
|
});
|
|
28
28
|
const allParameterNames = ['{}', ...expressionParameters, ...stepParameters];
|
|
29
29
|
const functionSignature = `${functionName}('${this.escapeSpecialCharacters(generatedExpression)}', async (${allParameterNames.join(', ')}) => {`;
|
|
30
|
-
return [functionSignature,
|
|
30
|
+
return [functionSignature,
|
|
31
|
+
// prettier-ignore
|
|
32
|
+
` // ...`, '});'].join('\n');
|
|
31
33
|
}
|
|
32
34
|
escapeSpecialCharacters(generatedExpression) {
|
|
33
35
|
let source = generatedExpression.source;
|
|
@@ -4,27 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createBdd = createBdd;
|
|
7
|
-
exports.
|
|
8
|
-
var _fixtureParameterNames = require("../playwright/fixtureParameterNames");
|
|
7
|
+
exports.hasCustomTest = void 0;
|
|
9
8
|
var _bddFixtures = require("../run/bddFixtures");
|
|
10
9
|
var _testTypeImpl = require("../playwright/testTypeImpl");
|
|
11
10
|
var _defineStep = require("./defineStep");
|
|
12
11
|
var _exit = require("../utils/exit");
|
|
12
|
+
var _scenario = require("../hooks/scenario");
|
|
13
|
+
var _worker = require("../hooks/worker");
|
|
13
14
|
/**
|
|
14
15
|
* Stuff related to writing steps in Playwright-style.
|
|
15
16
|
*/
|
|
16
17
|
|
|
18
|
+
// Global flag showing that custom test was passed.
|
|
19
|
+
// Used when checking 'importTestFrom' config option.
|
|
20
|
+
// todo: https://github.com/vitalets/playwright-bdd/issues/46
|
|
21
|
+
let hasCustomTest = exports.hasCustomTest = false;
|
|
17
22
|
function createBdd(customTest) {
|
|
18
|
-
|
|
23
|
+
if (!hasCustomTest) {
|
|
24
|
+
exports.hasCustomTest = hasCustomTest = isCustomTest(customTest);
|
|
25
|
+
}
|
|
19
26
|
const Given = defineStepCtor('Given', hasCustomTest);
|
|
20
27
|
const When = defineStepCtor('When', hasCustomTest);
|
|
21
28
|
const Then = defineStepCtor('Then', hasCustomTest);
|
|
22
29
|
const Step = defineStepCtor('Unknown', hasCustomTest);
|
|
30
|
+
const Before = (0, _scenario.scenarioHookFactory)('before');
|
|
31
|
+
const After = (0, _scenario.scenarioHookFactory)('after');
|
|
32
|
+
const BeforeAll = (0, _worker.workerHookFactory)('beforeAll');
|
|
33
|
+
const AfterAll = (0, _worker.workerHookFactory)('afterAll');
|
|
23
34
|
return {
|
|
24
35
|
Given,
|
|
25
36
|
When,
|
|
26
37
|
Then,
|
|
27
|
-
Step
|
|
38
|
+
Step,
|
|
39
|
+
Before,
|
|
40
|
+
After,
|
|
41
|
+
BeforeAll,
|
|
42
|
+
AfterAll
|
|
28
43
|
};
|
|
29
44
|
}
|
|
30
45
|
function defineStepCtor(keyword, hasCustomTest) {
|
|
@@ -37,13 +52,15 @@ function defineStepCtor(keyword, hasCustomTest) {
|
|
|
37
52
|
});
|
|
38
53
|
};
|
|
39
54
|
}
|
|
40
|
-
function extractFixtureNames(fn) {
|
|
41
|
-
return (0, _fixtureParameterNames.fixtureParameterNames)(fn).filter(name => !(0, _bddFixtures.isBddAutoInjectFixture)(name));
|
|
42
|
-
}
|
|
43
55
|
function isCustomTest(customTest) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
if (!customTest || customTest === _bddFixtures.test) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
assertTestHasBddFixtures(customTest);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
function assertTestHasBddFixtures(customTest) {
|
|
63
|
+
if (!(0, _testTypeImpl.isTestContainsSubtest)(customTest, _bddFixtures.test)) {
|
|
64
|
+
(0, _exit.exit)(`createBdd() should use 'test' extended from "playwright-bdd"`);
|
|
47
65
|
}
|
|
48
|
-
return isCustomTest;
|
|
49
66
|
}
|
|
@@ -8,7 +8,7 @@ exports.getPomNodeByFixtureName = getPomNodeByFixtureName;
|
|
|
8
8
|
var _steps = require("./steps");
|
|
9
9
|
var _exit = require("../../utils/exit");
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Class level @Fixture decorator.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -51,7 +51,9 @@ function ensureUniqueFixtureName({
|
|
|
51
51
|
}
|
|
52
52
|
function linkParentWithPomNode(Ctor, pomNode) {
|
|
53
53
|
const parentCtor = Object.getPrototypeOf(Ctor);
|
|
54
|
-
if (!parentCtor)
|
|
54
|
+
if (!parentCtor) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
55
57
|
// if parentCtor is not in pomGraph, add it.
|
|
56
58
|
// Case: parent class is not marked with @Fixture, but has decorator steps (base class)
|
|
57
59
|
const parentPomNode = pomGraph.get(parentCtor) || createPomNode(parentCtor, '');
|
|
@@ -59,6 +61,8 @@ function linkParentWithPomNode(Ctor, pomNode) {
|
|
|
59
61
|
}
|
|
60
62
|
function getPomNodeByFixtureName(fixtureName) {
|
|
61
63
|
for (const pomNode of pomGraph.values()) {
|
|
62
|
-
if (pomNode.fixtureName === fixtureName)
|
|
64
|
+
if (pomNode.fixtureName === fixtureName) {
|
|
65
|
+
return pomNode;
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -36,11 +36,15 @@ function createStepDecorator(keyword) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
function linkStepsWithPomNode(Ctor, pomNode) {
|
|
39
|
-
if (!(Ctor !== null && Ctor !== void 0 && Ctor.prototype))
|
|
39
|
+
if (!(Ctor !== null && Ctor !== void 0 && Ctor.prototype)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
40
42
|
const propertyDescriptors = Object.getOwnPropertyDescriptors(Ctor.prototype);
|
|
41
43
|
return Object.values(propertyDescriptors).forEach(descriptor => {
|
|
42
44
|
const stepConfig = getStepConfigFromMethod(descriptor);
|
|
43
|
-
if (!stepConfig)
|
|
45
|
+
if (!stepConfig) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
44
48
|
stepConfig.pomNode = pomNode;
|
|
45
49
|
decoratedSteps.add(stepConfig);
|
|
46
50
|
});
|
|
@@ -65,7 +69,9 @@ function appendDecoratorSteps(supportCodeLibrary) {
|
|
|
65
69
|
pattern,
|
|
66
70
|
code,
|
|
67
71
|
line: 0,
|
|
72
|
+
// not used in playwright-bdd
|
|
68
73
|
options: {},
|
|
74
|
+
// not used in playwright-bdd
|
|
69
75
|
uri: '' // not used in playwright-bdd
|
|
70
76
|
}, supportCodeLibrary);
|
|
71
77
|
supportCodeLibrary.stepDefinitions.push(stepDefinition);
|
|
@@ -34,7 +34,8 @@ function defineStep(stepConfig) {
|
|
|
34
34
|
}
|
|
35
35
|
function buildCucumberStepCode(stepConfig) {
|
|
36
36
|
const code = function (...args) {
|
|
37
|
-
|
|
37
|
+
// build the first argument (fixtures) for step fn
|
|
38
|
+
const fixturesArg = Object.assign({}, this.stepFixtures, {
|
|
38
39
|
$testInfo: this.testInfo,
|
|
39
40
|
$test: this.test,
|
|
40
41
|
$tags: this.tags
|
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.exit = exit;
|
|
7
7
|
exports.withExitHandler = withExitHandler;
|
|
8
|
-
var _logger = require("./logger");
|
|
9
8
|
var _worker_threads = require("worker_threads");
|
|
10
9
|
/**
|
|
11
10
|
* Exit utils.
|
|
12
11
|
*
|
|
13
|
-
* When calling process.exit() in worker thread used for file generation,
|
|
12
|
+
* When calling process.exit() in worker thread used for test-file generation,
|
|
14
13
|
* logs are not flushed (https://github.com/vitalets/playwright-bdd/issues/59).
|
|
15
14
|
* That's why instead of process.exit we throw ExitError
|
|
16
15
|
* that just sets process.exitCode = 1 and allow program to exit normally.
|
|
16
|
+
* This esnured by wrapping code with withExitHandler().
|
|
17
17
|
*
|
|
18
|
-
* On the other hand, when running in main thread, especially inside Playwright,
|
|
18
|
+
* On the other hand, when running in the main thread, especially inside Playwright,
|
|
19
19
|
* thrown error is captured by Playwright and show with additional messages (e.g. no tests found).
|
|
20
20
|
* That's why in main thread we to call process.exit() to show only needed error.
|
|
21
21
|
*
|
|
@@ -35,6 +35,10 @@ async function withExitHandler(fn) {
|
|
|
35
35
|
return await fn();
|
|
36
36
|
} catch (e) {
|
|
37
37
|
if (e instanceof ExitError) {
|
|
38
|
+
if (e.message) {
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.error(e.message);
|
|
41
|
+
}
|
|
38
42
|
process.exitCode = 1;
|
|
39
43
|
} else {
|
|
40
44
|
throw e;
|
|
@@ -44,7 +48,13 @@ async function withExitHandler(fn) {
|
|
|
44
48
|
function exit(...messages) {
|
|
45
49
|
messages = messages.filter(Boolean);
|
|
46
50
|
if (_worker_threads.isMainThread) {
|
|
47
|
-
|
|
51
|
+
// use console.error() here instead of logger.error() to have less stack
|
|
52
|
+
// for flushing messages to stderr.
|
|
53
|
+
|
|
54
|
+
if (messages.length) {
|
|
55
|
+
// eslint-disable-next-line no-console, max-depth
|
|
56
|
+
console.error('Error:', ...messages);
|
|
57
|
+
}
|
|
48
58
|
process.exit(1);
|
|
49
59
|
} else {
|
|
50
60
|
throw new ExitError(messages.join(' '));
|
|
@@ -4,6 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.callWithTimeout = callWithTimeout;
|
|
8
|
+
exports.extractTemplateParams = extractTemplateParams;
|
|
7
9
|
exports.getPackageVersion = getPackageVersion;
|
|
8
10
|
exports.getSymbolByName = getSymbolByName;
|
|
9
11
|
exports.removeDuplicates = removeDuplicates;
|
|
@@ -11,7 +13,12 @@ exports.resolvePackageRoot = resolvePackageRoot;
|
|
|
11
13
|
exports.template = template;
|
|
12
14
|
var _fs = _interopRequireDefault(require("fs"));
|
|
13
15
|
var _path = _interopRequireDefault(require("path"));
|
|
14
|
-
|
|
16
|
+
var _util = require("util");
|
|
17
|
+
const setTimeoutPromise = (0, _util.promisify)(setTimeout);
|
|
18
|
+
/**
|
|
19
|
+
* Returns Symbol by name.
|
|
20
|
+
* See: https://stackoverflow.com/questions/50453640/how-can-i-get-the-value-of-a-symbol-property
|
|
21
|
+
*/
|
|
15
22
|
function getSymbolByName(target, name) {
|
|
16
23
|
const ownKeys = Reflect.ownKeys(target);
|
|
17
24
|
const symbol = ownKeys.find(key => key.toString() === `Symbol(${name})`);
|
|
@@ -29,6 +36,13 @@ function template(t, params = {}) {
|
|
|
29
36
|
return params[key] !== undefined ? String(params[key]) : match;
|
|
30
37
|
});
|
|
31
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Extracts all template params from string.
|
|
41
|
+
* Params defined as <param>.
|
|
42
|
+
*/
|
|
43
|
+
function extractTemplateParams(t) {
|
|
44
|
+
return [...t.matchAll(/<(.+?)>/g)].map(m => m[1]);
|
|
45
|
+
}
|
|
32
46
|
function removeDuplicates(arr) {
|
|
33
47
|
return [...new Set(arr)];
|
|
34
48
|
}
|
|
@@ -41,4 +55,16 @@ function getPackageVersion(packageName) {
|
|
|
41
55
|
const packageJsonPath = _path.default.join(packageRoot, 'package.json');
|
|
42
56
|
const packageJson = JSON.parse(_fs.default.readFileSync(packageJsonPath, 'utf8'));
|
|
43
57
|
return packageJson.version || '';
|
|
58
|
+
}
|
|
59
|
+
async function callWithTimeout(fn, timeout, timeoutMsg) {
|
|
60
|
+
if (!timeout) {
|
|
61
|
+
return fn();
|
|
62
|
+
}
|
|
63
|
+
const ac = new AbortController();
|
|
64
|
+
return Promise.race([fn(), setTimeoutPromise(timeout, null, {
|
|
65
|
+
ref: false,
|
|
66
|
+
signal: ac.signal
|
|
67
|
+
}).then(() => {
|
|
68
|
+
throw new Error(timeoutMsg || `Function timeout (${timeout} ms)`);
|
|
69
|
+
})]).finally(() => ac.abort());
|
|
44
70
|
}
|
|
@@ -13,7 +13,9 @@ class Logger {
|
|
|
13
13
|
this.options = options;
|
|
14
14
|
}
|
|
15
15
|
log(...args) {
|
|
16
|
-
if (this.options.verbose)
|
|
16
|
+
if (this.options.verbose) {
|
|
17
|
+
console.log(...args);
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
warn(...args) {
|
|
19
21
|
// using log() to output warnings to stdout, not stderr
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
addTags: [async ({
|
|
9
|
+
$tags
|
|
10
|
+
}, use, testInfo) => {
|
|
11
|
+
testInfo.annotations.push({
|
|
12
|
+
type: 'tags',
|
|
13
|
+
description: $tags.join(', ')
|
|
14
|
+
});
|
|
15
|
+
await use();
|
|
16
|
+
}, {
|
|
17
|
+
auto: true
|
|
18
|
+
}]
|
|
19
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
context: async ({
|
|
9
|
+
context
|
|
10
|
+
}, use) => {
|
|
11
|
+
// eslint-disable-next-line no-undef
|
|
12
|
+
await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
|
|
13
|
+
await use(context);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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 _page = _interopRequireDefault(require("./page"));
|
|
9
|
+
var _context = _interopRequireDefault(require("./context"));
|
|
10
|
+
var _cacheLayer = _interopRequireDefault(require("./cacheLayer"));
|
|
11
|
+
var _addTags = _interopRequireDefault(require("./addTags"));
|
|
12
|
+
function getBuiltInFixtures(bddMode) {
|
|
13
|
+
let builtInFixtures = {
|
|
14
|
+
..._page.default,
|
|
15
|
+
..._context.default,
|
|
16
|
+
..._cacheLayer.default
|
|
17
|
+
};
|
|
18
|
+
if (bddMode) {
|
|
19
|
+
builtInFixtures = {
|
|
20
|
+
...builtInFixtures,
|
|
21
|
+
..._addTags.default
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return builtInFixtures;
|
|
25
|
+
}
|
|
26
|
+
var _default = exports.default = getBuiltInFixtures;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
// function test(descrition, callback) {
|
|
8
|
+
// return test(descrition, ({ page }) => {
|
|
9
|
+
// const { locator, ...custompage } = page
|
|
10
|
+
// callback({ page: custompage })
|
|
11
|
+
// })
|
|
12
|
+
// }
|
|
13
|
+
// class FilteredPage {
|
|
14
|
+
// constructor(page) {
|
|
15
|
+
// this.page = page;
|
|
16
|
+
// this.allowedMethods = ['getByText', 'getByTitle'];
|
|
17
|
+
// this.context = page.context;
|
|
18
|
+
// }
|
|
19
|
+
// goto(...args) {
|
|
20
|
+
// return this.page['goto'](...args);
|
|
21
|
+
// }
|
|
22
|
+
// getByRole(...args) {
|
|
23
|
+
// return this.page['getByRole'](...args);
|
|
24
|
+
// }
|
|
25
|
+
// }
|
|
26
|
+
// function FilteredPage(page) {
|
|
27
|
+
// return {
|
|
28
|
+
// getByRole: () => {
|
|
29
|
+
// throw new Error('You cannnot use getByRole property')
|
|
30
|
+
// }
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
|
+
var _default = exports.default = {
|
|
34
|
+
page: async ({
|
|
35
|
+
page
|
|
36
|
+
}, use) => {
|
|
37
|
+
page.getBaseUrl = function () {
|
|
38
|
+
if (process.env.mode === 'dev') {
|
|
39
|
+
return `${process.env.domain}?devURL=${process.env.devUrl}`;
|
|
40
|
+
}
|
|
41
|
+
return `${process.env.domain}`;
|
|
42
|
+
};
|
|
43
|
+
page.getCustomPageUrl = function (url) {
|
|
44
|
+
if (process.env.mode === 'dev') {
|
|
45
|
+
return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`;
|
|
46
|
+
}
|
|
47
|
+
return `${process.env.domain}/${url}`;
|
|
48
|
+
};
|
|
49
|
+
await use(page);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -20,91 +21,16 @@ exports.test = void 0;
|
|
|
20
21
|
var _bddFramework = require("../../bdd-framework");
|
|
21
22
|
var _test = require("@playwright/test");
|
|
22
23
|
var _readConfigFile = require("./readConfigFile");
|
|
23
|
-
|
|
24
|
-
// return test(descrition, ({ page }) => {
|
|
25
|
-
// const { locator, ...custompage } = page
|
|
26
|
-
// callback({ page: custompage })
|
|
27
|
-
// })
|
|
28
|
-
// }
|
|
29
|
-
|
|
30
|
-
// class FilteredPage {
|
|
31
|
-
// constructor(page) {
|
|
32
|
-
// this.page = page;
|
|
33
|
-
// this.allowedMethods = ['getByText', 'getByTitle'];
|
|
34
|
-
// this.context = page.context;
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
// goto(...args) {
|
|
38
|
-
// return this.page['goto'](...args);
|
|
39
|
-
// }
|
|
40
|
-
|
|
41
|
-
// getByRole(...args) {
|
|
42
|
-
// return this.page['getByRole'](...args);
|
|
43
|
-
// }
|
|
44
|
-
// }
|
|
45
|
-
|
|
46
|
-
// function FilteredPage(page) {
|
|
47
|
-
// return {
|
|
48
|
-
// getByRole: () => {
|
|
49
|
-
// throw new Error('You cannnot use getByRole property')
|
|
50
|
-
// }
|
|
51
|
-
// }
|
|
52
|
-
// }
|
|
24
|
+
var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
|
|
53
25
|
const {
|
|
54
|
-
additionalPages,
|
|
26
|
+
additionalPages: userFixtures,
|
|
55
27
|
bddMode
|
|
56
28
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
57
29
|
let base = bddMode ? _bddFramework.test : _test.test;
|
|
58
|
-
const
|
|
30
|
+
const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
|
|
59
31
|
const test = exports.test = base.extend({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, use) => {
|
|
63
|
-
// const proxyPage = new Proxy(page, {
|
|
64
|
-
// get: function (obj, prop) {
|
|
65
|
-
// console.log('Gettig Priop', prop);
|
|
66
|
-
// let filterMethod = FilteredPage(page)[prop];
|
|
67
|
-
// if (filterMethod) {
|
|
68
|
-
// return filterMethod;
|
|
69
|
-
// } else {
|
|
70
|
-
// return obj[prop] ? obj[prop] : 'property does not exist';
|
|
71
|
-
// }
|
|
72
|
-
// }
|
|
73
|
-
// })
|
|
74
|
-
page.getBaseUrl = function () {
|
|
75
|
-
if (process.env.mode === 'dev') {
|
|
76
|
-
return `${process.env.domain}?devURL=${process.env.devUrl}`;
|
|
77
|
-
}
|
|
78
|
-
return `${process.env.domain}`;
|
|
79
|
-
};
|
|
80
|
-
page.getCustomPageUrl = function (url) {
|
|
81
|
-
if (process.env.mode === 'dev') {
|
|
82
|
-
return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`;
|
|
83
|
-
}
|
|
84
|
-
return `${process.env.domain}/${url}`;
|
|
85
|
-
};
|
|
86
|
-
await use(page);
|
|
87
|
-
|
|
88
|
-
//await use(new FilteredPage(page));
|
|
89
|
-
|
|
90
|
-
// await use(async (page) => {
|
|
91
|
-
// delete page.getByTestId;
|
|
92
|
-
// await page;
|
|
93
|
-
// });
|
|
94
|
-
},
|
|
95
|
-
context: async ({
|
|
96
|
-
context
|
|
97
|
-
}, use) => {
|
|
98
|
-
// eslint-disable-next-line no-undef
|
|
99
|
-
await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
|
|
100
|
-
await use(context);
|
|
101
|
-
},
|
|
102
|
-
cacheLayer: async ({
|
|
103
|
-
context
|
|
104
|
-
}, use) => {
|
|
105
|
-
await use(cacheMap);
|
|
106
|
-
},
|
|
107
|
-
...additionalPages
|
|
32
|
+
...buildInFixtures,
|
|
33
|
+
...userFixtures
|
|
108
34
|
});
|
|
109
35
|
const {
|
|
110
36
|
Given,
|
|
@@ -17,7 +17,8 @@ const {
|
|
|
17
17
|
reportPath: htmlPath
|
|
18
18
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
19
19
|
const args = ['show-report', htmlPath].concat(userArgs);
|
|
20
|
-
function generateReport() {
|
|
20
|
+
async function generateReport() {
|
|
21
|
+
// await preProcessReport()
|
|
21
22
|
const childProcess = (0, _child_process.spawn)(command, args, {
|
|
22
23
|
stdio: 'inherit'
|
|
23
24
|
});
|
|
@@ -69,6 +69,11 @@ function getPlaywrightConfig() {
|
|
|
69
69
|
projects: isAuthMode ? [{
|
|
70
70
|
name: 'setup',
|
|
71
71
|
testMatch: /.*\.setup\.js/,
|
|
72
|
+
testDir: _path.default.join(process.cwd(), 'uat'),
|
|
73
|
+
teardown: 'cleanup'
|
|
74
|
+
}, {
|
|
75
|
+
name: 'cleanup',
|
|
76
|
+
testMatch: /.*\.teardown\.js/,
|
|
72
77
|
testDir: _path.default.join(process.cwd(), 'uat')
|
|
73
78
|
}, ...projects] : [...projects]
|
|
74
79
|
};
|
|
@@ -20,6 +20,7 @@ class JSONSummaryReporter {
|
|
|
20
20
|
this.interrupted = [];
|
|
21
21
|
this.timedOut = [];
|
|
22
22
|
this.flakey = [];
|
|
23
|
+
this.failedSteps = [];
|
|
23
24
|
this.status = 'unknown';
|
|
24
25
|
this.startedAt = 0;
|
|
25
26
|
this._open = (0, _readConfigFile.generateConfigFromFile)().openReportOn;
|
|
@@ -46,6 +47,14 @@ class JSONSummaryReporter {
|
|
|
46
47
|
// Using the t variable in the push will push a full test name + test description
|
|
47
48
|
const t = title.join(' > ');
|
|
48
49
|
// Set the status
|
|
50
|
+
const stepTitleList = result.steps.map(step => ({
|
|
51
|
+
title: step.title,
|
|
52
|
+
error: step.error,
|
|
53
|
+
testTitle: t
|
|
54
|
+
})).filter(step => step.error !== undefined);
|
|
55
|
+
if (stepTitleList.length > 0) {
|
|
56
|
+
this.failedSteps = [...this.failedSteps, ...stepTitleList];
|
|
57
|
+
}
|
|
49
58
|
const status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn') ? 'warned' : result.status;
|
|
50
59
|
// Logic to push the results into the correct array
|
|
51
60
|
if (result.status === 'passed' && result.retry >= 1) {
|