@zohodesk/testinglibrary 0.1.6 → 0.1.7
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/index.js +12 -3
- package/build/core/playwright/report-generator.js +2 -1
- package/build/core/playwright/setup/config-creator.js +5 -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/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
|
|
@@ -99,11 +99,20 @@ const test = exports.test = base.extend({
|
|
|
99
99
|
await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
|
|
100
100
|
await use(context);
|
|
101
101
|
},
|
|
102
|
-
cacheLayer: async ({
|
|
103
|
-
context
|
|
104
|
-
}, use) => {
|
|
102
|
+
cacheLayer: async ({}, use) => {
|
|
105
103
|
await use(cacheMap);
|
|
106
104
|
},
|
|
105
|
+
addTags: [async ({
|
|
106
|
+
$tags
|
|
107
|
+
}, use, testInfo) => {
|
|
108
|
+
testInfo.annotations.push({
|
|
109
|
+
type: 'tags',
|
|
110
|
+
description: $tags.join(', ')
|
|
111
|
+
});
|
|
112
|
+
await use();
|
|
113
|
+
}, {
|
|
114
|
+
auto: true
|
|
115
|
+
}],
|
|
107
116
|
...additionalPages
|
|
108
117
|
});
|
|
109
118
|
const {
|
|
@@ -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
|
};
|
|
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.tagProcessor = tagProcessor;
|
|
7
|
+
var _logger = require("../../utils/logger");
|
|
8
|
+
/* eslint-disable dot-notation */
|
|
9
|
+
|
|
7
10
|
function getTagsString(tags, editionTags) {
|
|
8
11
|
return tags && tags !== '' ? `${tags} and not (${editionTags})` : `not (${editionTags})`;
|
|
9
12
|
}
|
|
@@ -37,7 +40,7 @@ function editionPreprocessing(editionOrder, selectedEdition) {
|
|
|
37
40
|
}
|
|
38
41
|
return resultArray;
|
|
39
42
|
}
|
|
40
|
-
Logger.log(Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
43
|
+
_logger.Logger.log(_logger.Logger.INFO_TYPE, `No matching editions ${selectedEdition} found. Running with default edition`);
|
|
41
44
|
return [];
|
|
42
45
|
}
|
|
43
46
|
function buildEditionTags(editionArgs, operator) {
|
|
@@ -56,7 +59,8 @@ function tagProcessor(userArgsObject, editionOrder) {
|
|
|
56
59
|
}
|
|
57
60
|
} else {
|
|
58
61
|
// More than one edition given
|
|
59
|
-
const
|
|
62
|
+
const filteredEditions = editionOrder.filter(edition => !editionsArray.includes(edition));
|
|
63
|
+
const editionTags = buildEditionTags(filteredEditions, 'or');
|
|
60
64
|
tagArgs = `${getTagsString(tagArgs, editionTags)}`;
|
|
61
65
|
}
|
|
62
66
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
function sortEdition(event) {
|
|
3
|
+
var currentURL = window.location.href;
|
|
4
|
+
const endPointCount = window.location.href.indexOf('#');
|
|
5
|
+
if (!(endPointCount == -1)) {
|
|
6
|
+
window.history.pushState({}, '', currentURL.slice(0, endPointCount));
|
|
7
|
+
currentURL = currentURL.slice(0, endPointCount);
|
|
8
|
+
}
|
|
9
|
+
console.log(currentURL);
|
|
10
|
+
window.open(`${currentURL}#?q=@edition_${event.target.value}`, '_self');
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
<div class="mainContainer" style="margin-left: 20px; display: flex;">
|
|
14
|
+
<div class="selectEditionContainer" style="padding: 20px;">
|
|
15
|
+
<select class="selectEdition" style="padding: 5px; width: 100px; border-radius: 6px; border: 1px solid var(--color-border-default);" onchange="sortEdition(event)">
|
|
16
|
+
<option value="EnterPrise">EnterPrise</option>
|
|
17
|
+
<option value="Professional">Professional</option>
|
|
18
|
+
<option value="Express">Express</option>
|
|
19
|
+
<option value="Standard">Standard</option>
|
|
20
|
+
<option value="Free">Free</option>
|
|
21
|
+
</select>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.preProcessReport = preProcessReport;
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var _logger = require("./../../utils/logger");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
const htmlFilePath = _path.default.resolve(process.cwd(), 'uat', 'playwright-report', 'index.html');
|
|
12
|
+
const fileHtml = _fs.default.readFileSync(htmlFilePath, 'utf-8');
|
|
13
|
+
const addOnHtml = _fs.default.readFileSync(_path.default.resolve(__filename, '../', 'addonScript.html'), 'utf-8');
|
|
14
|
+
const splitedHTML = fileHtml.split('\n');
|
|
15
|
+
const toAdd = addOnHtml.split('\n');
|
|
16
|
+
function preProcessReport() {
|
|
17
|
+
if (_fs.default.existsSync(htmlFilePath)) {
|
|
18
|
+
const modifiedContent = [...splitedHTML.slice(0, 55), ...toAdd, ...splitedHTML.slice(56)].join('').toString();
|
|
19
|
+
_fs.default.writeFileSync(htmlFilePath, modifiedContent);
|
|
20
|
+
return;
|
|
21
|
+
} else {
|
|
22
|
+
_logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'Report is not generated Properly ...');
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
package/changelog.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Framework that abstracts the configuration for playwright and Jest
|
|
4
4
|
|
|
5
|
+
# 0.1.7
|
|
6
|
+
**Enhancements**
|
|
7
|
+
- Added option to run teardown logic.
|
|
8
|
+
- Added support for tag based filtering.
|
|
9
|
+
- Playwright-bdd version updated to 5.6.0.
|
|
10
|
+
- New fixture added to add tag as annotations in test report
|
|
11
|
+
|
|
12
|
+
**Issue Fixes**
|
|
13
|
+
- Edition command option. Fixed the edition tags not generated properly
|
|
14
|
+
|
|
5
15
|
# 0.1.6
|
|
6
16
|
|
|
7
17
|
**Enhancements**
|
package/npm-shrinkwrap.json
CHANGED
package/package.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copied from @cucumber/cucumber/lib/api/gherkin.d.ts
|
|
3
|
-
* Fixes error:
|
|
4
|
-
* Return type of exported function has or is using name 'PickleWithDocument'
|
|
5
|
-
* from external module "../node_modules/@cucumber/cucumber/lib/api/gherkin"
|
|
6
|
-
* but cannot be named
|
|
7
|
-
*/
|
|
8
|
-
import {
|
|
9
|
-
Envelope,
|
|
10
|
-
GherkinDocument,
|
|
11
|
-
IdGenerator,
|
|
12
|
-
Location,
|
|
13
|
-
ParseError,
|
|
14
|
-
Pickle,
|
|
15
|
-
} from '@cucumber/messages';
|
|
16
|
-
import { ISourcesCoordinates } from '@cucumber/cucumber/lib/api/types';
|
|
17
|
-
import { ILogger } from '@cucumber/cucumber/lib/logger';
|
|
18
|
-
|
|
19
|
-
declare module '@cucumber/cucumber/lib/api/gherkin' {
|
|
20
|
-
export interface PickleWithDocument {
|
|
21
|
-
gherkinDocument: GherkinDocument;
|
|
22
|
-
location: Location;
|
|
23
|
-
pickle: Pickle;
|
|
24
|
-
}
|
|
25
|
-
export function getFilteredPicklesAndErrors({
|
|
26
|
-
newId,
|
|
27
|
-
cwd,
|
|
28
|
-
logger,
|
|
29
|
-
unexpandedFeaturePaths,
|
|
30
|
-
featurePaths,
|
|
31
|
-
coordinates,
|
|
32
|
-
onEnvelope,
|
|
33
|
-
}: {
|
|
34
|
-
newId: IdGenerator.NewId;
|
|
35
|
-
cwd: string;
|
|
36
|
-
logger: ILogger;
|
|
37
|
-
unexpandedFeaturePaths: string[];
|
|
38
|
-
featurePaths: string[];
|
|
39
|
-
coordinates: ISourcesCoordinates;
|
|
40
|
-
onEnvelope?: (envelope: Envelope) => void;
|
|
41
|
-
}): Promise<{
|
|
42
|
-
filteredPickles: PickleWithDocument[];
|
|
43
|
-
parseErrors: ParseError[];
|
|
44
|
-
}>;
|
|
45
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.POMS = void 0;
|
|
7
|
-
exports.buildFixtureTag = buildFixtureTag;
|
|
8
|
-
var _createDecorators = require("../stepDefinitions/createDecorators");
|
|
9
|
-
/**
|
|
10
|
-
* Handle POMs graph for decorator steps.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const FIXTURE_TAG_PREFIX = '@fixture:';
|
|
14
|
-
class POMS {
|
|
15
|
-
usedPoms = new Map();
|
|
16
|
-
add(pomNode) {
|
|
17
|
-
if (pomNode) this.usedPoms.set(pomNode, null);
|
|
18
|
-
}
|
|
19
|
-
addByFixtureName(fixtureName) {
|
|
20
|
-
const pomNode = (0, _createDecorators.getPomNodeByFixtureName)(fixtureName);
|
|
21
|
-
if (pomNode) this.add(pomNode);
|
|
22
|
-
}
|
|
23
|
-
addByTag(tag) {
|
|
24
|
-
const fixtureName = extractFixtureName(tag);
|
|
25
|
-
if (fixtureName) this.addByFixtureName(fixtureName);
|
|
26
|
-
}
|
|
27
|
-
resolveFixtureNames(pomNode) {
|
|
28
|
-
const resolvedFixtureNames = this.usedPoms.get(pomNode);
|
|
29
|
-
if (resolvedFixtureNames) return resolvedFixtureNames;
|
|
30
|
-
const fixtureNames = [...pomNode.children].map(child => this.resolveFixtureNames(child)).flat();
|
|
31
|
-
if (this.usedPoms.has(pomNode)) {
|
|
32
|
-
// if nothing returned from children, use own fixtureName,
|
|
33
|
-
// otherwise use what returned from child
|
|
34
|
-
if (!fixtureNames.length) fixtureNames.push(pomNode.fixtureName);
|
|
35
|
-
this.usedPoms.set(pomNode, fixtureNames);
|
|
36
|
-
}
|
|
37
|
-
return fixtureNames;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.POMS = POMS;
|
|
41
|
-
function extractFixtureName(tag) {
|
|
42
|
-
return tag.startsWith(FIXTURE_TAG_PREFIX) ? tag.replace(FIXTURE_TAG_PREFIX, '') : '';
|
|
43
|
-
}
|
|
44
|
-
function buildFixtureTag(fixtureName) {
|
|
45
|
-
return `${FIXTURE_TAG_PREFIX}${fixtureName}`;
|
|
46
|
-
}
|