Skip to content

Commit 8fc1284

Browse files
committed
Merge branch '3.x' into task-4593-bump-webdriverio
2 parents b65988b + 02420fa commit 8fc1284

File tree

16 files changed

+174
-64
lines changed

16 files changed

+174
-64
lines changed

CHANGELOG.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,67 @@
1+
## 3.6.10
2+
3+
❤️ Thanks all to those who contributed to make this release! ❤️
4+
5+
🐛 *Bug Fixes*
6+
fix(cli): missing failure counts when there is failedHooks (#4633) - by @kobenguyent
7+
8+
## 3.6.9
9+
10+
❤️ Thanks all to those who contributed to make this release! ❤️
11+
12+
🐛 *Hot Fixes*
13+
fix: could not run tests due to missing `invisi-data` lib - by @kobenguyent
14+
15+
## 3.6.8
16+
17+
❤️ Thanks all to those who contributed to make this release! ❤️
18+
19+
🛩️ *Features*
20+
* feat(cli): mask sensitive data in logs (#4630) - by @kobenguyent
21+
```
22+
export const config: CodeceptJS.MainConfig = {
23+
tests: '**/*.e2e.test.ts',
24+
retry: 4,
25+
output: './output',
26+
maskSensitiveData: true,
27+
emptyOutputFolder: true,
28+
...
29+
30+
I login {"username":"[email protected]","password": "****"}
31+
I send post request "https://localhost:8000/login", {"username":"[email protected]","password": "****"}
32+
› [Request] {"baseURL":"https://localhost:8000/login","method":"POST","data":{"username":"[email protected]","password": "****"},"headers":{}}
33+
› [Response] {"access-token": "****"}
34+
```
35+
36+
* feat(REST): DELETE request supports payload (#4493) - by @schaudhary111
37+
38+
```js
39+
I.sendDeleteRequestWithPayload('/api/users/1', { author: 'john' });
40+
```
41+
42+
🐛 *Bug Fixes*
43+
* fix(playwright): Different behavior of see* and waitFor* when used in within (#4557) - by @kobenguyent
44+
* fix(cli): dry run returns no tests when using a regex grep (#4608) - by @kobenguyent
45+
```bash
46+
> codeceptjs dry-run --steps --grep "(?=.*Checkout process)"
47+
```
48+
* fix: Replace deprecated faker.name with faker.person (#4581) - by @thomashohn
49+
* fix(wdio): Remove dependency to devtools (#4563) - by @thomashohn
50+
* fix(typings): wrong defineParameterType (#4548) - by @kobenguyent
51+
* fix(typing): `Locator.build` complains the empty locator (#4543) - by @kobenguyent
52+
* fix: add hint to `I.seeEmailAttachment` treats parameter as regular expression (#4629) - by @ngraf
53+
```
54+
Add hint to "I.seeEmailAttachment" that under the hood parameter is treated as RegExp.
55+
When you don't know it, it can cause a lot of pain, wondering why your test fails with I.seeEmailAttachment('Attachment(1).pdf') although it looks just fine, but actually I.seeEmailAttachment('Attachment\\(1\\).pdf is required to make the test green, in case the attachment is called "Attachment(1).pdf" with special character in it.
56+
```
57+
* fix(playwright): waitForText fails when text contains double quotes (#4528) - by @DavertMik
58+
* fix(mock-server-helper): move to stand-alone package: https://www.npmjs.com/package/@codeceptjs/mock-server-helper (#4536) - by @kobenguyent
59+
* fix(appium): issue with async on runOnIos and runOnAndroid (#4525) - by @kobenguyent
60+
* fix: push ws messages to array (#4513) - by @kobenguyent
61+
62+
📖 *Documentation*
63+
* fix(docs): typo in ai.md (#4501) - by @tomaculum
64+
165
## 3.6.6
266

367
❤️ Thanks all to those who contributed to make this release! ❤️

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ Thanks all to those who are and will have contributing to this awesome project!
315315
<a href="https://github.com/thomashohn"><img src="https://avatars.githubusercontent.com/u/3414869?v=4" title="thomashohn" width="80" height="80"></a>
316316
<a href="https://github.com/elaichenkov"><img src="https://avatars.githubusercontent.com/u/29764053?v=4" title="elaichenkov" width="80" height="80"></a>
317317
<a href="https://github.com/BorisOsipov"><img src="https://avatars.githubusercontent.com/u/6514276?v=4" title="BorisOsipov" width="80" height="80"></a>
318+
<a href="https://github.com/ngraf"><img src="https://avatars.githubusercontent.com/u/7094389?v=4" title="ngraf" width="80" height="80"></a>
318319
<a href="https://github.com/nitschSB"><img src="https://avatars.githubusercontent.com/u/39341455?v=4" title="nitschSB" width="80" height="80"></a>
319320
<a href="https://github.com/hubidu"><img src="https://avatars.githubusercontent.com/u/13134082?v=4" title="hubidu" width="80" height="80"></a>
320321
<a href="https://github.com/jploskonka"><img src="https://avatars.githubusercontent.com/u/669483?v=4" title="jploskonka" width="80" height="80"></a>
321-
<a href="https://github.com/ngraf"><img src="https://avatars.githubusercontent.com/u/7094389?v=4" title="ngraf" width="80" height="80"></a>
322322
<a href="https://github.com/maojunxyz"><img src="https://avatars.githubusercontent.com/u/28778042?v=4" title="maojunxyz" width="80" height="80"></a>
323323
<a href="https://github.com/abhimanyupandian"><img src="https://avatars.githubusercontent.com/u/36107381?v=4" title="abhimanyupandian" width="80" height="80"></a>
324324
<a href="https://github.com/martomo"><img src="https://avatars.githubusercontent.com/u/1850135?v=4" title="martomo" width="80" height="80"></a>

docs/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ After running `codeceptjs init` it should be saved in test root.
2929
| `tests` | `string` | Pattern to locate CodeceptJS tests. Allows to enter glob pattern or an Array<string> of patterns to match tests / test file names. For tests in JavaScript: ```tests: 'tests/**.test.js' ``` For tests in TypeScript: ```tests: 'tests/**.test.ts' ``` |
3030
| `timeout?` | `number` | Set default tests timeout in seconds. Tests will be killed on no response after timeout. ```timeout: 20, ``` |
3131
| `translation?` | `string` | Enable [localized test commands](https://codecept.io/translation/) |
32+
| `maskSensitiveData?` | `boolean` | Enable to mask Sensitive Data in console. |
3233

3334

3435
## Require

docs/email.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ I.seeEmailIsFrom('@mysite.com');
156156
I.seeInEmailSubject('Awesome Proposal!');
157157
I.seeInEmailBody('To unsubscribe click here');
158158
I.seeNumberOfEmailAttachments(2);
159-
I.seeEmailAttachment('Attachment_1.pdf')
160-
I.seeEmailAttachment('Attachment_2.pdf')
159+
I.seeEmailAttachment('Attachment_1.pdf'); // Regular expression. Escape special characters like '(' or ')' in filename.
160+
I.seeEmailAttachment('Attachment_2.pdf');
161161
```
162162

163163
> More methods are listed in [helper's API reference](https://github.com/codeceptjs/mailslurp-helper/blob/master/README.md#api)

lib/cli.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ class Cli extends Base {
219219

220220
this.failures.forEach((failure) => {
221221
if (failure.constructor.name === 'Hook') {
222-
stats.failures -= stats.failures
223222
stats.failedHooks += 1
224223
}
225224
})

lib/codecept.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class Codecept {
9292

9393
// debug mode
9494
global.debugMode = false;
95+
96+
// mask sensitive data
97+
global.maskSensitiveData = this.config.maskSensitiveData || false;
9598
}
9699
}
97100

lib/command/dryRun.js

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const store = require('../store')
77
const Container = require('../container')
88

99
module.exports = async function (test, options) {
10-
if (options.grep) process.env.grep = options.grep.toLowerCase()
10+
if (options.grep) process.env.grep = options.grep
1111
const configFile = options.config
1212
let codecept
1313

@@ -60,35 +60,40 @@ function printTests(files) {
6060
let numOfTests = 0
6161
let numOfSuites = 0
6262
let outputString = ''
63-
const filterBy = process.env.grep ? process.env.grep.toLowerCase() : undefined
63+
const filterBy = process.env.grep
6464

65+
let filterRegex
6566
if (filterBy) {
66-
for (const suite of mocha.suite.suites) {
67-
const currentSuite = suite.title
68-
if (suite.title.toLowerCase().includes(filterBy)) {
69-
outputString += `${colors.white.bold(suite.title)} -- ${output.styles.log(suite.file || '')} -- ${mocha.suite.suites.length} tests\n`
70-
numOfSuites++
71-
}
72-
73-
for (test of suite.tests) {
74-
if (test.title.toLowerCase().includes(filterBy)) {
75-
numOfTests++
76-
outputString += `${colors.white.bold(test.parent.title)} -- ${output.styles.log(test.parent.file || '')} -- ${mocha.suite.suites.length} tests\n`
77-
outputString += ` ${output.styles.scenario(figures.checkboxOff)} ${test.title}\n`
78-
}
79-
}
67+
try {
68+
filterRegex = new RegExp(filterBy, 'i') // Case-insensitive matching
69+
} catch (err) {
70+
console.error(`Invalid grep pattern: ${filterBy}`)
71+
process.exit(1)
8072
}
81-
numOfSuites = countSuites(outputString)
82-
} else {
83-
for (const suite of mocha.suite.suites) {
84-
output.print(
85-
`${colors.white.bold(suite.title)} -- ${output.styles.log(suite.file || '')} -- ${mocha.suite.suites.length} tests`,
86-
)
73+
}
74+
75+
for (const suite of mocha.suite.suites) {
76+
const suiteMatches = filterRegex ? filterRegex.test(suite.title) : true
77+
let suiteHasMatchingTests = false
78+
79+
if (suiteMatches) {
80+
outputString += `${colors.white.bold(suite.title)} -- ${output.styles.log(suite.file || '')}\n`
81+
suiteHasMatchingTests = true
8782
numOfSuites++
83+
}
84+
85+
for (const test of suite.tests) {
86+
const testMatches = filterRegex ? filterRegex.test(test.title) : true
87+
88+
if (testMatches) {
89+
if (!suiteMatches && !suiteHasMatchingTests) {
90+
outputString += `${colors.white.bold(suite.title)} -- ${output.styles.log(suite.file || '')}\n`
91+
suiteHasMatchingTests = true
92+
numOfSuites++
93+
}
8894

89-
for (test of suite.tests) {
9095
numOfTests++
91-
output.print(` ${output.styles.scenario(figures.checkboxOff)} ${test.title}`)
96+
outputString += ` ${output.styles.scenario(figures.checkboxOff)} ${test.title}\n`
9297
}
9398
}
9499
}
@@ -108,15 +113,5 @@ function printFooter() {
108113
function removeDuplicates(inputString) {
109114
const array = inputString.split('\n')
110115
const uniqueLines = [...new Set(array)]
111-
const resultString = uniqueLines.join('\n')
112-
113-
return resultString
114-
}
115-
116-
function countSuites(inputString) {
117-
const array = inputString.split('\n')
118-
119-
const uniqueLines = [...new Set(array)]
120-
const res = uniqueLines.filter((item) => item.includes('-- '))
121-
return res.length
116+
return uniqueLines.join('\n')
122117
}

lib/helper/Playwright.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ class Playwright extends Helper {
12831283
* ```
12841284
*/
12851285
async _locate(locator) {
1286-
const context = (await this.context) || (await this._getContext())
1286+
const context = await this._getContext()
12871287

12881288
if (this.frame) return findElements(this.frame, locator)
12891289

@@ -1299,7 +1299,7 @@ class Playwright extends Helper {
12991299
* ```
13001300
*/
13011301
async _locateElement(locator) {
1302-
const context = (await this.context) || (await this._getContext())
1302+
const context = await this._getContext()
13031303
return findElement(context, locator)
13041304
}
13051305

@@ -2736,7 +2736,7 @@ class Playwright extends Helper {
27362736
}
27372737

27382738
async _getContext() {
2739-
if (this.context && this.context.constructor.name === 'FrameLocator') {
2739+
if ((this.context && this.context.constructor.name === 'FrameLocator') || this.context) {
27402740
return this.context
27412741
}
27422742
return this.page

lib/output.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const colors = require('chalk');
22
const figures = require('figures');
3+
const { maskSensitiveData } = require('invisi-data')
34

45
const styles = {
56
error: colors.bgRed.white.bold,
@@ -57,8 +58,9 @@ module.exports = {
5758
* @param {string} msg
5859
*/
5960
debug(msg) {
61+
const _msg = isMaskedData() ? maskSensitiveData(msg) : msg
6062
if (outputLevel >= 2) {
61-
print(' '.repeat(this.stepShift), styles.debug(`${figures.pointerSmall} ${msg}`));
63+
print(' '.repeat(this.stepShift), styles.debug(`${figures.pointerSmall} ${_msg}`));
6264
}
6365
},
6466

@@ -67,8 +69,9 @@ module.exports = {
6769
* @param {string} msg
6870
*/
6971
log(msg) {
72+
const _msg = isMaskedData() ? maskSensitiveData(msg) : msg
7073
if (outputLevel >= 3) {
71-
print(' '.repeat(this.stepShift), styles.log(truncate(` ${msg}`, this.spaceShift)));
74+
print(' '.repeat(this.stepShift), styles.log(truncate(` ${_msg}`, this.spaceShift)));
7275
}
7376
},
7477

@@ -120,7 +123,8 @@ module.exports = {
120123
stepLine += colors.grey(step.comment.split('\n').join('\n' + ' '.repeat(4)));
121124
}
122125

123-
print(' '.repeat(this.stepShift), truncate(stepLine, this.spaceShift));
126+
const _stepLine = isMaskedData() ? maskSensitiveData(stepLine) : stepLine
127+
print(' '.repeat(this.stepShift), truncate(_stepLine, this.spaceShift));
124128
},
125129

126130
/** @namespace */
@@ -167,7 +171,7 @@ module.exports = {
167171
scenario: {
168172
/**
169173
* @param {Mocha.Test} test
170-
*/
174+
*/
171175

172176
started(test) {},
173177

@@ -254,3 +258,7 @@ function truncate(msg, gap = 0) {
254258
}
255259
return msg;
256260
}
261+
262+
function isMaskedData() {
263+
return global.maskSensitiveData === true || false
264+
}

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeceptjs",
3-
"version": "3.6.7",
3+
"version": "3.6.10",
44
"description": "Supercharged End 2 End Testing Framework for NodeJS",
55
"keywords": [
66
"acceptance",
@@ -96,14 +96,15 @@
9696
"fs-extra": "11.2.0",
9797
"glob": "6.0.1",
9898
"html-minifier-terser": "7.2.0",
99+
"invisi-data": "^1.0.0",
99100
"inquirer": "6.5.2",
100101
"joi": "17.13.3",
101102
"js-beautify": "1.15.1",
102103
"lodash.clonedeep": "4.5.0",
103104
"lodash.merge": "4.6.2",
104105
"mkdirp": "1.0.4",
105106
"mocha": "10.8.2",
106-
"monocart-coverage-reports": "2.11.2",
107+
"monocart-coverage-reports": "2.11.3",
107108
"ms": "2.1.3",
108109
"ora-classic": "5.4.2",
109110
"parse-function": "5.6.10",
@@ -118,14 +119,14 @@
118119
},
119120
"devDependencies": {
120121
"@codeceptjs/mock-request": "0.3.1",
121-
"@eslint/eslintrc": "3.1.0",
122-
"@eslint/js": "9.14.0",
123-
"@faker-js/faker": "9.2.0",
122+
"@eslint/eslintrc": "3.2.0",
123+
"@eslint/js": "9.16.0",
124+
"@faker-js/faker": "9.3.0",
124125
"@pollyjs/adapter-puppeteer": "6.0.6",
125126
"@pollyjs/core": "5.1.0",
126127
"@types/chai": "4.3.19",
127128
"@types/inquirer": "9.0.3",
128-
"@types/node": "22.9.0",
129+
"@types/node": "22.10.1",
129130
"@wdio/sauce-service": "9.2.13",
130131
"@wdio/selenium-standalone-service": "8.3.2",
131132
"@wdio/utils": "9.2.8",
@@ -136,28 +137,28 @@
136137
"cheerio": "^1.0.0",
137138
"contributor-faces": "1.1.0",
138139
"documentation": "14.0.3",
139-
"electron": "33.2.0",
140-
"eslint": "9.14.0",
140+
"electron": "33.2.1",
141+
"eslint": "9.16.0",
141142
"eslint-config-airbnb-base": "15.0.0",
142143
"eslint-plugin-import": "2.31.0",
143144
"eslint-plugin-mocha": "10.5.0",
144145
"expect": "29.7.0",
145146
"express": "4.21.1",
146147
"globals": "15.12.0",
147148
"graphql": "16.9.0",
148-
"husky": "9.1.6",
149+
"husky": "9.1.7",
149150
"inquirer-test": "2.0.1",
150151
"jsdoc": "4.0.4",
151152
"jsdoc-typeof-plugin": "1.0.0",
152153
"json-server": "0.17.4",
153-
"playwright": "1.48.2",
154+
"playwright": "1.49.0",
154155
"prettier": "^3.3.2",
155156
"puppeteer": "23.8.0",
156157
"qrcode-terminal": "0.12.0",
157158
"rosie": "2.1.1",
158159
"runok": "0.9.3",
159160
"semver": "7.6.3",
160-
"sinon": "18.0.0",
161+
"sinon": "19.0.2",
161162
"sinon-chai": "3.7.0",
162163
"testcafe": "3.7.0",
163164
"ts-morph": "24.0.0",
@@ -166,7 +167,7 @@
166167
"tsd-jsdoc": "2.5.0",
167168
"typedoc": "0.26.11",
168169
"typedoc-plugin-markdown": "4.2.10",
169-
"typescript": "5.6.3",
170+
"typescript": "5.7.2",
170171
"wdio-docker-service": "1.5.0",
171172
"webdriverio": "9.2.14",
172173
"xml2js": "0.6.2",
@@ -183,4 +184,4 @@
183184
"strict": false
184185
}
185186
}
186-
}
187+
}

0 commit comments

Comments
 (0)