@zohodesk/testinglibrary 0.1.8-exp.5 → 0.1.8-stb-bdd-v2
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 +18 -18
- package/.eslintrc.js +31 -31
- package/.prettierrc +5 -5
- package/README.md +17 -17
- package/bin/cli.js +2 -2
- package/build/bdd-framework/cli/commands/env.js +3 -3
- package/build/bdd-framework/cli/options.js +4 -4
- package/build/bdd-framework/cli/worker.js +3 -3
- package/build/bdd-framework/config/dir.js +6 -6
- package/build/bdd-framework/config/env.js +3 -3
- package/build/bdd-framework/config/index.js +2 -2
- package/build/bdd-framework/config/lang.js +2 -2
- package/build/bdd-framework/cucumber/buildStepDefinition.js +3 -3
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +3 -3
- package/build/bdd-framework/cucumber/loadSources.js +9 -9
- package/build/bdd-framework/gen/fixtures.js +8 -8
- package/build/bdd-framework/gen/formatter.js +7 -7
- package/build/bdd-framework/gen/i18n.js +3 -3
- package/build/bdd-framework/gen/index.js +2 -2
- package/build/bdd-framework/gen/testFile.js +16 -16
- package/build/bdd-framework/gen/testNode.js +3 -3
- package/build/bdd-framework/gen/testPoms.js +31 -31
- package/build/bdd-framework/hooks/scenario.js +6 -6
- package/build/bdd-framework/hooks/worker.js +4 -4
- package/build/bdd-framework/playwright/fixtureParameterNames.js +3 -3
- package/build/bdd-framework/playwright/getLocationInFile.js +4 -4
- package/build/bdd-framework/playwright/loadConfig.js +3 -3
- package/build/bdd-framework/playwright/testTypeImpl.js +11 -11
- package/build/bdd-framework/playwright/transform.js +4 -4
- package/build/bdd-framework/playwright/utils.js +2 -2
- package/build/bdd-framework/run/StepInvoker.js +2 -2
- package/build/bdd-framework/run/bddWorld.js +15 -15
- package/build/bdd-framework/snippets/index.js +2 -2
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +4 -4
- package/build/bdd-framework/stepDefinitions/createBdd.js +2 -2
- package/build/bdd-framework/stepDefinitions/decorators/class.js +7 -7
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +6 -6
- package/build/bdd-framework/stepDefinitions/defineStep.js +3 -3
- package/build/bdd-framework/stepDefinitions/stepConfig.js +5 -5
- package/build/bdd-framework/utils/exit.js +18 -22
- package/build/bdd-framework/utils/index.js +9 -9
- package/build/bdd-framework/utils/jsStringWrap.js +9 -9
- package/build/bdd-framework/utils/logger.js +2 -2
- package/build/bdd-poc/config/pathConfig.js +22 -0
- package/build/bdd-poc/core-runner/exportMethods.js +20 -0
- package/build/bdd-poc/core-runner/main.js +10 -0
- package/build/bdd-poc/core-runner/runner.js +20 -0
- package/build/bdd-poc/core-runner/stepDefinitions.js +52 -0
- package/build/bdd-poc/index.js +26 -0
- package/build/bdd-poc/test/cucumber/featureFileParer.js +84 -0
- package/build/bdd-poc/test/cucumber/parserCucumber.js +15 -0
- package/build/bdd-poc/test/stepGenerate/extractTestInputs.js +36 -0
- package/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +38 -0
- package/build/bdd-poc/test/stepGenerate/stepsnippets.js +58 -0
- package/build/bdd-poc/test/tagsHandle.js +69 -0
- package/build/bdd-poc/test/testDataMap.js +97 -0
- package/build/bdd-poc/test/testStructure.js +98 -0
- package/build/bdd-poc/utils/stringManipulation.js +26 -0
- package/build/core/playwright/builtInFixtures/addTags.js +1 -1
- package/build/core/playwright/builtInFixtures/index.js +4 -3
- package/build/core/playwright/custom-commands.js +1 -1
- package/build/core/playwright/index.js +6 -17
- package/build/core/playwright/readConfigFile.js +30 -30
- package/build/core/playwright/setup/config-creator.js +14 -13
- package/build/core/playwright/setup/config-utils.js +26 -37
- package/build/core/playwright/tag-processor.js +4 -2
- package/build/core/playwright/test-runner.js +42 -37
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +2 -16
- package/build/index.d.ts +60 -60
- package/build/index.js +12 -17
- package/build/parser/sample.feature +34 -34
- package/build/parser/sample.spec.js +18 -18
- package/build/setup-folder-structure/helper.js +0 -1
- package/build/setup-folder-structure/reportEnhancement/addonScript.html +24 -24
- package/build/setup-folder-structure/samples/auth-setup-sample.js +72 -72
- package/build/setup-folder-structure/samples/authUsers-sample.json +8 -8
- package/build/setup-folder-structure/samples/env-config-sample.json +20 -20
- package/build/setup-folder-structure/samples/git-ignore.sample.js +36 -36
- package/build/setup-folder-structure/samples/uat-config-sample.js +44 -44
- package/build/utils/cliArgsToObject.js +25 -25
- package/build/utils/fileUtils.js +19 -1
- package/build/utils/getFilePath.js +2 -1
- package/changelog.md +131 -137
- package/jest.config.js +63 -63
- package/npm-shrinkwrap.json +5980 -6469
- package/package.json +54 -55
- package/playwright.config.js +112 -112
- package/build/core/playwright/constants/browserTypes.js +0 -16
package/.babelrc
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
{
|
|
2
|
-
"presets": [
|
|
3
|
-
[
|
|
4
|
-
"@babel/preset-env",
|
|
5
|
-
{
|
|
6
|
-
"targets": {
|
|
7
|
-
"node": "14"
|
|
8
|
-
},
|
|
9
|
-
"exclude": ["@babel/plugin-transform-destructuring"]
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
],
|
|
13
|
-
"plugins": [
|
|
14
|
-
["@babel/plugin-transform-runtime"]
|
|
15
|
-
],
|
|
16
|
-
"ignore": [
|
|
17
|
-
"./src/setup-folder-structure/samples"
|
|
18
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"presets": [
|
|
3
|
+
[
|
|
4
|
+
"@babel/preset-env",
|
|
5
|
+
{
|
|
6
|
+
"targets": {
|
|
7
|
+
"node": "14"
|
|
8
|
+
},
|
|
9
|
+
"exclude": ["@babel/plugin-transform-destructuring"]
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
],
|
|
13
|
+
"plugins": [
|
|
14
|
+
["@babel/plugin-transform-runtime"]
|
|
15
|
+
],
|
|
16
|
+
"ignore": [
|
|
17
|
+
"./src/setup-folder-structure/samples"
|
|
18
|
+
]
|
|
19
19
|
}
|
package/.eslintrc.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"env": {
|
|
3
|
-
"node": true,
|
|
4
|
-
"es2021": true
|
|
5
|
-
},
|
|
6
|
-
"extends": "eslint:recommended",
|
|
7
|
-
"overrides": [
|
|
8
|
-
{
|
|
9
|
-
"env": {
|
|
10
|
-
"node": true
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
".eslintrc.{js,cjs}"
|
|
14
|
-
],
|
|
15
|
-
"parserOptions": {
|
|
16
|
-
"sourceType": "script"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"parserOptions": {
|
|
21
|
-
"ecmaVersion": "latest",
|
|
22
|
-
"sourceType": "module"
|
|
23
|
-
},
|
|
24
|
-
"rules": {
|
|
25
|
-
"indent": ["error", 2, { "SwitchCase": 1 }],
|
|
26
|
-
"no-empty-pattern": "off",
|
|
27
|
-
"comma-dangle": ["error", "never"],
|
|
28
|
-
"curly": ["error"],
|
|
29
|
-
"brace-style": "error"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
module.exports = {
|
|
2
|
+
"env": {
|
|
3
|
+
"node": true,
|
|
4
|
+
"es2021": true
|
|
5
|
+
},
|
|
6
|
+
"extends": "eslint:recommended",
|
|
7
|
+
"overrides": [
|
|
8
|
+
{
|
|
9
|
+
"env": {
|
|
10
|
+
"node": true
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
".eslintrc.{js,cjs}"
|
|
14
|
+
],
|
|
15
|
+
"parserOptions": {
|
|
16
|
+
"sourceType": "script"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"parserOptions": {
|
|
21
|
+
"ecmaVersion": "latest",
|
|
22
|
+
"sourceType": "module"
|
|
23
|
+
},
|
|
24
|
+
"rules": {
|
|
25
|
+
"indent": ["error", 2, { "SwitchCase": 1 }],
|
|
26
|
+
"no-empty-pattern": "off",
|
|
27
|
+
"comma-dangle": ["error", "never"],
|
|
28
|
+
"curly": ["error"],
|
|
29
|
+
"brace-style": "error"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/.prettierrc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"trailingComma": "none",
|
|
3
|
-
"singleQuote": true,
|
|
4
|
-
"arrowParens": "avoid",
|
|
5
|
-
"jsxSingleQuote": true
|
|
1
|
+
{
|
|
2
|
+
"trailingComma": "none",
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"arrowParens": "avoid",
|
|
5
|
+
"jsxSingleQuote": true
|
|
6
6
|
}
|
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# Testing Framework
|
|
2
|
-
|
|
3
|
-
## Framework that abstracts the configuration for playwright and Jest
|
|
4
|
-
|
|
5
|
-
- Playwright
|
|
6
|
-
- Jest
|
|
7
|
-
|
|
8
|
-
## Cli
|
|
9
|
-
|
|
10
|
-
## Feature Supported
|
|
11
|
-
|
|
12
|
-
### Run TestCase
|
|
13
|
-
|
|
14
|
-
- npm run test
|
|
15
|
-
### Generate Report
|
|
16
|
-
|
|
17
|
-
- npm run report
|
|
1
|
+
# Testing Framework
|
|
2
|
+
|
|
3
|
+
## Framework that abstracts the configuration for playwright and Jest
|
|
4
|
+
|
|
5
|
+
- Playwright
|
|
6
|
+
- Jest
|
|
7
|
+
|
|
8
|
+
## Cli
|
|
9
|
+
|
|
10
|
+
## Feature Supported
|
|
11
|
+
|
|
12
|
+
### Run TestCase
|
|
13
|
+
|
|
14
|
+
- npm run test
|
|
15
|
+
### Generate Report
|
|
16
|
+
|
|
17
|
+
- npm run report
|
|
18
18
|
|
package/bin/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
3
|
require('../build/lib/cli');
|
|
@@ -28,9 +28,9 @@ function showPackageVersion(packageName) {
|
|
|
28
28
|
const version = packageName === 'playwright-bdd' ? getOwnVersion() : (0, _utils.getPackageVersion)(packageName);
|
|
29
29
|
logger.log(`${packageName}: v${version}`);
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Getting own version by relative path instead of using getPackageVersion(),
|
|
33
|
-
* to aneble using directly from /dist in tests.
|
|
31
|
+
/**
|
|
32
|
+
* Getting own version by relative path instead of using getPackageVersion(),
|
|
33
|
+
* to aneble using directly from /dist in tests.
|
|
34
34
|
*/
|
|
35
35
|
function getOwnVersion() {
|
|
36
36
|
return '5.6.0';
|
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.configOption = void 0;
|
|
7
7
|
exports.getCliConfigPath = getCliConfigPath;
|
|
8
8
|
var _commander = require("commander");
|
|
9
|
-
/**
|
|
10
|
-
* Config option moved to separate file as it used in test run.
|
|
9
|
+
/**
|
|
10
|
+
* Config option moved to separate file as it used in test run.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const configOption = exports.configOption = new _commander.Option(`-c, --config <file>`, `Path to Playwright configuration file (default: playwright.config.(js|ts))`);
|
|
14
|
-
/**
|
|
15
|
-
* Helper used in test run to detect config location.
|
|
14
|
+
/**
|
|
15
|
+
* Helper used in test run to detect config location.
|
|
16
16
|
*/
|
|
17
17
|
function getCliConfigPath() {
|
|
18
18
|
return new _commander.Command().allowUnknownOption().addOption(configOption).parse().getOptionValue('config');
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _worker_threads = require("worker_threads");
|
|
4
4
|
var _gen = require("../gen");
|
|
5
|
-
/**
|
|
6
|
-
* Worker to generate test files with fresh require/import cache
|
|
7
|
-
* See: https://github.com/nodejs/modules/issues/307#issuecomment-858729422
|
|
5
|
+
/**
|
|
6
|
+
* Worker to generate test files with fresh require/import cache
|
|
7
|
+
* See: https://github.com/nodejs/modules/issues/307#issuecomment-858729422
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
async function main() {
|
|
@@ -8,14 +8,14 @@ exports.getPlaywrightConfigDir = getPlaywrightConfigDir;
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _loadConfig = require("../playwright/loadConfig");
|
|
10
10
|
var _options = require("../cli/options");
|
|
11
|
-
/**
|
|
12
|
-
* Store playwright config dir in env to provide access to it in workers.
|
|
13
|
-
* Important that in workers there is different process.argv, that's why we save it to env.
|
|
14
|
-
* Config dir is needed to resolve all paths.
|
|
11
|
+
/**
|
|
12
|
+
* Store playwright config dir in env to provide access to it in workers.
|
|
13
|
+
* Important that in workers there is different process.argv, that's why we save it to env.
|
|
14
|
+
* Config dir is needed to resolve all paths.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Resolve playwright config dir considering cli flags.
|
|
17
|
+
/**
|
|
18
|
+
* Resolve playwright config dir considering cli flags.
|
|
19
19
|
*/
|
|
20
20
|
function getPlaywrightConfigDir() {
|
|
21
21
|
if (!process.env.PLAYWRIGHT_BDD_CONFIG_DIR) {
|
|
@@ -9,9 +9,9 @@ exports.getEnvConfigs = getEnvConfigs;
|
|
|
9
9
|
exports.saveConfigToEnv = saveConfigToEnv;
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
var _exit = require("../utils/exit");
|
|
12
|
-
/**
|
|
13
|
-
* Storing configs in env var PLAYWRIGHT_BDD_CONFIGS as JSON-stringified values.
|
|
14
|
-
* For passing configs to playwright workers and bddgen.
|
|
12
|
+
/**
|
|
13
|
+
* Storing configs in env var PLAYWRIGHT_BDD_CONFIGS as JSON-stringified values.
|
|
14
|
+
* For passing configs to playwright workers and bddgen.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
function saveConfigToEnv(config) {
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.LANG_EN = void 0;
|
|
7
7
|
exports.isEnglish = isEnglish;
|
|
8
|
-
/**
|
|
9
|
-
* Helpers for Cucumber language option.
|
|
8
|
+
/**
|
|
9
|
+
* Helpers for Cucumber language option.
|
|
10
10
|
*/
|
|
11
11
|
const LANG_EN = exports.LANG_EN = 'en';
|
|
12
12
|
function isEnglish(lang) {
|
|
@@ -8,9 +8,9 @@ exports.buildStepDefinition = buildStepDefinition;
|
|
|
8
8
|
var _messages = require("@cucumber/messages");
|
|
9
9
|
var _cucumberExpressions = require("@cucumber/cucumber-expressions");
|
|
10
10
|
var _step_definition = _interopRequireDefault(require("@cucumber/cucumber/lib/models/step_definition"));
|
|
11
|
-
/**
|
|
12
|
-
* Extracted from cucumber SupportCodeLibraryBuilder.
|
|
13
|
-
* See: https://github.com/cucumber/cucumber-js/blob/main/src/support_code_library_builder/index.ts
|
|
11
|
+
/**
|
|
12
|
+
* Extracted from cucumber SupportCodeLibraryBuilder.
|
|
13
|
+
* See: https://github.com/cucumber/cucumber-js/blob/main/src/support_code_library_builder/index.ts
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
const newId = _messages.IdGenerator.uuid();
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.loadSnippetBuilder = loadSnippetBuilder;
|
|
7
7
|
var _cucumber = require("@cucumber/cucumber");
|
|
8
|
-
/**
|
|
9
|
-
* Loads snippet builder
|
|
10
|
-
* See: https://github.com/cucumber/cucumber-js/blob/main/src/formatter/builder.ts
|
|
8
|
+
/**
|
|
9
|
+
* Loads snippet builder
|
|
10
|
+
* See: https://github.com/cucumber/cucumber-js/blob/main/src/formatter/builder.ts
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
async function loadSnippetBuilder(supportCodeLibrary, snippetInterface, snippetSyntax) {
|
|
@@ -9,17 +9,17 @@ var _messages = require("@cucumber/messages");
|
|
|
9
9
|
var _environment = require("@cucumber/cucumber/lib/api/environment");
|
|
10
10
|
var _gherkin = require("@cucumber/cucumber/lib/api/gherkin");
|
|
11
11
|
var _console_logger = require("@cucumber/cucumber/lib/api/console_logger");
|
|
12
|
-
/**
|
|
13
|
-
* Copied from original load_sources, but returns full Pickles.
|
|
14
|
-
* See: https://github.com/cucumber/cucumber-js/blob/main/src/api/load_sources.ts
|
|
12
|
+
/**
|
|
13
|
+
* Copied from original load_sources, but returns full Pickles.
|
|
14
|
+
* See: https://github.com/cucumber/cucumber-js/blob/main/src/api/load_sources.ts
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Load and parse features, produce a filtered and ordered test plan and/or parse errors.
|
|
19
|
-
*
|
|
20
|
-
* @public
|
|
21
|
-
* @param coordinates - Coordinates required to find features
|
|
22
|
-
* @param environment - Project environment.
|
|
17
|
+
/**
|
|
18
|
+
* Load and parse features, produce a filtered and ordered test plan and/or parse errors.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @param coordinates - Coordinates required to find features
|
|
22
|
+
* @param environment - Project environment.
|
|
23
23
|
*/
|
|
24
24
|
async function loadSources(coordinates, environment = {}) {
|
|
25
25
|
const {
|
|
@@ -9,18 +9,18 @@ var _fixtureParameterNames = require("../playwright/fixtureParameterNames");
|
|
|
9
9
|
var _bddFixtures = require("../run/bddFixtures");
|
|
10
10
|
var _exit = require("../utils/exit");
|
|
11
11
|
const bodyFixturesSymbol = Symbol('bodyFixtures');
|
|
12
|
-
/**
|
|
13
|
-
* This function is used for playwright-style steps and decorators.
|
|
14
|
-
* It extracts fixtures names from first parameter of function
|
|
15
|
-
* using Playwright's helper.
|
|
12
|
+
/**
|
|
13
|
+
* This function is used for playwright-style steps and decorators.
|
|
14
|
+
* It extracts fixtures names from first parameter of function
|
|
15
|
+
* using Playwright's helper.
|
|
16
16
|
*/
|
|
17
17
|
function extractFixtureNames(fn) {
|
|
18
18
|
return (0, _fixtureParameterNames.fixtureParameterNames)(fn).filter(name => !(0, _bddFixtures.isBddAutoInjectFixture)(name));
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* This function is used for cucumber-style steps.
|
|
22
|
-
* It looks for `this.useFixture('xxx')` entries in function body
|
|
23
|
-
* and extracts fixtures names from it.
|
|
20
|
+
/**
|
|
21
|
+
* This function is used for cucumber-style steps.
|
|
22
|
+
* It looks for `this.useFixture('xxx')` entries in function body
|
|
23
|
+
* and extracts fixtures names from it.
|
|
24
24
|
*/
|
|
25
25
|
function extractFixtureNamesFromFnBodyMemo(fn) {
|
|
26
26
|
if (typeof fn !== 'function') {
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Formatter = void 0;
|
|
7
7
|
var _jsStringWrap = require("../utils/jsStringWrap");
|
|
8
|
-
/**
|
|
9
|
-
* Helper to format Playwright test file.
|
|
8
|
+
/**
|
|
9
|
+
* Helper to format Playwright test file.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const TAGS_FIXTURE_TEST_KEY_SEPARATOR = '|';
|
|
@@ -117,11 +117,11 @@ class Formatter {
|
|
|
117
117
|
}
|
|
118
118
|
return '';
|
|
119
119
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Apply this function only to string literals (mostly titles here).
|
|
122
|
-
* Objects and arrays are handled with JSON.strinigfy,
|
|
123
|
-
* b/c object keys can't be in backtiks.
|
|
124
|
-
* See: https://stackoverflow.com/questions/33194138/template-string-as-object-property-name
|
|
120
|
+
/**
|
|
121
|
+
* Apply this function only to string literals (mostly titles here).
|
|
122
|
+
* Objects and arrays are handled with JSON.strinigfy,
|
|
123
|
+
* b/c object keys can't be in backtiks.
|
|
124
|
+
* See: https://stackoverflow.com/questions/33194138/template-string-as-object-property-name
|
|
125
125
|
*/
|
|
126
126
|
quoted(str) {
|
|
127
127
|
return (0, _jsStringWrap.jsStringWrap)(str, {
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getKeywordsMap = getKeywordsMap;
|
|
7
7
|
var _gherkin = require("@cucumber/gherkin");
|
|
8
|
-
/**
|
|
9
|
-
* Get i18n keywords.
|
|
10
|
-
* See: https://github.com/cucumber/cucumber-js/blob/main/src/cli/i18n.ts
|
|
8
|
+
/**
|
|
9
|
+
* Get i18n keywords.
|
|
10
|
+
* See: https://github.com/cucumber/cucumber-js/blob/main/src/cli/i18n.ts
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
function getKeywordsMap(language) {
|
|
@@ -21,8 +21,8 @@ var _logger = require("../utils/logger");
|
|
|
21
21
|
var _tagExpressions = _interopRequireDefault(require("@cucumber/tag-expressions"));
|
|
22
22
|
var _exit = require("../utils/exit");
|
|
23
23
|
var _createBdd = require("../stepDefinitions/createBdd");
|
|
24
|
-
/**
|
|
25
|
-
* Generate playwright test files from Gherkin documents.
|
|
24
|
+
/**
|
|
25
|
+
* Generate playwright test files from Gherkin documents.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
class TestFilesGenerator {
|
|
@@ -20,8 +20,8 @@ var _fixtures = require("./fixtures");
|
|
|
20
20
|
var _scenario = require("../hooks/scenario");
|
|
21
21
|
var _worker = require("../hooks/worker");
|
|
22
22
|
var _lang = require("../config/lang");
|
|
23
|
-
/**
|
|
24
|
-
* Generate test code.
|
|
23
|
+
/**
|
|
24
|
+
* Generate test code.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
class TestFile {
|
|
@@ -116,8 +116,8 @@ class TestFile {
|
|
|
116
116
|
}
|
|
117
117
|
return this.getSuite(feature);
|
|
118
118
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Generate test.describe suite for root Feature or Rule
|
|
119
|
+
/**
|
|
120
|
+
* Generate test.describe suite for root Feature or Rule
|
|
121
121
|
*/
|
|
122
122
|
getSuite(feature, parent) {
|
|
123
123
|
const node = new _testNode.TestNode(feature, parent);
|
|
@@ -143,8 +143,8 @@ class TestFile {
|
|
|
143
143
|
getScenarioLines(scenario, parent) {
|
|
144
144
|
return this.isOutline(scenario) ? this.getOutlineSuite(scenario, parent) : this.getTest(scenario, parent);
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Generate test.beforeEach for Background
|
|
146
|
+
/**
|
|
147
|
+
* Generate test.beforeEach for Background
|
|
148
148
|
*/
|
|
149
149
|
getBeforeEach(bg, parent) {
|
|
150
150
|
const node = new _testNode.TestNode({
|
|
@@ -157,8 +157,8 @@ class TestFile {
|
|
|
157
157
|
} = this.getSteps(bg, node.tags);
|
|
158
158
|
return this.formatter.beforeEach(fixtures, lines);
|
|
159
159
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Generate test.describe suite for Scenario Outline
|
|
160
|
+
/**
|
|
161
|
+
* Generate test.describe suite for Scenario Outline
|
|
162
162
|
*/
|
|
163
163
|
getOutlineSuite(scenario, parent) {
|
|
164
164
|
const node = new _testNode.TestNode(scenario, parent);
|
|
@@ -177,8 +177,8 @@ class TestFile {
|
|
|
177
177
|
});
|
|
178
178
|
return this.formatter.suite(node, lines);
|
|
179
179
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Generate test from Examples row of Scenario Outline
|
|
180
|
+
/**
|
|
181
|
+
* Generate test from Examples row of Scenario Outline
|
|
182
182
|
*/
|
|
183
183
|
// eslint-disable-next-line max-params
|
|
184
184
|
getOutlineTest(scenario, examples, exampleRow, title, parent) {
|
|
@@ -199,8 +199,8 @@ class TestFile {
|
|
|
199
199
|
} = this.getSteps(scenario, node.tags, exampleRow.id);
|
|
200
200
|
return this.formatter.test(node, fixtures, lines);
|
|
201
201
|
}
|
|
202
|
-
/**
|
|
203
|
-
* Generate test from Scenario
|
|
202
|
+
/**
|
|
203
|
+
* Generate test from Scenario
|
|
204
204
|
*/
|
|
205
205
|
getTest(scenario, parent) {
|
|
206
206
|
const node = new _testNode.TestNode(scenario, parent);
|
|
@@ -217,8 +217,8 @@ class TestFile {
|
|
|
217
217
|
} = this.getSteps(scenario, node.tags);
|
|
218
218
|
return this.formatter.test(node, fixtures, lines);
|
|
219
219
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Generate test steps
|
|
220
|
+
/**
|
|
221
|
+
* Generate test steps
|
|
222
222
|
*/
|
|
223
223
|
getSteps(scenario, tags, outlineExampleRowId) {
|
|
224
224
|
const testFixtureNames = new Set();
|
|
@@ -267,8 +267,8 @@ class TestFile {
|
|
|
267
267
|
lines
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Generate step for Given, When, Then
|
|
270
|
+
/**
|
|
271
|
+
* Generate step for Given, When, Then
|
|
272
272
|
*/
|
|
273
273
|
// eslint-disable-next-line max-statements, complexity
|
|
274
274
|
getStep(step, previousKeywordType, outlineExampleRowId) {
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TestNode = void 0;
|
|
7
7
|
var _utils = require("../utils");
|
|
8
|
-
/**
|
|
9
|
-
* Universal TestNode class of parent-child relations in test file structure.
|
|
10
|
-
* Holds tags and titles path.
|
|
8
|
+
/**
|
|
9
|
+
* Universal TestNode class of parent-child relations in test file structure.
|
|
10
|
+
* Holds tags and titles path.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const SPECIAL_TAGS = ['@only', '@skip', '@fixme'];
|
|
@@ -7,27 +7,27 @@ exports.TestPoms = void 0;
|
|
|
7
7
|
exports.buildFixtureTag = buildFixtureTag;
|
|
8
8
|
var _class = require("../stepDefinitions/decorators/class");
|
|
9
9
|
var _exit = require("../utils/exit");
|
|
10
|
-
/**
|
|
11
|
-
* Track PomNodes used in the particular test.
|
|
12
|
-
* To select correct fixture for decorator steps.
|
|
13
|
-
*
|
|
14
|
-
* Idea: try to use the deepest child fixture for parent steps.
|
|
15
|
-
*
|
|
16
|
-
* Example inheritance tree:
|
|
17
|
-
* A
|
|
18
|
-
* / \
|
|
19
|
-
* B C
|
|
20
|
-
* / \ \
|
|
21
|
-
* D E F
|
|
22
|
-
*
|
|
23
|
-
* If test uses steps from classes A and D:
|
|
24
|
-
* -> resolved fixture will be D, even for steps from A.
|
|
25
|
-
*
|
|
26
|
-
* If test uses steps from classes A, D and C:
|
|
27
|
-
* -> error, b/c A has 2 possible fixtures.
|
|
28
|
-
*
|
|
29
|
-
* If test uses steps from classes A and C, but @fixture tag is D:
|
|
30
|
-
* -> error, b/c A has 2 possible fixtures.
|
|
10
|
+
/**
|
|
11
|
+
* Track PomNodes used in the particular test.
|
|
12
|
+
* To select correct fixture for decorator steps.
|
|
13
|
+
*
|
|
14
|
+
* Idea: try to use the deepest child fixture for parent steps.
|
|
15
|
+
*
|
|
16
|
+
* Example inheritance tree:
|
|
17
|
+
* A
|
|
18
|
+
* / \
|
|
19
|
+
* B C
|
|
20
|
+
* / \ \
|
|
21
|
+
* D E F
|
|
22
|
+
*
|
|
23
|
+
* If test uses steps from classes A and D:
|
|
24
|
+
* -> resolved fixture will be D, even for steps from A.
|
|
25
|
+
*
|
|
26
|
+
* If test uses steps from classes A, D and C:
|
|
27
|
+
* -> error, b/c A has 2 possible fixtures.
|
|
28
|
+
*
|
|
29
|
+
* If test uses steps from classes A and C, but @fixture tag is D:
|
|
30
|
+
* -> error, b/c A has 2 possible fixtures.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
const FIXTURE_TAG_PREFIX = '@fixture:';
|
|
@@ -58,18 +58,18 @@ class TestPoms {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Resolve all used pomNodes to fixtures.
|
|
63
|
-
* This is needed to handle @fixture: tagged pomNodes
|
|
64
|
-
* that does not have steps in the test, but should be considered.
|
|
61
|
+
/**
|
|
62
|
+
* Resolve all used pomNodes to fixtures.
|
|
63
|
+
* This is needed to handle @fixture: tagged pomNodes
|
|
64
|
+
* that does not have steps in the test, but should be considered.
|
|
65
65
|
*/
|
|
66
66
|
resolveFixtures() {
|
|
67
67
|
this.usedPoms.forEach((_, pomNode) => {
|
|
68
68
|
this.getResolvedFixtures(pomNode);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Returns fixtures suitable for particular pomNode (actually for step)
|
|
71
|
+
/**
|
|
72
|
+
* Returns fixtures suitable for particular pomNode (actually for step)
|
|
73
73
|
*/
|
|
74
74
|
getResolvedFixtures(pomNode) {
|
|
75
75
|
const usedPom = this.usedPoms.get(pomNode);
|
|
@@ -109,10 +109,10 @@ class TestPoms {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* For scenarios with @fixture:xxx tags verify that there are no steps from fixtures,
|
|
114
|
-
* deeper than xxx.
|
|
115
|
-
* @fixture:xxx tag provides maximum fixture that can be used in the scenario.
|
|
112
|
+
/**
|
|
113
|
+
* For scenarios with @fixture:xxx tags verify that there are no steps from fixtures,
|
|
114
|
+
* deeper than xxx.
|
|
115
|
+
* @fixture:xxx tag provides maximum fixture that can be used in the scenario.
|
|
116
116
|
*/
|
|
117
117
|
verifyChildFixtures(pomNode, usedPom, childFixtures) {
|
|
118
118
|
if (!usedPom.byTag) {
|
|
@@ -11,16 +11,16 @@ exports.scenarioHookFactory = scenarioHookFactory;
|
|
|
11
11
|
var _tagExpressions = _interopRequireDefault(require("@cucumber/tag-expressions"));
|
|
12
12
|
var _fixtureParameterNames = require("../playwright/fixtureParameterNames");
|
|
13
13
|
var _utils = require("../utils");
|
|
14
|
-
/**
|
|
15
|
-
* Scenario level hooks: Before / After.
|
|
16
|
-
*
|
|
17
|
-
* before(async ({ page }) => {})
|
|
14
|
+
/**
|
|
15
|
+
* Scenario level hooks: Before / After.
|
|
16
|
+
*
|
|
17
|
+
* before(async ({ page }) => {})
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
const scenarioHooks = [];
|
|
21
21
|
let scenarioHooksFixtures;
|
|
22
|
-
/**
|
|
23
|
-
* Returns Before() / After() functions.
|
|
22
|
+
/**
|
|
23
|
+
* Returns Before() / After() functions.
|
|
24
24
|
*/
|
|
25
25
|
function scenarioHookFactory(type) {
|
|
26
26
|
return (...args) => {
|
|
@@ -8,14 +8,14 @@ exports.runWorkerHooks = runWorkerHooks;
|
|
|
8
8
|
exports.workerHookFactory = workerHookFactory;
|
|
9
9
|
var _fixtureParameterNames = require("../playwright/fixtureParameterNames");
|
|
10
10
|
var _utils = require("../utils");
|
|
11
|
-
/**
|
|
12
|
-
* Worker-level hooks: BeforeAll / AfterAll.
|
|
11
|
+
/**
|
|
12
|
+
* Worker-level hooks: BeforeAll / AfterAll.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
const workerHooks = [];
|
|
16
16
|
let workerHooksFixtures;
|
|
17
|
-
/**
|
|
18
|
-
* Returns BeforeAll() / AfterAll() functions.
|
|
17
|
+
/**
|
|
18
|
+
* Returns BeforeAll() / AfterAll() functions.
|
|
19
19
|
*/
|
|
20
20
|
function workerHookFactory(type) {
|
|
21
21
|
return (...args) => {
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.fixtureParameterNames = fixtureParameterNames;
|
|
7
|
-
/**
|
|
8
|
-
* Extracted from playwright.
|
|
9
|
-
* https://github.com/microsoft/playwright/blob/main/packages/playwright-test/src/common/fixtures.ts#L226
|
|
7
|
+
/**
|
|
8
|
+
* Extracted from playwright.
|
|
9
|
+
* https://github.com/microsoft/playwright/blob/main/packages/playwright-test/src/common/fixtures.ts#L226
|
|
10
10
|
*/
|
|
11
11
|
/* eslint-disable max-statements, complexity, max-len, max-depth */
|
|
12
12
|
const signatureSymbol = Symbol('signature');
|