codeceptjs 3.7.6-beta.1 → 3.7.6-beta.2
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/lib/codecept.js +8 -1
- package/lib/command/workers/runTests.js +39 -1
- package/lib/helper/Appium.js +4 -2
- package/lib/helper/Playwright.js +38 -3
- package/package.json +5 -5
- package/typings/index.d.ts +10 -11
- package/typings/promiseBasedTypes.d.ts +8 -0
- package/typings/types.d.ts +8 -0
package/lib/codecept.js
CHANGED
|
@@ -122,6 +122,7 @@ class Codecept {
|
|
|
122
122
|
/**
|
|
123
123
|
* Executes bootstrap.
|
|
124
124
|
*
|
|
125
|
+
* @returns {Promise<void>}
|
|
125
126
|
*/
|
|
126
127
|
async bootstrap() {
|
|
127
128
|
return runHook(this.config.bootstrap, 'bootstrap')
|
|
@@ -129,7 +130,8 @@ class Codecept {
|
|
|
129
130
|
|
|
130
131
|
/**
|
|
131
132
|
* Executes teardown.
|
|
132
|
-
|
|
133
|
+
*
|
|
134
|
+
* @returns {Promise<void>}
|
|
133
135
|
*/
|
|
134
136
|
async teardown() {
|
|
135
137
|
return runHook(this.config.teardown, 'teardown')
|
|
@@ -262,6 +264,11 @@ class Codecept {
|
|
|
262
264
|
})
|
|
263
265
|
}
|
|
264
266
|
|
|
267
|
+
/**
|
|
268
|
+
* Returns the version string of CodeceptJS.
|
|
269
|
+
*
|
|
270
|
+
* @returns {string} The version string.
|
|
271
|
+
*/
|
|
265
272
|
static version() {
|
|
266
273
|
return JSON.parse(readFileSync(`${__dirname}/../package.json`, 'utf8')).version
|
|
267
274
|
}
|
|
@@ -23,11 +23,49 @@ const Codecept = require(process.env.CODECEPT_CLASS_PATH || '../../codecept')
|
|
|
23
23
|
const { options, tests, testRoot, workerIndex, poolMode } = workerData
|
|
24
24
|
|
|
25
25
|
// hide worker output
|
|
26
|
-
if
|
|
26
|
+
// In pool mode, only suppress output if debug is NOT enabled
|
|
27
|
+
// In regular mode, hide result output but allow step output in verbose/debug
|
|
28
|
+
if (poolMode && !options.debug) {
|
|
29
|
+
// In pool mode without debug, suppress only result summaries and failures, but allow Scenario Steps
|
|
30
|
+
const originalWrite = process.stdout.write
|
|
31
|
+
process.stdout.write = string => {
|
|
32
|
+
// Always allow Scenario Steps output (including the circle symbol)
|
|
33
|
+
if (string.includes('Scenario Steps:') || string.includes('◯ Scenario Steps:')) {
|
|
34
|
+
return originalWrite.call(process.stdout, string)
|
|
35
|
+
}
|
|
36
|
+
if (string.includes(' FAIL |') || string.includes(' OK |') || string.includes('-- FAILURES:') || string.includes('AssertionError:') || string.includes('◯ File:')) {
|
|
37
|
+
return true
|
|
38
|
+
}
|
|
39
|
+
return originalWrite.call(process.stdout, string)
|
|
40
|
+
}
|
|
41
|
+
} else if (!poolMode && !options.debug && !options.verbose) {
|
|
27
42
|
process.stdout.write = string => {
|
|
28
43
|
stdout += string
|
|
29
44
|
return true
|
|
30
45
|
}
|
|
46
|
+
} else {
|
|
47
|
+
// In verbose/debug mode for test/suite modes, show step details
|
|
48
|
+
// but suppress individual worker result summaries to avoid duplicate output
|
|
49
|
+
const originalWrite = process.stdout.write
|
|
50
|
+
const originalConsoleLog = console.log
|
|
51
|
+
|
|
52
|
+
process.stdout.write = string => {
|
|
53
|
+
// Suppress individual worker result summaries and failure reports
|
|
54
|
+
if (string.includes(' FAIL |') || string.includes(' OK |') || string.includes('-- FAILURES:') || string.includes('AssertionError:') || string.includes('◯ File:') || string.includes('◯ Scenario Steps:')) {
|
|
55
|
+
return true
|
|
56
|
+
}
|
|
57
|
+
return originalWrite.call(process.stdout, string)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Override console.log to catch result summaries
|
|
61
|
+
console.log = (...args) => {
|
|
62
|
+
const fullMessage = args.join(' ')
|
|
63
|
+
if (fullMessage.includes(' FAIL |') || fullMessage.includes(' OK |') || fullMessage.includes('-- FAILURES:')) {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
return originalConsoleLog.apply(console, args)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
31
69
|
|
|
32
70
|
const overrideConfigs = tryOrDefault(() => JSON.parse(options.override), {})
|
|
33
71
|
|
package/lib/helper/Appium.js
CHANGED
|
@@ -261,11 +261,13 @@ class Appium extends Webdriver {
|
|
|
261
261
|
|
|
262
262
|
this.platform = null
|
|
263
263
|
if (config.capabilities[`${vendorPrefix.appium}:platformName`]) {
|
|
264
|
-
|
|
264
|
+
config.capabilities[`${vendorPrefix.appium}:platformName`] = config.capabilities[`${vendorPrefix.appium}:platformName`].toLowerCase()
|
|
265
|
+
this.platform = config.capabilities[`${vendorPrefix.appium}:platformName`]
|
|
265
266
|
}
|
|
266
267
|
|
|
267
268
|
if (config.capabilities.platformName) {
|
|
268
|
-
|
|
269
|
+
config.capabilities.platformName = config.capabilities.platformName.toLowerCase()
|
|
270
|
+
this.platform = config.capabilities.platformName
|
|
269
271
|
}
|
|
270
272
|
|
|
271
273
|
return config
|
package/lib/helper/Playwright.js
CHANGED
|
@@ -98,7 +98,13 @@ const pathSeparator = path.sep
|
|
|
98
98
|
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
99
99
|
* @prop {object} [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
|
|
100
100
|
* @prop {string} [testIdAttribute=data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
|
|
101
|
-
* @prop {object} [customLocatorStrategies] - custom locator strategies. An object with keys as strategy names and values as JavaScript functions. Example: `{ byRole: (selector, root) => { return root.querySelector(
|
|
101
|
+
* @prop {object} [customLocatorStrategies] - custom locator strategies. An object with keys as strategy names and values as JavaScript functions. Example: `{ byRole: (selector, root) => { return root.querySelector(`[role="${selector}"]`) } }`
|
|
102
|
+
* @prop {string|object} [storageState] - Playwright storage state (path to JSON file or object)
|
|
103
|
+
* passed directly to `browser.newContext`.
|
|
104
|
+
* If a Scenario is declared with a `cookies` option (e.g. `Scenario('name', { cookies: [...] }, fn)`),
|
|
105
|
+
* those cookies are used instead and the configured `storageState` is ignored (no merge).
|
|
106
|
+
* May include session cookies, auth tokens, localStorage and (if captured with
|
|
107
|
+
* `grabStorageState({ indexedDB: true })`) IndexedDB data; treat as sensitive and do not commit.
|
|
102
108
|
*/
|
|
103
109
|
const config = {}
|
|
104
110
|
|
|
@@ -360,6 +366,11 @@ class Playwright extends Helper {
|
|
|
360
366
|
// override defaults with config
|
|
361
367
|
this._setConfig(config)
|
|
362
368
|
|
|
369
|
+
// pass storageState directly (string path or object) and let Playwright handle errors/missing file
|
|
370
|
+
if (typeof config.storageState !== 'undefined') {
|
|
371
|
+
this.storageState = config.storageState
|
|
372
|
+
}
|
|
373
|
+
|
|
363
374
|
}
|
|
364
375
|
|
|
365
376
|
_validateConfig(config) {
|
|
@@ -386,6 +397,7 @@ class Playwright extends Helper {
|
|
|
386
397
|
use: { actionTimeout: 0 },
|
|
387
398
|
ignoreHTTPSErrors: false, // Adding it here o that context can be set up to ignore the SSL errors,
|
|
388
399
|
highlightElement: false,
|
|
400
|
+
storageState: undefined,
|
|
389
401
|
}
|
|
390
402
|
|
|
391
403
|
process.env.testIdAttribute = 'data-testid'
|
|
@@ -589,8 +601,7 @@ class Playwright extends Helper {
|
|
|
589
601
|
|
|
590
602
|
// load pre-saved cookies
|
|
591
603
|
if (test?.opts?.cookies) contextOptions.storageState = { cookies: test.opts.cookies }
|
|
592
|
-
|
|
593
|
-
if (this.storageState) contextOptions.storageState = this.storageState
|
|
604
|
+
else if (this.storageState) contextOptions.storageState = this.storageState
|
|
594
605
|
if (this.options.userAgent) contextOptions.userAgent = this.options.userAgent
|
|
595
606
|
if (this.options.locale) contextOptions.locale = this.options.locale
|
|
596
607
|
if (this.options.colorScheme) contextOptions.colorScheme = this.options.colorScheme
|
|
@@ -2162,6 +2173,30 @@ class Playwright extends Helper {
|
|
|
2162
2173
|
if (cookie[0]) return cookie[0]
|
|
2163
2174
|
}
|
|
2164
2175
|
|
|
2176
|
+
/**
|
|
2177
|
+
* Grab the current storage state (cookies, localStorage, etc.) via Playwright's `browserContext.storageState()`.
|
|
2178
|
+
* Returns the raw object that Playwright provides.
|
|
2179
|
+
*
|
|
2180
|
+
* Security: The returned object can contain authentication tokens, session cookies
|
|
2181
|
+
* and (when `indexedDB: true` is used) data that may include user PII. Treat it as a secret.
|
|
2182
|
+
* Avoid committing it to source control and prefer storing it in a protected secrets store / CI artifact vault.
|
|
2183
|
+
*
|
|
2184
|
+
* @param {object} [options]
|
|
2185
|
+
* @param {boolean} [options.indexedDB] set to true to include IndexedDB in snapshot (Playwright >=1.51)
|
|
2186
|
+
*
|
|
2187
|
+
* ```js
|
|
2188
|
+
* // basic usage
|
|
2189
|
+
* const state = await I.grabStorageState();
|
|
2190
|
+
* require('fs').writeFileSync('authState.json', JSON.stringify(state));
|
|
2191
|
+
*
|
|
2192
|
+
* // include IndexedDB when using Firebase Auth, etc.
|
|
2193
|
+
* const stateWithIDB = await I.grabStorageState({ indexedDB: true });
|
|
2194
|
+
* ```
|
|
2195
|
+
*/
|
|
2196
|
+
async grabStorageState(options = {}) {
|
|
2197
|
+
return this.browserContext.storageState(options)
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2165
2200
|
/**
|
|
2166
2201
|
* {{> clearCookie }}
|
|
2167
2202
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeceptjs",
|
|
3
|
-
"version": "3.7.6-beta.
|
|
3
|
+
"version": "3.7.6-beta.2",
|
|
4
4
|
"description": "Supercharged End 2 End Testing Framework for NodeJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acceptance",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"cross-spawn": "7.0.6",
|
|
97
97
|
"css-to-xpath": "0.1.0",
|
|
98
98
|
"csstoxpath": "1.6.0",
|
|
99
|
-
"envinfo": "7.
|
|
99
|
+
"envinfo": "7.15.0",
|
|
100
100
|
"escape-string-regexp": "4.0.0",
|
|
101
101
|
"figures": "3.2.0",
|
|
102
102
|
"fn-args": "4.0.0",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"@pollyjs/core": "6.0.6",
|
|
139
139
|
"@types/chai": "5.2.2",
|
|
140
140
|
"@types/inquirer": "9.0.9",
|
|
141
|
-
"@types/node": "24.
|
|
141
|
+
"@types/node": "24.6.0",
|
|
142
142
|
"@wdio/sauce-service": "9.12.5",
|
|
143
143
|
"@wdio/selenium-standalone-service": "8.15.0",
|
|
144
144
|
"@wdio/utils": "9.19.2",
|
|
@@ -147,11 +147,11 @@
|
|
|
147
147
|
"chai-as-promised": "7.1.2",
|
|
148
148
|
"chai-subset": "1.6.0",
|
|
149
149
|
"documentation": "14.0.3",
|
|
150
|
-
"electron": "38.
|
|
150
|
+
"electron": "38.2.0",
|
|
151
151
|
"eslint": "^9.36.0",
|
|
152
152
|
"eslint-plugin-import": "2.32.0",
|
|
153
153
|
"eslint-plugin-mocha": "11.1.0",
|
|
154
|
-
"expect": "30.
|
|
154
|
+
"expect": "30.2.0",
|
|
155
155
|
"express": "^5.1.0",
|
|
156
156
|
"globals": "16.4.0",
|
|
157
157
|
"graphql": "16.11.0",
|
package/typings/index.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ declare namespace CodeceptJS {
|
|
|
97
97
|
* tests: 'tests/**.test.ts'
|
|
98
98
|
* ```
|
|
99
99
|
*/
|
|
100
|
-
tests: string
|
|
100
|
+
tests: string | string[]
|
|
101
101
|
/**
|
|
102
102
|
* Where to store failure screenshots, artifacts, etc
|
|
103
103
|
*
|
|
@@ -520,17 +520,16 @@ declare namespace CodeceptJS {
|
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
-
type TryTo = <T>(fn: () => Promise<T> | T) => Promise<T | false
|
|
524
|
-
type HopeThat = <T>(fn: () => Promise<T> | T) => Promise<T | false
|
|
525
|
-
type RetryTo = <T>(fn: () => Promise<T> | T, retries?: number) => Promise<T
|
|
526
|
-
|
|
523
|
+
type TryTo = <T>(fn: () => Promise<T> | T) => Promise<T | false>
|
|
524
|
+
type HopeThat = <T>(fn: () => Promise<T> | T) => Promise<T | false>
|
|
525
|
+
type RetryTo = <T>(fn: () => Promise<T> | T, retries?: number) => Promise<T>
|
|
527
526
|
|
|
528
527
|
// Globals
|
|
529
528
|
declare const codecept_dir: string
|
|
530
529
|
declare const output_dir: string
|
|
531
|
-
declare const tryTo: TryTo
|
|
532
|
-
declare const retryTo: RetryTo
|
|
533
|
-
declare const hopeThat: HopeThat
|
|
530
|
+
declare const tryTo: TryTo
|
|
531
|
+
declare const retryTo: RetryTo
|
|
532
|
+
declare const hopeThat: HopeThat
|
|
534
533
|
|
|
535
534
|
declare const actor: CodeceptJS.actor
|
|
536
535
|
declare const codecept_actor: CodeceptJS.actor
|
|
@@ -643,7 +642,7 @@ declare module '@codeceptjs/helper' {
|
|
|
643
642
|
}
|
|
644
643
|
|
|
645
644
|
declare module 'codeceptjs/effects' {
|
|
646
|
-
export const tryTo: TryTo
|
|
647
|
-
export const retryTo: RetryTo
|
|
648
|
-
export const hopeThat: HopeThat
|
|
645
|
+
export const tryTo: TryTo
|
|
646
|
+
export const retryTo: RetryTo
|
|
647
|
+
export const hopeThat: HopeThat
|
|
649
648
|
}
|
|
@@ -2737,6 +2737,8 @@ declare namespace CodeceptJS {
|
|
|
2737
2737
|
*/
|
|
2738
2738
|
// @ts-ignore
|
|
2739
2739
|
// @ts-ignore
|
|
2740
|
+
// @ts-ignore
|
|
2741
|
+
// @ts-ignore
|
|
2740
2742
|
type PlaywrightConfig = {
|
|
2741
2743
|
url?: string;
|
|
2742
2744
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6116,6 +6118,8 @@ declare namespace CodeceptJS {
|
|
|
6116
6118
|
*/
|
|
6117
6119
|
// @ts-ignore
|
|
6118
6120
|
// @ts-ignore
|
|
6121
|
+
// @ts-ignore
|
|
6122
|
+
// @ts-ignore
|
|
6119
6123
|
type PuppeteerConfig = {
|
|
6120
6124
|
url: string;
|
|
6121
6125
|
basicAuth?: any;
|
|
@@ -7962,6 +7966,8 @@ declare namespace CodeceptJS {
|
|
|
7962
7966
|
*/
|
|
7963
7967
|
// @ts-ignore
|
|
7964
7968
|
// @ts-ignore
|
|
7969
|
+
// @ts-ignore
|
|
7970
|
+
// @ts-ignore
|
|
7965
7971
|
type RESTConfig = {
|
|
7966
7972
|
endpoint?: string;
|
|
7967
7973
|
prettyPrintJson?: boolean;
|
|
@@ -9119,6 +9125,8 @@ declare namespace CodeceptJS {
|
|
|
9119
9125
|
*/
|
|
9120
9126
|
// @ts-ignore
|
|
9121
9127
|
// @ts-ignore
|
|
9128
|
+
// @ts-ignore
|
|
9129
|
+
// @ts-ignore
|
|
9122
9130
|
type WebDriverConfig = {
|
|
9123
9131
|
url: string;
|
|
9124
9132
|
browser: string;
|
package/typings/types.d.ts
CHANGED
|
@@ -2827,6 +2827,8 @@ declare namespace CodeceptJS {
|
|
|
2827
2827
|
*/
|
|
2828
2828
|
// @ts-ignore
|
|
2829
2829
|
// @ts-ignore
|
|
2830
|
+
// @ts-ignore
|
|
2831
|
+
// @ts-ignore
|
|
2830
2832
|
type PlaywrightConfig = {
|
|
2831
2833
|
url?: string;
|
|
2832
2834
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6357,6 +6359,8 @@ declare namespace CodeceptJS {
|
|
|
6357
6359
|
*/
|
|
6358
6360
|
// @ts-ignore
|
|
6359
6361
|
// @ts-ignore
|
|
6362
|
+
// @ts-ignore
|
|
6363
|
+
// @ts-ignore
|
|
6360
6364
|
type PuppeteerConfig = {
|
|
6361
6365
|
url: string;
|
|
6362
6366
|
basicAuth?: any;
|
|
@@ -8339,6 +8343,8 @@ declare namespace CodeceptJS {
|
|
|
8339
8343
|
*/
|
|
8340
8344
|
// @ts-ignore
|
|
8341
8345
|
// @ts-ignore
|
|
8346
|
+
// @ts-ignore
|
|
8347
|
+
// @ts-ignore
|
|
8342
8348
|
type RESTConfig = {
|
|
8343
8349
|
endpoint?: string;
|
|
8344
8350
|
prettyPrintJson?: boolean;
|
|
@@ -9556,6 +9562,8 @@ declare namespace CodeceptJS {
|
|
|
9556
9562
|
*/
|
|
9557
9563
|
// @ts-ignore
|
|
9558
9564
|
// @ts-ignore
|
|
9565
|
+
// @ts-ignore
|
|
9566
|
+
// @ts-ignore
|
|
9559
9567
|
type WebDriverConfig = {
|
|
9560
9568
|
url: string;
|
|
9561
9569
|
browser: string;
|