@zohodesk/testinglibrary 0.0.5-exp.25 → 0.0.5-exp.26
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 +0 -1
- package/build/bdd-framework/cli/commands/env.js +21 -12
- package/build/bdd-framework/cli/commands/export.js +23 -15
- package/build/bdd-framework/cli/commands/test.js +28 -19
- package/build/bdd-framework/cli/index.js +9 -7
- package/build/bdd-framework/cli/options.js +13 -4
- package/build/bdd-framework/cli/worker.js +6 -3
- package/build/bdd-framework/config/dir.js +15 -7
- package/build/bdd-framework/config/env.js +18 -8
- package/build/bdd-framework/config/index.js +24 -13
- package/build/bdd-framework/cucumber/buildStepDefinition.js +15 -7
- package/build/bdd-framework/cucumber/gherkin.d.js +5 -1
- package/build/bdd-framework/cucumber/loadConfig.js +9 -3
- package/build/bdd-framework/cucumber/loadFeatures.js +11 -5
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +10 -3
- package/build/bdd-framework/cucumber/loadSources.js +18 -11
- package/build/bdd-framework/cucumber/loadSteps.js +17 -9
- package/build/bdd-framework/decorators.js +22 -7
- package/build/bdd-framework/gen/formatter.js +11 -3
- package/build/bdd-framework/gen/i18n.js +10 -3
- package/build/bdd-framework/gen/index.js +50 -41
- package/build/bdd-framework/gen/poms.js +12 -4
- package/build/bdd-framework/gen/testFile.js +44 -35
- package/build/bdd-framework/gen/testNode.js +12 -4
- package/build/bdd-framework/gen/testPoms.js +16 -7
- package/build/bdd-framework/index.js +45 -4
- package/build/bdd-framework/playwright/fixtureParameterNames.js +7 -1
- package/build/bdd-framework/playwright/getLocationInFile.js +12 -5
- package/build/bdd-framework/playwright/loadConfig.js +21 -12
- package/build/bdd-framework/playwright/testTypeImpl.js +13 -5
- package/build/bdd-framework/playwright/transform.js +23 -15
- package/build/bdd-framework/playwright/types.js +5 -4
- package/build/bdd-framework/playwright/utils.js +18 -10
- package/build/bdd-framework/run/bddFixtures.js +26 -18
- package/build/bdd-framework/run/bddWorld.js +20 -12
- package/build/bdd-framework/snippets/index.js +20 -12
- package/build/bdd-framework/snippets/snippetSyntax.js +9 -2
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +9 -2
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +12 -3
- package/build/bdd-framework/stepDefinitions/createBdd.js +20 -12
- package/build/bdd-framework/stepDefinitions/createDecorators.js +19 -10
- package/build/bdd-framework/stepDefinitions/decorators/poms.js +12 -4
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +18 -9
- package/build/bdd-framework/stepDefinitions/defineStep.js +18 -10
- package/build/bdd-framework/stepDefinitions/stepConfig.js +11 -3
- package/build/bdd-framework/utils/index.js +25 -13
- package/build/bdd-framework/utils/jsStringWrap.js +7 -1
- package/build/bdd-framework/utils/logger.js +10 -2
- package/build/core/jest/preprocessor/jsPreprocessor.js +11 -3
- package/build/core/jest/runner/jest-runner.js +13 -6
- package/build/core/jest/setup/index.js +9 -167
- package/build/core/playwright/codegen.js +18 -11
- package/build/core/playwright/custom-commands.js +8 -1
- package/build/core/playwright/env-initializer.js +11 -5
- package/build/core/playwright/index.js +28 -7
- package/build/core/playwright/readConfigFile.js +22 -12
- package/build/core/playwright/report-generator.js +21 -14
- package/build/core/playwright/setup/config-creator.js +30 -22
- package/build/core/playwright/test-runner.js +39 -32
- package/build/index.d.ts +1 -0
- package/build/index.js +36 -13
- package/build/lib/cli.js +21 -17
- package/build/lib/post-install.js +11 -8
- package/build/lint/index.js +2 -1
- package/build/parser/parser.js +26 -18
- package/build/parser/sample.spec.js +7 -5
- package/build/parser/verifier.js +26 -24
- package/build/setup-folder-structure/setupProject.js +42 -35
- package/build/utils/cliArgsToObject.js +8 -2
- package/build/utils/fileUtils.js +18 -9
- package/build/utils/getFilePath.js +9 -3
- package/build/utils/logger.js +8 -1
- package/build/utils/rootPath.js +21 -12
- package/changelog.md +4 -0
- package/package.json +1 -1
package/.babelrc
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.envCommand = void 0;
|
|
8
|
+
exports.getOwnVersion = getOwnVersion;
|
|
9
|
+
var _commander = require("commander");
|
|
10
|
+
var _options = require("../options");
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
var _logger = require("../../utils/logger");
|
|
13
|
+
var _utils = require("../../utils");
|
|
14
|
+
var _loadConfig = require("../../playwright/loadConfig");
|
|
15
|
+
const logger = new _logger.Logger({
|
|
8
16
|
verbose: true
|
|
9
17
|
});
|
|
10
|
-
|
|
18
|
+
const envCommand = new _commander.Command('env').description('Prints environment info').addOption(_options.configOption).action(opts => {
|
|
11
19
|
logger.log(`Playwright-bdd environment info:\n`);
|
|
12
20
|
logger.log(`platform: ${process.platform}`);
|
|
13
21
|
logger.log(`node: ${process.version}`);
|
|
@@ -16,19 +24,20 @@ export const envCommand = new Command('env').description('Prints environment inf
|
|
|
16
24
|
showPackageVersion('@cucumber/cucumber');
|
|
17
25
|
showPlaywrightConfigPath(opts.config);
|
|
18
26
|
});
|
|
27
|
+
exports.envCommand = envCommand;
|
|
19
28
|
function showPackageVersion(packageName) {
|
|
20
|
-
const version = packageName === 'playwright-bdd' ? getOwnVersion() : getPackageVersion(packageName);
|
|
29
|
+
const version = packageName === 'playwright-bdd' ? getOwnVersion() : (0, _utils.getPackageVersion)(packageName);
|
|
21
30
|
logger.log(`${packageName}: v${version}`);
|
|
22
31
|
}
|
|
23
32
|
/**
|
|
24
33
|
* Getting own version by relative path instead of using getPackageVersion(),
|
|
25
34
|
* to aneble using directly from /dist in tests.
|
|
26
35
|
*/
|
|
27
|
-
|
|
36
|
+
function getOwnVersion() {
|
|
28
37
|
return '5.3.0';
|
|
29
38
|
}
|
|
30
39
|
function showPlaywrightConfigPath(cliConfigPath) {
|
|
31
|
-
const resolvedConfigFile = resolveConfigFile(cliConfigPath);
|
|
32
|
-
const relPath =
|
|
40
|
+
const resolvedConfigFile = (0, _loadConfig.resolveConfigFile)(cliConfigPath);
|
|
41
|
+
const relPath = _path.default.relative(process.cwd(), resolvedConfigFile);
|
|
33
42
|
logger.log(`Playwright config file: ${relPath}`);
|
|
34
43
|
}
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.exportCommand = void 0;
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _commander = require("commander");
|
|
10
|
+
var _options = require("../options");
|
|
11
|
+
var _loadConfig = require("../../playwright/loadConfig");
|
|
12
|
+
var _logger = require("../../utils/logger");
|
|
13
|
+
var _env = require("../../config/env");
|
|
14
|
+
var _test = require("./test");
|
|
15
|
+
var _gen = require("../../gen");
|
|
16
|
+
const logger = new _logger.Logger({
|
|
10
17
|
verbose: true
|
|
11
18
|
});
|
|
12
|
-
|
|
19
|
+
const exportCommand = new _commander.Command('export').description('Prints all step definitions').addOption(_options.configOption).action(async opts => {
|
|
13
20
|
const {
|
|
14
21
|
resolvedConfigFile
|
|
15
|
-
} = await
|
|
16
|
-
logger.log(`List of all steps found by config: ${
|
|
17
|
-
const configs = Object.values(getEnvConfigs());
|
|
18
|
-
assertConfigsCount(configs);
|
|
22
|
+
} = await (0, _loadConfig.loadConfig)(opts.config);
|
|
23
|
+
logger.log(`List of all steps found by config: ${_path.default.relative(process.cwd(), resolvedConfigFile)}\n`);
|
|
24
|
+
const configs = Object.values((0, _env.getEnvConfigs)());
|
|
25
|
+
(0, _test.assertConfigsCount)(configs);
|
|
19
26
|
await showStepsForConfigs(configs);
|
|
20
27
|
});
|
|
28
|
+
exports.exportCommand = exportCommand;
|
|
21
29
|
async function showStepsForConfigs(configs) {
|
|
22
30
|
// here we don't need workers (as in test command) because if some step files
|
|
23
31
|
// are already in node cache, we collected them.
|
|
24
32
|
const steps = new Set();
|
|
25
33
|
const tasks = configs.map(async config => {
|
|
26
|
-
const stepDefinitions = await new TestFilesGenerator(config).extractSteps();
|
|
34
|
+
const stepDefinitions = await new _gen.TestFilesGenerator(config).extractSteps();
|
|
27
35
|
stepDefinitions.forEach(s => steps.add(`* ${getStepText(s)}`));
|
|
28
36
|
});
|
|
29
37
|
await Promise.all(tasks);
|
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.assertConfigsCount = assertConfigsCount;
|
|
8
|
+
exports.testCommand = void 0;
|
|
9
|
+
var _worker_threads = require("worker_threads");
|
|
10
|
+
var _events = require("events");
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
var _commander = require("commander");
|
|
13
|
+
var _gen = require("../../gen");
|
|
14
|
+
var _utils = require("../../utils");
|
|
15
|
+
var _loadConfig = require("../../playwright/loadConfig");
|
|
16
|
+
var _env = require("../../config/env");
|
|
17
|
+
var _config = require("../../config");
|
|
18
|
+
var _options = require("../options");
|
|
19
|
+
const GEN_WORKER_PATH = _path.default.resolve(__dirname, '..', 'worker.js');
|
|
20
|
+
const testCommand = new _commander.Command('test').description('Generate Playwright test files from Gherkin documents').addOption(_options.configOption).option('--tags <expression>', `Tags expression to filter scenarios for generation`).option('--verbose', `Verbose mode (default: ${Boolean(_config.defaults.verbose)})`).action(async opts => {
|
|
21
|
+
await (0, _loadConfig.loadConfig)(opts.config);
|
|
22
|
+
const configs = Object.values((0, _env.getEnvConfigs)());
|
|
15
23
|
assertConfigsCount(configs);
|
|
16
24
|
const cliOptions = buildCliOptions(opts);
|
|
17
25
|
await generateFilesForConfigs(configs, cliOptions);
|
|
18
26
|
});
|
|
27
|
+
exports.testCommand = testCommand;
|
|
19
28
|
function buildCliOptions(opts) {
|
|
20
29
|
const config = {};
|
|
21
30
|
if ('tags' in opts) config.tags = opts.tags;
|
|
22
31
|
if ('verbose' in opts) config.verbose = Boolean(opts.verbose);
|
|
23
32
|
return config;
|
|
24
33
|
}
|
|
25
|
-
|
|
34
|
+
function assertConfigsCount(configs) {
|
|
26
35
|
if (configs.length === 0) {
|
|
27
|
-
exitWithMessage(`No BDD configs found. Did you use defineBddConfig() in playwright.config.ts?`);
|
|
36
|
+
(0, _utils.exitWithMessage)(`No BDD configs found. Did you use defineBddConfig() in playwright.config.ts?`);
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
async function generateFilesForConfigs(configs, cliConfig) {
|
|
@@ -35,16 +44,16 @@ async function generateFilesForConfigs(configs, cliConfig) {
|
|
|
35
44
|
...config,
|
|
36
45
|
...cliConfig
|
|
37
46
|
};
|
|
38
|
-
return index === 0 ? new TestFilesGenerator(finalConfig).generate() : runInWorker(finalConfig);
|
|
47
|
+
return index === 0 ? new _gen.TestFilesGenerator(finalConfig).generate() : runInWorker(finalConfig);
|
|
39
48
|
});
|
|
40
49
|
return Promise.all(tasks);
|
|
41
50
|
}
|
|
42
51
|
async function runInWorker(config) {
|
|
43
|
-
const worker = new Worker(GEN_WORKER_PATH, {
|
|
52
|
+
const worker = new _worker_threads.Worker(GEN_WORKER_PATH, {
|
|
44
53
|
workerData: {
|
|
45
54
|
config
|
|
46
55
|
}
|
|
47
56
|
});
|
|
48
57
|
// todo: check if worker exited with error?
|
|
49
|
-
await once(worker, 'exit');
|
|
58
|
+
await (0, _events.once)(worker, 'exit');
|
|
50
59
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var _test = require("./commands/test");
|
|
6
|
+
var _env = require("./commands/env");
|
|
7
|
+
var _export = require("./commands/export");
|
|
8
|
+
const program = new _commander.Command();
|
|
9
|
+
program.name('bddgen').description(`Playwright-bdd CLI v${(0, _env.getOwnVersion)()}`).addCommand(_test.testCommand, {
|
|
8
10
|
isDefault: true
|
|
9
|
-
}).addCommand(exportCommand).addCommand(envCommand).addHelpCommand(false).parse();
|
|
11
|
+
}).addCommand(_export.exportCommand).addCommand(_env.envCommand).addHelpCommand(false).parse();
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.configOption = void 0;
|
|
7
|
+
exports.getCliConfigPath = getCliConfigPath;
|
|
8
|
+
var _commander = require("commander");
|
|
1
9
|
/**
|
|
2
10
|
* Config option moved to separate file as it used in test run.
|
|
3
11
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
12
|
+
|
|
13
|
+
const configOption = new _commander.Option(`-c, --config <file>`, `Path to Playwright configuration file (default: playwright.config.(js|ts))`);
|
|
6
14
|
/**
|
|
7
15
|
* Helper used in test run to detect config location.
|
|
8
16
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
exports.configOption = configOption;
|
|
18
|
+
function getCliConfigPath() {
|
|
19
|
+
return new _commander.Command().allowUnknownOption().addOption(configOption).parse().getOptionValue('config');
|
|
11
20
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _worker_threads = require("worker_threads");
|
|
4
|
+
var _gen = require("../gen");
|
|
1
5
|
/**
|
|
2
6
|
* Worker to generate test files with fresh require/import cache
|
|
3
7
|
* See: https://github.com/nodejs/modules/issues/307#issuecomment-858729422
|
|
4
8
|
*/
|
|
5
|
-
|
|
6
|
-
import { TestFilesGenerator } from '../gen';
|
|
9
|
+
|
|
7
10
|
async function main() {
|
|
8
|
-
await new TestFilesGenerator(workerData.config).generate();
|
|
11
|
+
await new _gen.TestFilesGenerator(_worker_threads.workerData.config).generate();
|
|
9
12
|
}
|
|
10
13
|
main();
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getPlaywrightConfigDir = getPlaywrightConfigDir;
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _loadConfig = require("../playwright/loadConfig");
|
|
10
|
+
var _options = require("../cli/options");
|
|
1
11
|
/**
|
|
2
12
|
* Store playwright config dir in env to provide access to it in workers.
|
|
3
13
|
* Important that in workers there is different process.argv, that's why we save it to env.
|
|
4
14
|
* Config dir is needed to resolve all paths.
|
|
5
15
|
*/
|
|
6
|
-
|
|
7
|
-
import { resolveConfigFile } from '../playwright/loadConfig';
|
|
8
|
-
import { getCliConfigPath } from '../cli/options';
|
|
16
|
+
|
|
9
17
|
/**
|
|
10
18
|
* Resolve playwright config dir considering cli flags.
|
|
11
19
|
*/
|
|
12
|
-
|
|
20
|
+
function getPlaywrightConfigDir() {
|
|
13
21
|
if (!process.env.PLAYWRIGHT_BDD_CONFIG_DIR) {
|
|
14
|
-
const cliConfigPath = getCliConfigPath();
|
|
15
|
-
const playwrightConfigFile = resolveConfigFile(cliConfigPath);
|
|
16
|
-
process.env.PLAYWRIGHT_BDD_CONFIG_DIR = playwrightConfigFile ?
|
|
22
|
+
const cliConfigPath = (0, _options.getCliConfigPath)();
|
|
23
|
+
const playwrightConfigFile = (0, _loadConfig.resolveConfigFile)(cliConfigPath);
|
|
24
|
+
process.env.PLAYWRIGHT_BDD_CONFIG_DIR = playwrightConfigFile ? _path.default.dirname(playwrightConfigFile) : process.cwd();
|
|
17
25
|
}
|
|
18
26
|
return process.env.PLAYWRIGHT_BDD_CONFIG_DIR;
|
|
19
27
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getConfigFromEnv = getConfigFromEnv;
|
|
8
|
+
exports.getEnvConfigs = getEnvConfigs;
|
|
9
|
+
exports.saveConfigToEnv = saveConfigToEnv;
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _utils = require("../utils");
|
|
1
12
|
/**
|
|
2
13
|
* Storing configs in env var PLAYWRIGHT_BDD_CONFIGS as JSON-stringified values.
|
|
3
14
|
* For passing configs to playwright workers and bddgen.
|
|
4
15
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function saveConfigToEnv(config) {
|
|
16
|
+
|
|
17
|
+
function saveConfigToEnv(config) {
|
|
8
18
|
const envConfigs = getEnvConfigs();
|
|
9
19
|
const existingConfig = envConfigs[config.outputDir];
|
|
10
20
|
if (existingConfig) {
|
|
@@ -12,23 +22,23 @@ export function saveConfigToEnv(config) {
|
|
|
12
22
|
// Throw error only if different calls of defineBddConfig() use the same outputDir.
|
|
13
23
|
// See: https://github.com/vitalets/playwright-bdd/issues/39#issuecomment-1653805368
|
|
14
24
|
if (!isSameConfigs(config, existingConfig)) {
|
|
15
|
-
exitWithMessage(`When using several calls of defineBddConfig()`, `please manually provide different "outputDir" option.`);
|
|
25
|
+
(0, _utils.exitWithMessage)(`When using several calls of defineBddConfig()`, `please manually provide different "outputDir" option.`);
|
|
16
26
|
}
|
|
17
27
|
return;
|
|
18
28
|
}
|
|
19
29
|
envConfigs[config.outputDir] = config;
|
|
20
30
|
saveEnvConfigs(envConfigs);
|
|
21
31
|
}
|
|
22
|
-
|
|
32
|
+
function getConfigFromEnv(outputDir) {
|
|
23
33
|
const envConfigs = getEnvConfigs();
|
|
24
|
-
outputDir =
|
|
34
|
+
outputDir = _path.default.resolve(outputDir);
|
|
25
35
|
const config = envConfigs[outputDir];
|
|
26
36
|
if (!config) {
|
|
27
|
-
exitWithMessage(`Config not found for outputDir: "${outputDir}".`, `Available dirs: ${Object.keys(envConfigs).join('\n')}`);
|
|
37
|
+
(0, _utils.exitWithMessage)(`Config not found for outputDir: "${outputDir}".`, `Available dirs: ${Object.keys(envConfigs).join('\n')}`);
|
|
28
38
|
}
|
|
29
39
|
return config;
|
|
30
40
|
}
|
|
31
|
-
|
|
41
|
+
function getEnvConfigs() {
|
|
32
42
|
return JSON.parse(process.env.PLAYWRIGHT_BDD_CONFIGS || '{}');
|
|
33
43
|
}
|
|
34
44
|
function saveEnvConfigs(envConfigs) {
|
|
@@ -1,38 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.defaults = void 0;
|
|
8
|
+
exports.defineBddConfig = defineBddConfig;
|
|
9
|
+
exports.extractCucumberConfig = extractCucumberConfig;
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _env = require("./env");
|
|
12
|
+
var _dir = require("./dir");
|
|
13
|
+
var _utils = require("../utils");
|
|
1
14
|
/**
|
|
2
15
|
* BDD Config.
|
|
3
16
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { getPlaywrightConfigDir } from './dir';
|
|
7
|
-
import { getPackageVersion } from '../utils';
|
|
8
|
-
export const defaults = {
|
|
17
|
+
|
|
18
|
+
const defaults = {
|
|
9
19
|
outputDir: '.features-gen',
|
|
10
20
|
verbose: false,
|
|
11
21
|
examplesTitleFormat: 'Example #<_index_>',
|
|
12
22
|
publishQuiet: true,
|
|
13
23
|
quotes: 'double'
|
|
14
24
|
};
|
|
15
|
-
|
|
25
|
+
exports.defaults = defaults;
|
|
26
|
+
function defineBddConfig(inputConfig) {
|
|
16
27
|
const config = getConfig(inputConfig);
|
|
17
28
|
// In main process store config in env to be accessible by workers
|
|
18
29
|
if (!process.env.TEST_WORKER_INDEX) {
|
|
19
|
-
saveConfigToEnv(config);
|
|
30
|
+
(0, _env.saveConfigToEnv)(config);
|
|
20
31
|
}
|
|
21
32
|
return config.outputDir;
|
|
22
33
|
}
|
|
23
34
|
function getConfig(inputConfig) {
|
|
24
35
|
const config = Object.assign({}, defaults, inputConfig);
|
|
25
|
-
const configDir = getPlaywrightConfigDir();
|
|
26
|
-
const featuresRoot = config.featuresRoot ?
|
|
36
|
+
const configDir = (0, _dir.getPlaywrightConfigDir)();
|
|
37
|
+
const featuresRoot = config.featuresRoot ? _path.default.resolve(configDir, config.featuresRoot) : configDir;
|
|
27
38
|
return {
|
|
28
39
|
...config,
|
|
29
40
|
// important to resolve outputDir as it is used as unique key for input configs
|
|
30
|
-
outputDir:
|
|
41
|
+
outputDir: _path.default.resolve(configDir, config.outputDir),
|
|
31
42
|
importTestFrom: resolveImportTestFrom(configDir, config.importTestFrom),
|
|
32
43
|
featuresRoot
|
|
33
44
|
};
|
|
34
45
|
}
|
|
35
|
-
|
|
46
|
+
function extractCucumberConfig(config) {
|
|
36
47
|
// todo: find more strict way to omit own config fields
|
|
37
48
|
// see: https://bobbyhadz.com/blog/typescript-object-remove-property
|
|
38
49
|
const omitProps = {
|
|
@@ -62,13 +73,13 @@ function resolveImportTestFrom(configDir, importTestFrom) {
|
|
|
62
73
|
file: importTestFrom
|
|
63
74
|
} : importTestFrom;
|
|
64
75
|
return {
|
|
65
|
-
file:
|
|
76
|
+
file: _path.default.resolve(configDir, file),
|
|
66
77
|
varName
|
|
67
78
|
};
|
|
68
79
|
}
|
|
69
80
|
}
|
|
70
81
|
function stripPublishQuiet(cucumberConfig) {
|
|
71
|
-
const cucumberVersion = getPackageVersion('@cucumber/cucumber');
|
|
82
|
+
const cucumberVersion = (0, _utils.getPackageVersion)('@cucumber/cucumber');
|
|
72
83
|
// Playwright-bdd supports Cucumber from v9+
|
|
73
84
|
// publishQuiet was deprecated in Cucumber 9.4.0.
|
|
74
85
|
// See: https://github.com/cucumber/cucumber-js/pull/2311
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.buildStepDefinition = buildStepDefinition;
|
|
8
|
+
var _messages = require("@cucumber/messages");
|
|
9
|
+
var _cucumberExpressions = require("@cucumber/cucumber-expressions");
|
|
10
|
+
var _step_definition = _interopRequireDefault(require("@cucumber/cucumber/lib/models/step_definition"));
|
|
1
11
|
/**
|
|
2
12
|
* Extracted from cucumber SupportCodeLibraryBuilder.
|
|
3
13
|
* See: https://github.com/cucumber/cucumber-js/blob/main/src/support_code_library_builder/index.ts
|
|
4
14
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const newId = IdGenerator.uuid();
|
|
9
|
-
export function buildStepDefinition({
|
|
15
|
+
|
|
16
|
+
const newId = _messages.IdGenerator.uuid();
|
|
17
|
+
function buildStepDefinition({
|
|
10
18
|
keyword,
|
|
11
19
|
pattern,
|
|
12
20
|
code,
|
|
@@ -15,13 +23,13 @@ export function buildStepDefinition({
|
|
|
15
23
|
uri
|
|
16
24
|
}, supportCodeLibrary) {
|
|
17
25
|
// todo: handle error.undefinedParameterTypeName as it's done in cucumber?
|
|
18
|
-
const expression = typeof pattern === 'string' ? new CucumberExpression(pattern, supportCodeLibrary.parameterTypeRegistry) : new RegularExpression(pattern, supportCodeLibrary.parameterTypeRegistry);
|
|
26
|
+
const expression = typeof pattern === 'string' ? new _cucumberExpressions.CucumberExpression(pattern, supportCodeLibrary.parameterTypeRegistry) : new _cucumberExpressions.RegularExpression(pattern, supportCodeLibrary.parameterTypeRegistry);
|
|
19
27
|
// skip wrapping code as it is not needed for decorator steps
|
|
20
28
|
// const wrappedCode = this.wrapCode({
|
|
21
29
|
// code,
|
|
22
30
|
// wrapperOptions: options.wrapperOptions,
|
|
23
31
|
// })
|
|
24
|
-
return new
|
|
32
|
+
return new _step_definition.default({
|
|
25
33
|
code,
|
|
26
34
|
expression,
|
|
27
35
|
id: newId(),
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadConfig = loadConfig;
|
|
7
|
+
var _api = require("@cucumber/cucumber/api");
|
|
2
8
|
const cache = new Map();
|
|
3
|
-
|
|
9
|
+
async function loadConfig(options, environment) {
|
|
4
10
|
const cacheKey = JSON.stringify(options);
|
|
5
11
|
let config = cache.get(cacheKey);
|
|
6
12
|
if (!config) {
|
|
7
|
-
config = loadConfiguration(options, environment);
|
|
13
|
+
config = (0, _api.loadConfiguration)(options, environment);
|
|
8
14
|
cache.set(cacheKey, config);
|
|
9
15
|
}
|
|
10
16
|
return config;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadFeatures = loadFeatures;
|
|
7
|
+
var _loadSources = require("./loadSources");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
async function loadFeatures(runConfiguration, environment) {
|
|
4
10
|
const {
|
|
5
11
|
filteredPickles,
|
|
6
12
|
parseErrors
|
|
7
|
-
} = await loadSources(runConfiguration.sources, environment);
|
|
13
|
+
} = await (0, _loadSources.loadSources)(runConfiguration.sources, environment);
|
|
8
14
|
handleParseErrors(parseErrors);
|
|
9
15
|
return groupByDocument(filteredPickles);
|
|
10
16
|
}
|
|
@@ -28,6 +34,6 @@ function handleParseErrors(parseErrors) {
|
|
|
28
34
|
const message = parseErrors.map(parseError => {
|
|
29
35
|
return `Parse error in "${parseError.source.uri}" ${parseError.message}`;
|
|
30
36
|
}).join('\n');
|
|
31
|
-
exitWithMessage(message);
|
|
37
|
+
(0, _utils.exitWithMessage)(message);
|
|
32
38
|
}
|
|
33
39
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadSnippetBuilder = loadSnippetBuilder;
|
|
7
|
+
var _cucumber = require("@cucumber/cucumber");
|
|
1
8
|
/**
|
|
2
9
|
* Loads snippet builder
|
|
3
10
|
* See: https://github.com/cucumber/cucumber-js/blob/main/src/formatter/builder.ts
|
|
4
11
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return FormatterBuilder.getStepDefinitionSnippetBuilder({
|
|
12
|
+
|
|
13
|
+
async function loadSnippetBuilder(supportCodeLibrary, snippetInterface, snippetSyntax) {
|
|
14
|
+
return _cucumber.FormatterBuilder.getStepDefinitionSnippetBuilder({
|
|
8
15
|
cwd: process.cwd(),
|
|
9
16
|
snippetInterface,
|
|
10
17
|
snippetSyntax,
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadSources = loadSources;
|
|
7
|
+
var _paths = require("@cucumber/cucumber/lib/api/paths");
|
|
8
|
+
var _messages = require("@cucumber/messages");
|
|
9
|
+
var _environment = require("@cucumber/cucumber/lib/api/environment");
|
|
10
|
+
var _gherkin = require("@cucumber/cucumber/lib/api/gherkin");
|
|
11
|
+
var _console_logger = require("@cucumber/cucumber/lib/api/console_logger");
|
|
1
12
|
/**
|
|
2
13
|
* Copied from original load_sources, but returns full Pickles.
|
|
3
14
|
* See: https://github.com/cucumber/cucumber-js/blob/main/src/api/load_sources.ts
|
|
4
15
|
*/
|
|
5
|
-
|
|
6
|
-
import { IdGenerator } from '@cucumber/messages';
|
|
7
|
-
import { mergeEnvironment } from '@cucumber/cucumber/lib/api/environment';
|
|
8
|
-
import { getFilteredPicklesAndErrors } from '@cucumber/cucumber/lib/api/gherkin';
|
|
9
|
-
import { ConsoleLogger } from '@cucumber/cucumber/lib/api/console_logger';
|
|
16
|
+
|
|
10
17
|
/**
|
|
11
18
|
* Load and parse features, produce a filtered and ordered test plan and/or parse errors.
|
|
12
19
|
*
|
|
@@ -14,18 +21,18 @@ import { ConsoleLogger } from '@cucumber/cucumber/lib/api/console_logger';
|
|
|
14
21
|
* @param coordinates - Coordinates required to find features
|
|
15
22
|
* @param environment - Project environment.
|
|
16
23
|
*/
|
|
17
|
-
|
|
24
|
+
async function loadSources(coordinates, environment = {}) {
|
|
18
25
|
const {
|
|
19
26
|
cwd,
|
|
20
27
|
stderr,
|
|
21
28
|
debug
|
|
22
|
-
} = mergeEnvironment(environment);
|
|
23
|
-
const logger = new ConsoleLogger(stderr, debug);
|
|
24
|
-
const newId = IdGenerator.uuid();
|
|
29
|
+
} = (0, _environment.mergeEnvironment)(environment);
|
|
30
|
+
const logger = new _console_logger.ConsoleLogger(stderr, debug);
|
|
31
|
+
const newId = _messages.IdGenerator.uuid();
|
|
25
32
|
const {
|
|
26
33
|
unexpandedFeaturePaths,
|
|
27
34
|
featurePaths
|
|
28
|
-
} = await resolvePaths(logger, cwd, coordinates);
|
|
35
|
+
} = await (0, _paths.resolvePaths)(logger, cwd, coordinates);
|
|
29
36
|
if (featurePaths.length === 0) {
|
|
30
37
|
return {
|
|
31
38
|
filteredPickles: [],
|
|
@@ -35,7 +42,7 @@ export async function loadSources(coordinates, environment = {}) {
|
|
|
35
42
|
const {
|
|
36
43
|
filteredPickles,
|
|
37
44
|
parseErrors
|
|
38
|
-
} = await getFilteredPicklesAndErrors({
|
|
45
|
+
} = await (0, _gherkin.getFilteredPicklesAndErrors)({
|
|
39
46
|
newId,
|
|
40
47
|
cwd,
|
|
41
48
|
logger,
|