@playq/core 0.2.77
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/README.md +41 -0
- package/bin/playq.js +175 -0
- package/cucumber.js +10 -0
- package/dist/exec/featureFileCache.d.ts +21 -0
- package/dist/exec/featureFileCache.js +124 -0
- package/dist/exec/featureFilePreProcess.d.ts +12 -0
- package/dist/exec/featureFilePreProcess.js +208 -0
- package/dist/exec/preLoader.d.ts +1 -0
- package/dist/exec/preLoader.js +72 -0
- package/dist/exec/preProcessEntry.d.ts +1 -0
- package/dist/exec/preProcessEntry.js +83 -0
- package/dist/exec/preProcess_old_todelete.d.ts +1 -0
- package/dist/exec/preProcess_old_todelete.js +258 -0
- package/dist/exec/runner.d.ts +1 -0
- package/dist/exec/runner.js +221 -0
- package/dist/exec/runner_orchestrator.d.ts +1 -0
- package/dist/exec/runner_orchestrator.js +85 -0
- package/dist/exec/sgGenerator.d.ts +11 -0
- package/dist/exec/sgGenerator.js +310 -0
- package/dist/global.d.ts +15 -0
- package/dist/global.js +185 -0
- package/dist/helper/actions/api/apiRequestActions.d.ts +117 -0
- package/dist/helper/actions/api/apiRequestActions.js +374 -0
- package/dist/helper/actions/api/apiValidationActions.d.ts +119 -0
- package/dist/helper/actions/api/apiValidationActions.js +615 -0
- package/dist/helper/actions/apiActions.d.ts +18 -0
- package/dist/helper/actions/apiActions.js +34 -0
- package/dist/helper/actions/apiStepDefs.d.ts +1 -0
- package/dist/helper/actions/apiStepDefs.js +64 -0
- package/dist/helper/actions/comm/commonActions.d.ts +58 -0
- package/dist/helper/actions/comm/commonActions.js +198 -0
- package/dist/helper/actions/comm/utilityActions.d.ts +131 -0
- package/dist/helper/actions/comm/utilityActions.js +351 -0
- package/dist/helper/actions/commActions.d.ts +18 -0
- package/dist/helper/actions/commActions.js +34 -0
- package/dist/helper/actions/commStepDefs.d.ts +1 -0
- package/dist/helper/actions/commStepDefs.js +57 -0
- package/dist/helper/actions/stepGroupStepDefs.d.ts +1 -0
- package/dist/helper/actions/stepGroupStepDefs.js +15 -0
- package/dist/helper/actions/web/alertActions.d.ts +61 -0
- package/dist/helper/actions/web/alertActions.js +224 -0
- package/dist/helper/actions/web/cookieActions.d.ts +45 -0
- package/dist/helper/actions/web/cookieActions.js +186 -0
- package/dist/helper/actions/web/downloadActions.d.ts +40 -0
- package/dist/helper/actions/web/downloadActions.js +153 -0
- package/dist/helper/actions/web/elementReaderActions.d.ts +95 -0
- package/dist/helper/actions/web/elementReaderActions.js +326 -0
- package/dist/helper/actions/web/formActions.d.ts +122 -0
- package/dist/helper/actions/web/formActions.js +423 -0
- package/dist/helper/actions/web/iframeActions.d.ts +23 -0
- package/dist/helper/actions/web/iframeActions.js +108 -0
- package/dist/helper/actions/web/javascriptActions.d.ts +14 -0
- package/dist/helper/actions/web/javascriptActions.js +77 -0
- package/dist/helper/actions/web/keyboardActions.d.ts +35 -0
- package/dist/helper/actions/web/keyboardActions.js +118 -0
- package/dist/helper/actions/web/localStorageActions.d.ts +51 -0
- package/dist/helper/actions/web/localStorageActions.js +163 -0
- package/dist/helper/actions/web/mouseActions.d.ts +240 -0
- package/dist/helper/actions/web/mouseActions.js +609 -0
- package/dist/helper/actions/web/reportingActions.d.ts +34 -0
- package/dist/helper/actions/web/reportingActions.js +58 -0
- package/dist/helper/actions/web/screenshotActions.d.ts +34 -0
- package/dist/helper/actions/web/screenshotActions.js +151 -0
- package/dist/helper/actions/web/testDataActions.d.ts +21 -0
- package/dist/helper/actions/web/testDataActions.js +211 -0
- package/dist/helper/actions/web/validationActions.d.ts +547 -0
- package/dist/helper/actions/web/validationActions.js +1754 -0
- package/dist/helper/actions/web/waitActions.d.ts +191 -0
- package/dist/helper/actions/web/waitActions.js +589 -0
- package/dist/helper/actions/web/webNavigation.d.ts +104 -0
- package/dist/helper/actions/web/webNavigation.js +288 -0
- package/dist/helper/actions/webActions.d.ts +32 -0
- package/dist/helper/actions/webActions.js +48 -0
- package/dist/helper/actions/webStepDefs.d.ts +1 -0
- package/dist/helper/actions/webStepDefs.js +455 -0
- package/dist/helper/browsers/browserManager.d.ts +1 -0
- package/dist/helper/browsers/browserManager.js +56 -0
- package/dist/helper/bundle/defaultEntries.d.ts +6 -0
- package/dist/helper/bundle/defaultEntries.js +200 -0
- package/dist/helper/bundle/env.d.ts +1 -0
- package/dist/helper/bundle/env.js +157 -0
- package/dist/helper/bundle/vars.d.ts +9 -0
- package/dist/helper/bundle/vars.js +375 -0
- package/dist/helper/faker/customFaker.d.ts +55 -0
- package/dist/helper/faker/customFaker.js +45 -0
- package/dist/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/dist/helper/faker/modules/dateTime.d.ts +18 -0
- package/dist/helper/faker/modules/dateTime.js +106 -0
- package/dist/helper/faker/modules/mobile.d.ts +4 -0
- package/dist/helper/faker/modules/mobile.js +59 -0
- package/dist/helper/faker/modules/nric.d.ts +32 -0
- package/dist/helper/faker/modules/nric.js +84 -0
- package/dist/helper/faker/modules/passport.d.ts +3 -0
- package/dist/helper/faker/modules/passport.js +36 -0
- package/dist/helper/faker/modules/person.d.ts +14 -0
- package/dist/helper/faker/modules/person.js +73 -0
- package/dist/helper/faker/modules/postcode.d.ts +6 -0
- package/dist/helper/faker/modules/postcode.js +47 -0
- package/dist/helper/fixtures/locAggregate.d.ts +7 -0
- package/dist/helper/fixtures/locAggregate.js +94 -0
- package/dist/helper/fixtures/logFixture.d.ts +8 -0
- package/dist/helper/fixtures/logFixture.js +56 -0
- package/dist/helper/fixtures/webFixture.d.ts +19 -0
- package/dist/helper/fixtures/webFixture.js +186 -0
- package/dist/helper/fixtures/webLocFixture.d.ts +2 -0
- package/dist/helper/fixtures/webLocFixture.js +144 -0
- package/dist/helper/report/allureStepLogger.d.ts +0 -0
- package/dist/helper/report/allureStepLogger.js +25 -0
- package/dist/helper/report/customiseReport.d.ts +1 -0
- package/dist/helper/report/customiseReport.js +55 -0
- package/dist/helper/report/init.d.ts +1 -0
- package/dist/helper/report/init.js +14 -0
- package/dist/helper/report/report.d.ts +1 -0
- package/dist/helper/report/report.js +102 -0
- package/dist/helper/util/dataLoader.d.ts +10 -0
- package/dist/helper/util/dataLoader.js +73 -0
- package/dist/helper/util/logger.d.ts +4 -0
- package/dist/helper/util/logger.js +61 -0
- package/dist/helper/util/session/sessionUtil.d.ts +26 -0
- package/dist/helper/util/session/sessionUtil.js +729 -0
- package/dist/helper/util/stepHelpers.d.ts +2 -0
- package/dist/helper/util/stepHelpers.js +16 -0
- package/dist/helper/util/test-data/dataLoader.d.ts +7 -0
- package/dist/helper/util/test-data/dataLoader.js +145 -0
- package/dist/helper/util/test-data/dataTest.d.ts +10 -0
- package/dist/helper/util/test-data/dataTest.js +216 -0
- package/dist/helper/util/totp/totpHelper.d.ts +38 -0
- package/dist/helper/util/totp/totpHelper.js +117 -0
- package/dist/helper/util/utilities/cryptoUtil.d.ts +2 -0
- package/dist/helper/util/utilities/cryptoUtil.js +53 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.d.ts +2 -0
- package/dist/helper/util/utilities/schemaGeneratorUtil.js +129 -0
- package/dist/helper/util/utils.d.ts +2 -0
- package/dist/helper/util/utils.js +22 -0
- package/dist/helper/wrapper/PlaywrightWrappers.d.ts +8 -0
- package/dist/helper/wrapper/PlaywrightWrappers.js +26 -0
- package/dist/helper/wrapper/assert.d.ts +9 -0
- package/dist/helper/wrapper/assert.js +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +57 -0
- package/dist/scripts/get-versions.d.ts +1 -0
- package/dist/scripts/get-versions.js +98 -0
- package/dist/scripts/posttest.d.ts +1 -0
- package/dist/scripts/posttest.js +29 -0
- package/dist/scripts/pretest.d.ts +1 -0
- package/dist/scripts/pretest.js +57 -0
- package/dist/scripts/util.d.ts +1 -0
- package/dist/scripts/util.js +376 -0
- package/package.json +68 -0
- package/src/exec/featureFileCache.ts +80 -0
- package/src/exec/featureFilePreProcess.ts +239 -0
- package/src/exec/preLoader.ts +72 -0
- package/src/exec/preProcessEntry.ts +59 -0
- package/src/exec/preProcess_old_todelete.ts +289 -0
- package/src/exec/runner.ts +241 -0
- package/src/exec/runnerCuke.js +90 -0
- package/src/exec/runner_orchestrator.ts +91 -0
- package/src/exec/sgGenerator.ts +373 -0
- package/src/global.ts +130 -0
- package/src/helper/actions/api/apiRequestActions.ts +362 -0
- package/src/helper/actions/api/apiValidationActions.ts +594 -0
- package/src/helper/actions/apiActions.ts +18 -0
- package/src/helper/actions/apiStepDefs.ts +80 -0
- package/src/helper/actions/comm/commonActions.ts +165 -0
- package/src/helper/actions/comm/utilityActions.ts +344 -0
- package/src/helper/actions/commActions.ts +18 -0
- package/src/helper/actions/commStepDefs.ts +72 -0
- package/src/helper/actions/stepGroupStepDefs.ts +17 -0
- package/src/helper/actions/web/alertActions.ts +179 -0
- package/src/helper/actions/web/cookieActions.ts +124 -0
- package/src/helper/actions/web/downloadActions.ts +129 -0
- package/src/helper/actions/web/elementReaderActions.ts +323 -0
- package/src/helper/actions/web/formActions.ts +469 -0
- package/src/helper/actions/web/iframeActions.ts +67 -0
- package/src/helper/actions/web/javascriptActions.ts +38 -0
- package/src/helper/actions/web/keyboardActions.ts +101 -0
- package/src/helper/actions/web/localStorageActions.ts +109 -0
- package/src/helper/actions/web/mouseActions.ts +864 -0
- package/src/helper/actions/web/reportingActions.ts +53 -0
- package/src/helper/actions/web/screenshotActions.ts +124 -0
- package/src/helper/actions/web/testDataActions.ts +162 -0
- package/src/helper/actions/web/validationActions.ts +2287 -0
- package/src/helper/actions/web/waitActions.ts +757 -0
- package/src/helper/actions/web/webNavigation.ts +313 -0
- package/src/helper/actions/webActions.ts +33 -0
- package/src/helper/actions/webStepDefs.ts +505 -0
- package/src/helper/browsers/browserManager.ts +23 -0
- package/src/helper/bundle/defaultEntries.ts +208 -0
- package/src/helper/bundle/env.ts +119 -0
- package/src/helper/bundle/vars.ts +368 -0
- package/src/helper/faker/customFaker.ts +107 -0
- package/src/helper/faker/modules/data/postcodes_valid_sg.json +17 -0
- package/src/helper/faker/modules/dateTime.ts +121 -0
- package/src/helper/faker/modules/mobile.ts +58 -0
- package/src/helper/faker/modules/nric.ts +109 -0
- package/src/helper/faker/modules/passport.ts +34 -0
- package/src/helper/faker/modules/person.ts +93 -0
- package/src/helper/faker/modules/postcode.ts +57 -0
- package/src/helper/fixtures/locAggregate.ts +61 -0
- package/src/helper/fixtures/logFixture.ts +57 -0
- package/src/helper/fixtures/webFixture.ts +206 -0
- package/src/helper/fixtures/webLocFixture.ts +143 -0
- package/src/helper/report/allureStepLogger.ts +26 -0
- package/src/helper/report/customiseReport.ts +61 -0
- package/src/helper/report/init.ts +18 -0
- package/src/helper/report/report.ts +72 -0
- package/src/helper/util/dataLoader.ts +42 -0
- package/src/helper/util/logger.ts +32 -0
- package/src/helper/util/session/sessionUtil.ts +839 -0
- package/src/helper/util/stepHelpers.ts +14 -0
- package/src/helper/util/test-data/dataLoader.ts +108 -0
- package/src/helper/util/test-data/dataTest.ts +191 -0
- package/src/helper/util/test-data/registerUser.json +7 -0
- package/src/helper/util/totp/totpHelper.ts +102 -0
- package/src/helper/util/utilities/cryptoUtil.ts +53 -0
- package/src/helper/util/utilities/schemaGeneratorUtil.ts +143 -0
- package/src/helper/util/utils.ts +28 -0
- package/src/helper/wrapper/PlaywrightWrappers.ts +28 -0
- package/src/helper/wrapper/assert.ts +25 -0
- package/src/index.ts +17 -0
- package/src/scripts/get-versions.ts +68 -0
- package/src/scripts/posttest.ts +32 -0
- package/src/scripts/pretest.ts +48 -0
- package/src/scripts/util.ts +406 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { spawnSync, execSync, spawn } from 'child_process';
|
|
2
|
+
import minimist from 'minimist';
|
|
3
|
+
import { loadEnv } from '../helper/bundle/env';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
// Note: remove stray invalid import; runner does not need faker
|
|
7
|
+
|
|
8
|
+
// loadEnv();
|
|
9
|
+
// console.log(' - Runner (PLAYQ_ENV):', process.env.PLAYQ_ENV );
|
|
10
|
+
// console.log(' - Runner (PLAYQ_RUNNER):', process.env.PLAYQ_RUNNER );
|
|
11
|
+
// console.log(' - Runner (PLAYQ_GREP):', process.env.PLAYQ_GREP );
|
|
12
|
+
// console.log(' - Runner (PLAYQ_TAGS):', process.env.PLAYQ_TAGS );
|
|
13
|
+
// console.log(' - Runner (PLAYQ_PROJECT):', process.env.PLAYQ_PROJECT );
|
|
14
|
+
// console.log(' - Env (RUNNER - cc_card_type):', process.env['cc_card_type']);
|
|
15
|
+
// console.log(' - Env (RUNNER - config.testExecution.timeout):', process.env['config.testExecution.timeout'] );
|
|
16
|
+
|
|
17
|
+
if (process.env.PLAYQ_RUNNER && process.env.PLAYQ_RUNNER === 'cucumber') {
|
|
18
|
+
// Allow vars to initialize in the cucumber child process (do NOT set PLAYQ_NO_INIT_VARS here)
|
|
19
|
+
// Ensure legacy TEST_RUNNER flag used by helper code is set
|
|
20
|
+
process.env.TEST_RUNNER = 'cucumber';
|
|
21
|
+
// Provide a default browser type if none supplied via config/env
|
|
22
|
+
if (!process.env['PLAYQ__browser__browserType'] && !process.env['browser.browserType']) {
|
|
23
|
+
process.env.PLAYQ__browser__browserType = 'chromium';
|
|
24
|
+
}
|
|
25
|
+
loadEnv();
|
|
26
|
+
const cucumberArgs = [
|
|
27
|
+
'cucumber-js',
|
|
28
|
+
'--config',
|
|
29
|
+
'cucumber.js',
|
|
30
|
+
'--profile',
|
|
31
|
+
'default',
|
|
32
|
+
];
|
|
33
|
+
if (process.env.PLAYQ_TAGS) cucumberArgs.push('--tags', process.env.PLAYQ_TAGS);
|
|
34
|
+
|
|
35
|
+
const run = spawn('npx', cucumberArgs, {
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
env: { ...process.env },
|
|
38
|
+
shell: true,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
run.on('close', (code) => {
|
|
42
|
+
try {
|
|
43
|
+
const pkgPath = path.resolve(process.cwd(), 'package.json');
|
|
44
|
+
const pkg = require(pkgPath);
|
|
45
|
+
if (pkg.scripts && pkg.scripts['posttest:cucumber']) {
|
|
46
|
+
execSync('npm run posttest:cucumber', { stdio: 'inherit' });
|
|
47
|
+
} else {
|
|
48
|
+
console.log('ℹ️ Skipping posttest:cucumber (script not defined)');
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.log('ℹ️ Posttest check failed, continuing:', (err as any)?.message || err);
|
|
52
|
+
}
|
|
53
|
+
process.exit(code);
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
if (process.env.PLAYQ_RUN_CONFIG) {
|
|
57
|
+
// Dynamically import the run_config object from the specified run config file
|
|
58
|
+
// Look for run config in the user's project root
|
|
59
|
+
const runConfigPath = path.resolve(process.cwd(), `resources/run-configs/${process.env.PLAYQ_RUN_CONFIG}.run`);
|
|
60
|
+
const runConfig = require(runConfigPath).default;
|
|
61
|
+
console.log('🌐 Running with runConfig:', JSON.stringify(runConfig));
|
|
62
|
+
for (const cfg of runConfig.runs) {
|
|
63
|
+
|
|
64
|
+
console.log(` - Running test with grep: ${cfg.PLAYQ_GREP}, env: ${cfg.PLAYQ_ENV}`);
|
|
65
|
+
Object.keys(cfg).forEach(key => {
|
|
66
|
+
if (key.trim() == 'PLAYQ_RUNNER') throw new Error('PLAYQ_RUNNER is not allowed in run configs');
|
|
67
|
+
process.env[key] = cfg[key];
|
|
68
|
+
console.log(`Setting ${key} = ${cfg[key]}`);
|
|
69
|
+
});
|
|
70
|
+
process.env.PLAYQ_NO_INIT_VARS = '1';
|
|
71
|
+
loadEnv();
|
|
72
|
+
const command = `npx playwright test --config=playq/config/playwright/playwright.config.js${process.env.PLAYQ_GREP ? ` --grep="${process.env.PLAYQ_GREP}"` : ''
|
|
73
|
+
}${process.env.PLAYQ_PROJECT ? ` --project="${process.env.PLAYQ_PROJECT}"` : ''}`;
|
|
74
|
+
|
|
75
|
+
const childEnv = { ...process.env } as any;
|
|
76
|
+
// Ensure child initializes vars by removing the parent-side guard
|
|
77
|
+
delete childEnv.PLAYQ_NO_INIT_VARS;
|
|
78
|
+
const preload = '-r ts-node/register';
|
|
79
|
+
childEnv.NODE_OPTIONS = childEnv.NODE_OPTIONS
|
|
80
|
+
? `${childEnv.NODE_OPTIONS} ${preload}`
|
|
81
|
+
: preload;
|
|
82
|
+
// Ensure core and project roots propagate to child
|
|
83
|
+
if (!childEnv.PLAYQ_CORE_ROOT) childEnv.PLAYQ_CORE_ROOT = path.resolve(__dirname, '..');
|
|
84
|
+
if (!childEnv.PLAYQ_PROJECT_ROOT) childEnv.PLAYQ_PROJECT_ROOT = process.cwd();
|
|
85
|
+
// Point ts-node to the project's tsconfig for path aliases
|
|
86
|
+
const projectTsConfig = path.resolve(process.cwd(), 'tsconfig.json');
|
|
87
|
+
childEnv.TS_NODE_PROJECT = projectTsConfig;
|
|
88
|
+
childEnv.TS_NODE_TRANSPILE_ONLY = childEnv.TS_NODE_TRANSPILE_ONLY || 'true';
|
|
89
|
+
const result = spawnSync(command, {
|
|
90
|
+
stdio: 'inherit',
|
|
91
|
+
shell: true,
|
|
92
|
+
env: childEnv,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
process.env.PLAYQ_NO_INIT_VARS = '1';
|
|
98
|
+
loadEnv();
|
|
99
|
+
const command = `npx playwright test --config=playq/config/playwright/playwright.config.js${process.env.PLAYQ_GREP ? ` --grep="${process.env.PLAYQ_GREP}"` : ''
|
|
100
|
+
}${process.env.PLAYQ_PROJECT ? ` --project="${process.env.PLAYQ_PROJECT}"` : ''}`;
|
|
101
|
+
|
|
102
|
+
const childEnv = { ...process.env } as any;
|
|
103
|
+
// Ensure child initializes vars by removing the parent-side guard
|
|
104
|
+
delete childEnv.PLAYQ_NO_INIT_VARS;
|
|
105
|
+
const preload = '-r ts-node/register';
|
|
106
|
+
childEnv.NODE_OPTIONS = childEnv.NODE_OPTIONS
|
|
107
|
+
? `${childEnv.NODE_OPTIONS} ${preload}`
|
|
108
|
+
: preload;
|
|
109
|
+
// Ensure core and project roots propagate to child
|
|
110
|
+
if (!childEnv.PLAYQ_CORE_ROOT) childEnv.PLAYQ_CORE_ROOT = path.resolve(__dirname, '..');
|
|
111
|
+
if (!childEnv.PLAYQ_PROJECT_ROOT) childEnv.PLAYQ_PROJECT_ROOT = process.cwd();
|
|
112
|
+
// Point ts-node to the project's tsconfig for path aliases
|
|
113
|
+
const projectTsConfig = path.resolve(process.cwd(), 'tsconfig.json');
|
|
114
|
+
childEnv.TS_NODE_PROJECT = projectTsConfig;
|
|
115
|
+
childEnv.TS_NODE_TRANSPILE_ONLY = childEnv.TS_NODE_TRANSPILE_ONLY || 'true';
|
|
116
|
+
const result = spawnSync(command, {
|
|
117
|
+
stdio: 'inherit',
|
|
118
|
+
shell: true,
|
|
119
|
+
env: childEnv,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// console.log(' - Runner (PLAYQ_ENV):', process.env.PLAYQ_ENV );
|
|
127
|
+
// console.log(' - Runner (PLAYQ_RUNNER):', process.env.PLAYQ_RUNNER );
|
|
128
|
+
// console.log(' - Runner (PLAYQ_GREP):', process.env.PLAYQ_GREP );
|
|
129
|
+
// console.log(' - Runner (PLAYQ_TAGS):', process.env.PLAYQ_TAGS );
|
|
130
|
+
// console.log(' - Runner (PLAYQ_PROJECT):', process.env.PLAYQ_PROJECT );
|
|
131
|
+
// console.log(' - Env (RUNNER - cc_card_type):', process.env.cc_card_type );
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
// let runner = 'playwright';
|
|
135
|
+
// let env = '';
|
|
136
|
+
// let grep = '';
|
|
137
|
+
// let tags = '';
|
|
138
|
+
// let prj = '';
|
|
139
|
+
// console.log('🌐 os.platform():', os.platform());
|
|
140
|
+
|
|
141
|
+
// // Use minimist for all platforms for consistency
|
|
142
|
+
// const args = minimist(process.argv.slice(2));
|
|
143
|
+
|
|
144
|
+
// // Try npm_config_* first (for npm script context), then fall back to minimist
|
|
145
|
+
// grep = process.env.npm_config_grep || args.grep || '';
|
|
146
|
+
// env = process.env.npm_config_env || args.env || '';
|
|
147
|
+
// tags = process.env.npm_config_tags || args.tags || '';
|
|
148
|
+
// prj = process.env.npm_config_project || args.project || '';
|
|
149
|
+
// runner = ['cucumber', 'bdd', 'cuke'].includes(
|
|
150
|
+
// (process.env.npm_config_runner || args.runner || '').toLowerCase()
|
|
151
|
+
// )
|
|
152
|
+
// ? 'cucumber'
|
|
153
|
+
// : 'playwright';
|
|
154
|
+
|
|
155
|
+
// console.log('🌐 grep:', grep);
|
|
156
|
+
// console.log('🌐 env:', env);
|
|
157
|
+
// console.log('🌐 tags:', tags);
|
|
158
|
+
// console.log('🌐 prj:', prj);
|
|
159
|
+
// console.log('🌐 runner:', runner);
|
|
160
|
+
|
|
161
|
+
// // Debug information
|
|
162
|
+
// console.log('🔍 Debug - process.argv:', process.argv);
|
|
163
|
+
// console.log('🔍 Debug - minimist args:', args);
|
|
164
|
+
// console.log('🔍 Debug - npm_config_env:', process.env.npm_config_env);
|
|
165
|
+
// console.log('🔍 Debug - npm_config_grep:', process.env.npm_config_grep);
|
|
166
|
+
|
|
167
|
+
// process.env.TS_NODE_PROJECT = './tsconfig.json';
|
|
168
|
+
// require('tsconfig-paths').register();
|
|
169
|
+
|
|
170
|
+
// console.log('🌐 Running tests with args:', process.argv);
|
|
171
|
+
// console.log(process.platform);
|
|
172
|
+
// console.log(process.env.npm_config_env);
|
|
173
|
+
|
|
174
|
+
// process.env.TEST_RUNNER = runner;
|
|
175
|
+
// if (tags) process.env.TAGS = tags;
|
|
176
|
+
// if (grep) process.env.GREP = grep;
|
|
177
|
+
// if (prj) process.env.PROJECT = prj;
|
|
178
|
+
|
|
179
|
+
// if (env) {
|
|
180
|
+
// process.env.RUN_ENV = env;
|
|
181
|
+
// loadEnv(env);
|
|
182
|
+
// }
|
|
183
|
+
|
|
184
|
+
// if (runner === 'cucumber') {
|
|
185
|
+
// execSync('npm run pretest:cucumber', { stdio: 'inherit' });
|
|
186
|
+
|
|
187
|
+
// const cucumberArgs = [
|
|
188
|
+
// 'cucumber-js',
|
|
189
|
+
// '--config',
|
|
190
|
+
// 'cucumber.js',
|
|
191
|
+
// '--profile',
|
|
192
|
+
// 'default',
|
|
193
|
+
// ];
|
|
194
|
+
// if (tags) cucumberArgs.push('--tags', tags);
|
|
195
|
+
|
|
196
|
+
// console.log(`🚀 Running Cucumber with args: ${cucumberArgs.join(' ')}`);
|
|
197
|
+
// console.log('📦 Final Cucumber command:', `npx ${cucumberArgs.join(' ')}`);
|
|
198
|
+
|
|
199
|
+
// const run = spawn('npx', cucumberArgs, {
|
|
200
|
+
// stdio: 'inherit',
|
|
201
|
+
// env: { ...process.env, RUN_ENV: env, PROJECT: prj },
|
|
202
|
+
|
|
203
|
+
// shell: true,
|
|
204
|
+
// });
|
|
205
|
+
|
|
206
|
+
// run.on('close', (code) => {
|
|
207
|
+
// execSync('npm run posttest:cucumber', { stdio: 'inherit' });
|
|
208
|
+
// process.exit(code);
|
|
209
|
+
// });
|
|
210
|
+
// } else if (runner === 'playwright') {
|
|
211
|
+
// try {
|
|
212
|
+
// execSync('npm run pretest:playwright', { stdio: 'inherit' });
|
|
213
|
+
// } catch (error) {
|
|
214
|
+
// console.log(
|
|
215
|
+
// '⚠️ Pre-test cleanup had some issues, but continuing with tests...'
|
|
216
|
+
// );
|
|
217
|
+
// }
|
|
218
|
+
|
|
219
|
+
// const command = `npx playwright test --config=config/playwright/playwright.config.ts${
|
|
220
|
+
// grep ? ` --grep='${grep}'` : ''
|
|
221
|
+
// }${prj ? ` --project=${prj}` : ''}`;
|
|
222
|
+
|
|
223
|
+
// const result = spawnSync(command, {
|
|
224
|
+
// stdio: 'inherit',
|
|
225
|
+
// shell: true,
|
|
226
|
+
// env: { ...process.env, RUN_ENV: env, PROJECT: prj },
|
|
227
|
+
// });
|
|
228
|
+
|
|
229
|
+
// try {
|
|
230
|
+
// execSync('npm run posttest:playwright', { stdio: 'inherit' });
|
|
231
|
+
// } catch (error) {
|
|
232
|
+
// console.log(
|
|
233
|
+
// '⚠️ Post-test reporting had some issues, but test execution completed.'
|
|
234
|
+
// );
|
|
235
|
+
// }
|
|
236
|
+
|
|
237
|
+
// process.exit(result.status || 0);
|
|
238
|
+
// } else {
|
|
239
|
+
// console.error(`❌ Unknown runner: ${runner}`);
|
|
240
|
+
// process.exit(1);
|
|
241
|
+
// }
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const { spawn } = require('child_process');
|
|
2
|
+
const minimist = require('minimist');
|
|
3
|
+
|
|
4
|
+
console.log("🧪 CLI args raw in runnerCuke:", process.argv);
|
|
5
|
+
|
|
6
|
+
const argsFromCLI = minimist(process.argv.slice(2));
|
|
7
|
+
|
|
8
|
+
console.log("🧪 CLI args received:", argsFromCLI);
|
|
9
|
+
console.log("🔍 Resolved variables:");
|
|
10
|
+
console.log(" - TEST_RUNNER:", process.env.TEST_RUNNER || 'cucumber');
|
|
11
|
+
console.log(" - TAGS:",
|
|
12
|
+
argsFromCLI.tags ||
|
|
13
|
+
argsFromCLI.tag ||
|
|
14
|
+
argsFromCLI.TAGS ||
|
|
15
|
+
process.env.TAGS ||
|
|
16
|
+
process.env.npm_config_TAGS ||
|
|
17
|
+
''
|
|
18
|
+
);
|
|
19
|
+
console.log(" - ENV:", argsFromCLI.env || process.env.ENV || process.env.npm_config_ENV || '');
|
|
20
|
+
console.log(" - GREP:", argsFromCLI.grep || process.env.npm_config_GREP || '');
|
|
21
|
+
|
|
22
|
+
const TEST_RUNNER = process.env.TEST_RUNNER || 'cucumber';
|
|
23
|
+
|
|
24
|
+
// const tag =
|
|
25
|
+
// argsFromCLI.tags ||
|
|
26
|
+
// argsFromCLI.tag ||
|
|
27
|
+
// argsFromCLI.TAGS ||
|
|
28
|
+
// process.env.TAGS ||
|
|
29
|
+
// process.env.npm_config_TAGS ||
|
|
30
|
+
// '';
|
|
31
|
+
// const env = argsFromCLI.env || process.env.ENV || process.env.npm_config_ENV || '';
|
|
32
|
+
// const grep = argsFromCLI.grep || process.env.npm_config_GREP || '';
|
|
33
|
+
|
|
34
|
+
const tag = argsFromCLI.tags || argsFromCLI.tag || '';
|
|
35
|
+
const env = argsFromCLI.env || '';
|
|
36
|
+
const grep = argsFromCLI.grep || '';
|
|
37
|
+
|
|
38
|
+
// Set environment variables for downstream use
|
|
39
|
+
process.env.TAGS = tag;
|
|
40
|
+
process.env.ENV = env;
|
|
41
|
+
process.env.GREP = grep;
|
|
42
|
+
|
|
43
|
+
console.log(`🔧 TEST_RUNNER: ${TEST_RUNNER}`);
|
|
44
|
+
console.log(`🌍 ENV: ${env}`);
|
|
45
|
+
console.log(`🏷️ TAGS used: "${tag}"`);
|
|
46
|
+
console.log(`🔍 GREP: ${grep}`);
|
|
47
|
+
|
|
48
|
+
let run;
|
|
49
|
+
|
|
50
|
+
const cucumberArgs = ['cucumber-js', '--config', 'cucumber.js', '--profile', 'default'];
|
|
51
|
+
if (tag) cucumberArgs.push('--tags', tag);
|
|
52
|
+
console.log(`🚀 Running Cucumber with args: ${cucumberArgs.join(' ')}`);
|
|
53
|
+
console.log("📦 Final Cucumber command:", `npx ${cucumberArgs.join(' ')}`);
|
|
54
|
+
|
|
55
|
+
run = spawn('npx', cucumberArgs, {
|
|
56
|
+
stdio: 'inherit',
|
|
57
|
+
env: { ...process.env, RUN_ENV: env },
|
|
58
|
+
shell: true
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// if (TEST_RUNNER === 'cucumber') {
|
|
62
|
+
// const cucumberArgs = ['cucumber-js', '--config', 'cucumber.js', '--profile', 'default'];
|
|
63
|
+
// if (tag) cucumberArgs.push('--tags', tag);
|
|
64
|
+
// console.log(`🚀 Running Cucumber with args: ${cucumberArgs.join(' ')}`);
|
|
65
|
+
// console.log("📦 Final Cucumber command:", `npx ${cucumberArgs.join(' ')}`);
|
|
66
|
+
|
|
67
|
+
// run = spawn('npx', cucumberArgs, {
|
|
68
|
+
// stdio: 'inherit',
|
|
69
|
+
// env: { ...process.env, ENV: env },
|
|
70
|
+
// shell: true
|
|
71
|
+
// });
|
|
72
|
+
|
|
73
|
+
// } else if (TEST_RUNNER === 'playwright') {
|
|
74
|
+
// const pwArgs = ['playwright', 'test', '--config=config/playwright/playwright.config.ts'];
|
|
75
|
+
// if (grep) pwArgs.push('--grep', grep);
|
|
76
|
+
|
|
77
|
+
// console.log("📦 Final Playwright command:", `npx ${pwArgs.join(' ')}`);
|
|
78
|
+
|
|
79
|
+
// run = spawn('npx', pwArgs, {
|
|
80
|
+
// stdio: 'inherit',
|
|
81
|
+
// env: { ...process.env, ENV: env },
|
|
82
|
+
// shell: true
|
|
83
|
+
// });
|
|
84
|
+
|
|
85
|
+
// } else {
|
|
86
|
+
// console.error(`❌ Unknown TEST_RUNNER: ${TEST_RUNNER}`);
|
|
87
|
+
// process.exit(1);
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
run.on('close', code => process.exit(code));
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { spawnSync } from 'child_process';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import yargs from 'yargs';
|
|
6
|
+
|
|
7
|
+
const args = yargs(process.argv).argv as any;
|
|
8
|
+
const runnerName = args.runner;
|
|
9
|
+
|
|
10
|
+
if (!runnerName) {
|
|
11
|
+
console.error('❌ Missing --runner=<name>');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const runnerPath = path.resolve(`./resources/runners/${runnerName}.run.json`);
|
|
16
|
+
if (!fs.existsSync(runnerPath)) {
|
|
17
|
+
console.error(`❌ Runner file not found: ${runnerPath}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const runnerConfig = JSON.parse(fs.readFileSync(runnerPath, 'utf-8'));
|
|
22
|
+
const { runType, runs } = runnerConfig;
|
|
23
|
+
|
|
24
|
+
execSync('npm run pretest:playwright', { stdio: 'inherit' });
|
|
25
|
+
|
|
26
|
+
async function runOneTest(config: any) {
|
|
27
|
+
const env = config.env ? config.env : ''
|
|
28
|
+
const grep = config.grep ? `--grep="${config.grep}"` : '';
|
|
29
|
+
// const env = config.env ? `--env="${config.env}"` : '';
|
|
30
|
+
const prj = config.project ? `--project=${config.project}"` : '';
|
|
31
|
+
|
|
32
|
+
const command = `npx playwright test --config=config/playwright/playwright.config.js ${grep} ${prj}`;
|
|
33
|
+
console.log(`🔹 Running: ${command}`);
|
|
34
|
+
const result = spawnSync(command, {
|
|
35
|
+
stdio: 'inherit',
|
|
36
|
+
shell: true,
|
|
37
|
+
env: { ...process.env, TEST_RUNNER: "playwright", RUN_ENV: env }
|
|
38
|
+
// env: { ...process.env }
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (result.status !== 0) {
|
|
42
|
+
console.error(`❌ Test failed: ${grep}`);
|
|
43
|
+
process.exit(result.status);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function runTests() {
|
|
48
|
+
if (runType === 'sequential') {
|
|
49
|
+
for (const run of runs) {
|
|
50
|
+
await runOneTest(run);
|
|
51
|
+
}
|
|
52
|
+
} else if (runType === 'parallel') {
|
|
53
|
+
const promises = runs.map(run =>
|
|
54
|
+
new Promise((resolve, reject) => {
|
|
55
|
+
const env = run.env ? run.env : ''
|
|
56
|
+
const grep = run.grep ? `--grep="${run.grep}"` : '';
|
|
57
|
+
// const env = run.env ? `--env="${run.env}"` : '';
|
|
58
|
+
const prj = run.project ? `--project=${run.project}"` : '';
|
|
59
|
+
const command = `npx playwright test --config=config/playwright/playwright.config.js ${grep} ${prj}`;
|
|
60
|
+
|
|
61
|
+
const proc = spawnSync(command, {
|
|
62
|
+
stdio: 'inherit',
|
|
63
|
+
shell: true,
|
|
64
|
+
env: { ...process.env, TEST_RUNNER: "playwright", RUN_ENV: env }
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (proc.status !== 0) {
|
|
68
|
+
reject(new Error(`Failed: ${command}`));
|
|
69
|
+
} else {
|
|
70
|
+
resolve(true);
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
await Promise.all(promises);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.error('❌ One or more test batches failed.');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
console.error(`❌ Unknown runType: ${runType}`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
runTests().then(() => {
|
|
88
|
+
execSync('npm run posttest:playwright', { stdio: 'inherit' });
|
|
89
|
+
console.log('✅ All test runs completed.');
|
|
90
|
+
process.exit(0);
|
|
91
|
+
});
|