@zohodesk/testinglibrary 0.1.8-exp-bdd-v2 → 0.1.8-exp-bdd-v3
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/build/bdd-poc/test/stepGenerate/stepFileGenerate.js +1 -1
- package/build/core/playwright/index.js +6 -18
- package/build/core/playwright/setup/config-utils.js +14 -13
- package/build/core/playwright/test-runner.js +30 -26
- package/build/decorators.d.ts +1 -1
- package/build/decorators.js +2 -16
- package/package.json +1 -1
- package/build/bdd-framework/cli/commands/env.js +0 -43
- package/build/bdd-framework/cli/commands/export.js +0 -48
- package/build/bdd-framework/cli/commands/test.js +0 -61
- package/build/bdd-framework/cli/index.js +0 -11
- package/build/bdd-framework/cli/options.js +0 -20
- package/build/bdd-framework/cli/worker.js +0 -13
- package/build/bdd-framework/config/dir.js +0 -27
- package/build/bdd-framework/config/env.js +0 -49
- package/build/bdd-framework/config/index.js +0 -91
- package/build/bdd-framework/cucumber/buildStepDefinition.js +0 -43
- package/build/bdd-framework/cucumber/gherkin.d.js +0 -5
- package/build/bdd-framework/cucumber/gherkin.d.ts +0 -45
- package/build/bdd-framework/cucumber/loadConfig.js +0 -17
- package/build/bdd-framework/cucumber/loadFeatures.js +0 -39
- package/build/bdd-framework/cucumber/loadSnippetBuilder.js +0 -20
- package/build/bdd-framework/cucumber/loadSources.js +0 -57
- package/build/bdd-framework/cucumber/loadSteps.js +0 -35
- package/build/bdd-framework/decorators.js +0 -22
- package/build/bdd-framework/gen/formatter.js +0 -88
- package/build/bdd-framework/gen/i18n.js +0 -35
- package/build/bdd-framework/gen/index.js +0 -163
- package/build/bdd-framework/gen/poms.js +0 -46
- package/build/bdd-framework/gen/testFile.js +0 -356
- package/build/bdd-framework/gen/testNode.js +0 -48
- package/build/bdd-framework/gen/testPoms.js +0 -123
- package/build/bdd-framework/index.js +0 -45
- package/build/bdd-framework/playwright/fixtureParameterNames.js +0 -77
- package/build/bdd-framework/playwright/getLocationInFile.js +0 -46
- package/build/bdd-framework/playwright/loadConfig.js +0 -42
- package/build/bdd-framework/playwright/testTypeImpl.js +0 -57
- package/build/bdd-framework/playwright/transform.js +0 -80
- package/build/bdd-framework/playwright/types.js +0 -5
- package/build/bdd-framework/playwright/utils.js +0 -37
- package/build/bdd-framework/run/bddFixtures.js +0 -108
- package/build/bdd-framework/run/bddWorld.js +0 -88
- package/build/bdd-framework/snippets/index.js +0 -135
- package/build/bdd-framework/snippets/snippetSyntax.js +0 -41
- package/build/bdd-framework/snippets/snippetSyntaxDecorators.js +0 -26
- package/build/bdd-framework/snippets/snippetSyntaxTs.js +0 -18
- package/build/bdd-framework/stepDefinitions/createBdd.js +0 -49
- package/build/bdd-framework/stepDefinitions/createDecorators.js +0 -109
- package/build/bdd-framework/stepDefinitions/decorators/poms.js +0 -64
- package/build/bdd-framework/stepDefinitions/decorators/steps.js +0 -94
- package/build/bdd-framework/stepDefinitions/defineStep.js +0 -61
- package/build/bdd-framework/stepDefinitions/stepConfig.js +0 -24
- package/build/bdd-framework/utils/exit.js +0 -54
- package/build/bdd-framework/utils/index.js +0 -44
- package/build/bdd-framework/utils/jsStringWrap.js +0 -44
- package/build/bdd-framework/utils/logger.js +0 -29
|
@@ -13,7 +13,7 @@ var _testStructure = require("../testStructure");
|
|
|
13
13
|
async function stepFileCreation(featureContent, stepFilename, featureFilePath) {
|
|
14
14
|
const generatedFolderPath = _path.default.resolve(process.cwd(), 'uat', 'feature-gen');
|
|
15
15
|
if (!(0, _fs.existsSync)(generatedFolderPath)) {
|
|
16
|
-
(0, _fs.mkdirSync)(
|
|
16
|
+
(0, _fs.mkdirSync)(generatedFolderPath, {
|
|
17
17
|
recursive: true
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -3,13 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.When = exports.Then = exports.Given = void 0;
|
|
7
|
-
Object.defineProperty(exports, "createBdd", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _bddFramework.createBdd;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
6
|
Object.defineProperty(exports, "expect", {
|
|
14
7
|
enumerable: true,
|
|
15
8
|
get: function () {
|
|
@@ -17,9 +10,10 @@ Object.defineProperty(exports, "expect", {
|
|
|
17
10
|
}
|
|
18
11
|
});
|
|
19
12
|
exports.test = void 0;
|
|
20
|
-
var _bddFramework = require("../../bdd-framework");
|
|
21
13
|
var _test = require("@playwright/test");
|
|
22
14
|
var _readConfigFile = require("./readConfigFile");
|
|
15
|
+
// import { createBdd, test as bddBase } from '../../bdd-framework';
|
|
16
|
+
|
|
23
17
|
// function test(descrition, callback) {
|
|
24
18
|
// return test(descrition, ({ page }) => {
|
|
25
19
|
// const { locator, ...custompage } = page
|
|
@@ -54,7 +48,7 @@ const {
|
|
|
54
48
|
additionalPages,
|
|
55
49
|
bddMode
|
|
56
50
|
} = (0, _readConfigFile.generateConfigFromFile)();
|
|
57
|
-
let base = bddMode ?
|
|
51
|
+
let base = bddMode ? bddBase : _test.test;
|
|
58
52
|
const test = base.extend({
|
|
59
53
|
page: async ({
|
|
60
54
|
page
|
|
@@ -101,12 +95,6 @@ const test = base.extend({
|
|
|
101
95
|
},
|
|
102
96
|
...additionalPages
|
|
103
97
|
});
|
|
104
|
-
|
|
105
|
-
const {
|
|
106
|
-
|
|
107
|
-
When,
|
|
108
|
-
Then
|
|
109
|
-
} = (0, _bddFramework.createBdd)();
|
|
110
|
-
exports.Then = Then;
|
|
111
|
-
exports.When = When;
|
|
112
|
-
exports.Given = Given;
|
|
98
|
+
|
|
99
|
+
// const { Given, When, Then } = createBdd();
|
|
100
|
+
exports.test = test;
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getProjects = getProjects;
|
|
8
|
-
exports.getTestDir = getTestDir;
|
|
9
8
|
var _test = require("@playwright/test");
|
|
10
9
|
var _path = _interopRequireDefault(require("path"));
|
|
11
10
|
var _readConfigFile = require("../readConfigFile");
|
|
12
|
-
|
|
11
|
+
// import { defineBddConfig } from '../../../bdd-framework';
|
|
12
|
+
|
|
13
13
|
function getBrowserConfig({
|
|
14
14
|
browserName,
|
|
15
15
|
isAuthMode,
|
|
@@ -98,14 +98,15 @@ function getProjects({
|
|
|
98
98
|
viewport
|
|
99
99
|
})).filter(Boolean);
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
|
|
102
|
+
// function getTestDir(bddMode, cwd, { stepDefinitionsFolder }) {
|
|
103
|
+
// return bddMode
|
|
104
|
+
// ? defineBddConfig({
|
|
105
|
+
// paths: [path.join(cwd, 'uat', '**', '*.feature')],
|
|
106
|
+
// import: [path.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
|
|
107
|
+
// featuresRoot: path.join(cwd, 'uat'),
|
|
108
|
+
// outputDir: path.join(cwd, 'uat', '.features-gen'),
|
|
109
|
+
// publish: true,
|
|
110
|
+
// })
|
|
111
|
+
// : path.join(cwd, 'uat');
|
|
112
|
+
// }
|
|
@@ -31,32 +31,36 @@ function getPlaywrightArgs(userArgsObject, debug, bddMode, tagArgs, headless) {
|
|
|
31
31
|
}
|
|
32
32
|
return playwrightArgs;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
34
|
+
|
|
35
|
+
// function runPreprocessing(tagArgs, configPath) {
|
|
36
|
+
// const beforeCommand = 'node';
|
|
37
|
+
// const bddGenPath = path.resolve(__dirname, '../', '../', 'bdd-framework', 'cli', 'index.js');
|
|
38
|
+
// const beforeArgs = [bddGenPath, '-c', configPath];
|
|
39
|
+
|
|
40
|
+
// if (tagArgs) {
|
|
41
|
+
// beforeArgs.push('--tags');
|
|
42
|
+
// beforeArgs.push(tagArgs);
|
|
43
|
+
// }
|
|
44
|
+
|
|
45
|
+
// return new Promise((resolve, reject) => {
|
|
46
|
+
// const childProcessForPreprocessing = spawn(beforeCommand, beforeArgs, { stdio: 'inherit' });
|
|
47
|
+
|
|
48
|
+
// childProcessForPreprocessing.on('error', (data) => {
|
|
49
|
+
// Logger.log(Logger.FAILURE_TYPE, data);
|
|
50
|
+
// reject();
|
|
51
|
+
// });
|
|
52
|
+
|
|
53
|
+
// childProcessForPreprocessing.on('exit', (code) => {
|
|
54
|
+
// if (code === 0) {
|
|
55
|
+
// Logger.log(Logger.SUCCESS_TYPE, 'Feature Files Processed Successfully');
|
|
56
|
+
// resolve();
|
|
57
|
+
// } else {
|
|
58
|
+
// reject(`BddGen exited with code ${code}`);
|
|
59
|
+
// }
|
|
60
|
+
// });
|
|
61
|
+
// });
|
|
62
|
+
// }
|
|
63
|
+
|
|
60
64
|
function runPlaywright(command, args) {
|
|
61
65
|
return new Promise((resolve, reject) => {
|
|
62
66
|
const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
|
package/build/decorators.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './bdd-framework/decorators';
|
|
1
|
+
// export * from './bdd-framework/decorators';
|
package/build/decorators.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _decorators = require("./bdd-framework/decorators");
|
|
7
|
-
Object.keys(_decorators).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _decorators[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _decorators[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
// export * from './bdd-framework/decorators';
|
|
2
|
+
"use strict";
|
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
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({
|
|
16
|
-
verbose: true
|
|
17
|
-
});
|
|
18
|
-
const envCommand = new _commander.Command('env').description('Prints environment info').addOption(_options.configOption).action(opts => {
|
|
19
|
-
logger.log(`Playwright-bdd environment info:\n`);
|
|
20
|
-
logger.log(`platform: ${process.platform}`);
|
|
21
|
-
logger.log(`node: ${process.version}`);
|
|
22
|
-
showPackageVersion('playwright-bdd');
|
|
23
|
-
showPackageVersion('@playwright/test');
|
|
24
|
-
showPackageVersion('@cucumber/cucumber');
|
|
25
|
-
showPlaywrightConfigPath(opts.config);
|
|
26
|
-
});
|
|
27
|
-
exports.envCommand = envCommand;
|
|
28
|
-
function showPackageVersion(packageName) {
|
|
29
|
-
const version = packageName === 'playwright-bdd' ? getOwnVersion() : (0, _utils.getPackageVersion)(packageName);
|
|
30
|
-
logger.log(`${packageName}: v${version}`);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Getting own version by relative path instead of using getPackageVersion(),
|
|
34
|
-
* to aneble using directly from /dist in tests.
|
|
35
|
-
*/
|
|
36
|
-
function getOwnVersion() {
|
|
37
|
-
return '5.4.0';
|
|
38
|
-
}
|
|
39
|
-
function showPlaywrightConfigPath(cliConfigPath) {
|
|
40
|
-
const resolvedConfigFile = (0, _loadConfig.resolveConfigFile)(cliConfigPath);
|
|
41
|
-
const relPath = _path.default.relative(process.cwd(), resolvedConfigFile);
|
|
42
|
-
logger.log(`Playwright config file: ${relPath}`);
|
|
43
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
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({
|
|
17
|
-
verbose: true
|
|
18
|
-
});
|
|
19
|
-
const exportCommand = new _commander.Command('export').description('Prints all step definitions').addOption(_options.configOption).action(async opts => {
|
|
20
|
-
const {
|
|
21
|
-
resolvedConfigFile
|
|
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);
|
|
26
|
-
await showStepsForConfigs(configs);
|
|
27
|
-
});
|
|
28
|
-
exports.exportCommand = exportCommand;
|
|
29
|
-
async function showStepsForConfigs(configs) {
|
|
30
|
-
// here we don't need workers (as in test command) because if some step files
|
|
31
|
-
// are already in node cache, we collected them.
|
|
32
|
-
const steps = new Set();
|
|
33
|
-
const tasks = configs.map(async config => {
|
|
34
|
-
const stepDefinitions = await new _gen.TestFilesGenerator(config).extractSteps();
|
|
35
|
-
stepDefinitions.forEach(s => steps.add(`* ${getStepText(s)}`));
|
|
36
|
-
});
|
|
37
|
-
await Promise.all(tasks);
|
|
38
|
-
steps.forEach(stepText => logger.log(stepText));
|
|
39
|
-
}
|
|
40
|
-
function getStepText({
|
|
41
|
-
pattern,
|
|
42
|
-
keyword
|
|
43
|
-
}) {
|
|
44
|
-
// for Unknown return When as it looks the most suitable
|
|
45
|
-
const keywordText = keyword === 'Unknown' ? 'When' : keyword;
|
|
46
|
-
const patternText = typeof pattern === 'string' ? pattern : pattern.source;
|
|
47
|
-
return `${keywordText} ${patternText}`;
|
|
48
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
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 _loadConfig = require("../../playwright/loadConfig");
|
|
15
|
-
var _env = require("../../config/env");
|
|
16
|
-
var _config = require("../../config");
|
|
17
|
-
var _options = require("../options");
|
|
18
|
-
var _exit = require("../../utils/exit");
|
|
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 = readConfigsFromEnv();
|
|
23
|
-
mergeCliOptions(configs, opts);
|
|
24
|
-
await generateFilesForConfigs(configs);
|
|
25
|
-
});
|
|
26
|
-
exports.testCommand = testCommand;
|
|
27
|
-
function readConfigsFromEnv() {
|
|
28
|
-
const configs = Object.values((0, _env.getEnvConfigs)());
|
|
29
|
-
assertConfigsCount(configs);
|
|
30
|
-
return configs;
|
|
31
|
-
}
|
|
32
|
-
function mergeCliOptions(configs, opts) {
|
|
33
|
-
configs.forEach(config => {
|
|
34
|
-
if ('tags' in opts) config.tags = opts.tags;
|
|
35
|
-
if ('verbose' in opts) config.verbose = Boolean(opts.verbose);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
function assertConfigsCount(configs) {
|
|
39
|
-
if (configs.length === 0) {
|
|
40
|
-
(0, _exit.exit)(`No BDD configs found. Did you use defineBddConfig() in playwright.config.ts?`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async function generateFilesForConfigs(configs) {
|
|
44
|
-
// run first config in main thread and other in workers (to have fresh require cache)
|
|
45
|
-
// See: https://github.com/vitalets/playwright-bdd/issues/32
|
|
46
|
-
const tasks = configs.map((config, index) => {
|
|
47
|
-
return index === 0 ? new _gen.TestFilesGenerator(config).generate() : runInWorker(config);
|
|
48
|
-
});
|
|
49
|
-
return Promise.all(tasks);
|
|
50
|
-
}
|
|
51
|
-
async function runInWorker(config) {
|
|
52
|
-
const worker = new _worker_threads.Worker(GEN_WORKER_PATH, {
|
|
53
|
-
workerData: {
|
|
54
|
-
config
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
const [exitCode] = await (0, _events.once)(worker, 'exit');
|
|
58
|
-
if (exitCode) {
|
|
59
|
-
(0, _exit.exit)();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
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, {
|
|
10
|
-
isDefault: true
|
|
11
|
-
}).addCommand(_export.exportCommand).addCommand(_env.envCommand).addHelpCommand(false).parse();
|
|
@@ -1,20 +0,0 @@
|
|
|
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");
|
|
9
|
-
/**
|
|
10
|
-
* Config option moved to separate file as it used in test run.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const 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.
|
|
16
|
-
*/
|
|
17
|
-
exports.configOption = configOption;
|
|
18
|
-
function getCliConfigPath() {
|
|
19
|
-
return new _commander.Command().allowUnknownOption().addOption(configOption).parse().getOptionValue('config');
|
|
20
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _worker_threads = require("worker_threads");
|
|
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
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
await new _gen.TestFilesGenerator(_worker_threads.workerData.config).generate();
|
|
12
|
-
}
|
|
13
|
-
main();
|
|
@@ -1,27 +0,0 @@
|
|
|
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");
|
|
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
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Resolve playwright config dir considering cli flags.
|
|
19
|
-
*/
|
|
20
|
-
function getPlaywrightConfigDir() {
|
|
21
|
-
if (!process.env.PLAYWRIGHT_BDD_CONFIG_DIR) {
|
|
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();
|
|
25
|
-
}
|
|
26
|
-
return process.env.PLAYWRIGHT_BDD_CONFIG_DIR;
|
|
27
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
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 _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.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
function saveConfigToEnv(config) {
|
|
18
|
-
const envConfigs = getEnvConfigs();
|
|
19
|
-
const existingConfig = envConfigs[config.outputDir];
|
|
20
|
-
if (existingConfig) {
|
|
21
|
-
// Playwright config can be evaluated several times.
|
|
22
|
-
// Throw error only if different calls of defineBddConfig() use the same outputDir.
|
|
23
|
-
// See: https://github.com/vitalets/playwright-bdd/issues/39#issuecomment-1653805368
|
|
24
|
-
if (!isSameConfigs(config, existingConfig)) {
|
|
25
|
-
(0, _exit.exit)(`When using several calls of defineBddConfig()`, `please manually provide different "outputDir" option.`);
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
envConfigs[config.outputDir] = config;
|
|
30
|
-
saveEnvConfigs(envConfigs);
|
|
31
|
-
}
|
|
32
|
-
function getConfigFromEnv(outputDir) {
|
|
33
|
-
const envConfigs = getEnvConfigs();
|
|
34
|
-
outputDir = _path.default.resolve(outputDir);
|
|
35
|
-
const config = envConfigs[outputDir];
|
|
36
|
-
if (!config) {
|
|
37
|
-
(0, _exit.exit)(`Config not found for outputDir: "${outputDir}".`, `Available dirs: ${Object.keys(envConfigs).join('\n')}`);
|
|
38
|
-
}
|
|
39
|
-
return config;
|
|
40
|
-
}
|
|
41
|
-
function getEnvConfigs() {
|
|
42
|
-
return JSON.parse(process.env.PLAYWRIGHT_BDD_CONFIGS || '{}');
|
|
43
|
-
}
|
|
44
|
-
function saveEnvConfigs(envConfigs) {
|
|
45
|
-
process.env.PLAYWRIGHT_BDD_CONFIGS = JSON.stringify(envConfigs);
|
|
46
|
-
}
|
|
47
|
-
function isSameConfigs(config1, config2) {
|
|
48
|
-
return JSON.stringify(config1) === JSON.stringify(config2);
|
|
49
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
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");
|
|
14
|
-
/**
|
|
15
|
-
* BDD Config.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const defaults = {
|
|
19
|
-
outputDir: '.features-gen',
|
|
20
|
-
verbose: false,
|
|
21
|
-
examplesTitleFormat: 'Example #<_index_>',
|
|
22
|
-
publishQuiet: true,
|
|
23
|
-
quotes: 'double'
|
|
24
|
-
};
|
|
25
|
-
exports.defaults = defaults;
|
|
26
|
-
function defineBddConfig(inputConfig) {
|
|
27
|
-
const config = getConfig(inputConfig);
|
|
28
|
-
// In main process store config in env to be accessible by workers
|
|
29
|
-
if (!process.env.TEST_WORKER_INDEX) {
|
|
30
|
-
(0, _env.saveConfigToEnv)(config);
|
|
31
|
-
}
|
|
32
|
-
return config.outputDir;
|
|
33
|
-
}
|
|
34
|
-
function getConfig(inputConfig) {
|
|
35
|
-
const config = Object.assign({}, defaults, inputConfig);
|
|
36
|
-
const configDir = (0, _dir.getPlaywrightConfigDir)();
|
|
37
|
-
const featuresRoot = config.featuresRoot ? _path.default.resolve(configDir, config.featuresRoot) : configDir;
|
|
38
|
-
return {
|
|
39
|
-
...config,
|
|
40
|
-
// important to resolve outputDir as it is used as unique key for input configs
|
|
41
|
-
outputDir: _path.default.resolve(configDir, config.outputDir),
|
|
42
|
-
importTestFrom: resolveImportTestFrom(configDir, config.importTestFrom),
|
|
43
|
-
featuresRoot
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function extractCucumberConfig(config) {
|
|
47
|
-
// todo: find more strict way to omit own config fields
|
|
48
|
-
// see: https://bobbyhadz.com/blog/typescript-object-remove-property
|
|
49
|
-
const omitProps = {
|
|
50
|
-
outputDir: true,
|
|
51
|
-
importTestFrom: true,
|
|
52
|
-
verbose: true,
|
|
53
|
-
skip: true,
|
|
54
|
-
examplesTitleFormat: true,
|
|
55
|
-
quotes: true,
|
|
56
|
-
tags: true,
|
|
57
|
-
featuresRoot: true
|
|
58
|
-
};
|
|
59
|
-
const keys = Object.keys(omitProps);
|
|
60
|
-
const cucumberConfig = {
|
|
61
|
-
...config
|
|
62
|
-
};
|
|
63
|
-
keys.forEach(key => delete cucumberConfig[key]);
|
|
64
|
-
stripPublishQuiet(cucumberConfig);
|
|
65
|
-
return cucumberConfig;
|
|
66
|
-
}
|
|
67
|
-
function resolveImportTestFrom(configDir, importTestFrom) {
|
|
68
|
-
if (importTestFrom) {
|
|
69
|
-
const {
|
|
70
|
-
file,
|
|
71
|
-
varName
|
|
72
|
-
} = typeof importTestFrom === 'string' ? {
|
|
73
|
-
file: importTestFrom
|
|
74
|
-
} : importTestFrom;
|
|
75
|
-
return {
|
|
76
|
-
file: _path.default.resolve(configDir, file),
|
|
77
|
-
varName
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function stripPublishQuiet(cucumberConfig) {
|
|
82
|
-
const cucumberVersion = (0, _utils.getPackageVersion)('@cucumber/cucumber');
|
|
83
|
-
// Playwright-bdd supports Cucumber from v9+
|
|
84
|
-
// publishQuiet was deprecated in Cucumber 9.4.0.
|
|
85
|
-
// See: https://github.com/cucumber/cucumber-js/pull/2311
|
|
86
|
-
// Remove publishQuite from Cucumber config to hide deprecation warning.
|
|
87
|
-
// See: https://github.com/vitalets/playwright-bdd/pull/47
|
|
88
|
-
if (!/^9\.[0123]\./.test(cucumberVersion)) {
|
|
89
|
-
delete cucumberConfig.publishQuiet;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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"));
|
|
11
|
-
/**
|
|
12
|
-
* Extracted from cucumber SupportCodeLibraryBuilder.
|
|
13
|
-
* See: https://github.com/cucumber/cucumber-js/blob/main/src/support_code_library_builder/index.ts
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const newId = _messages.IdGenerator.uuid();
|
|
17
|
-
function buildStepDefinition({
|
|
18
|
-
keyword,
|
|
19
|
-
pattern,
|
|
20
|
-
code,
|
|
21
|
-
line,
|
|
22
|
-
options,
|
|
23
|
-
uri
|
|
24
|
-
}, supportCodeLibrary) {
|
|
25
|
-
// todo: handle error.undefinedParameterTypeName as it's done in cucumber?
|
|
26
|
-
const expression = typeof pattern === 'string' ? new _cucumberExpressions.CucumberExpression(pattern, supportCodeLibrary.parameterTypeRegistry) : new _cucumberExpressions.RegularExpression(pattern, supportCodeLibrary.parameterTypeRegistry);
|
|
27
|
-
// skip wrapping code as it is not needed for decorator steps
|
|
28
|
-
// const wrappedCode = this.wrapCode({
|
|
29
|
-
// code,
|
|
30
|
-
// wrapperOptions: options.wrapperOptions,
|
|
31
|
-
// })
|
|
32
|
-
return new _step_definition.default({
|
|
33
|
-
code,
|
|
34
|
-
expression,
|
|
35
|
-
id: newId(),
|
|
36
|
-
line,
|
|
37
|
-
options,
|
|
38
|
-
keyword,
|
|
39
|
-
pattern,
|
|
40
|
-
unwrappedCode: code,
|
|
41
|
-
uri
|
|
42
|
-
});
|
|
43
|
-
}
|
|
@@ -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
|
-
}
|