Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5df2d1

Browse files
mccmrunalbgrozev
andauthored
fix(jasmine-framework): move @types/jasmine to dependencies (#15001)
* fix(jasmine-framework): move @types/jasmine to dependencies Fixes #14475 * fix: Allow specFileRetries to be overriden in the beforeSession hook (#14859) This fixes #14842. This initializes the launcher's specFileRetries to -1 instead of reading from the config. The worker then reads the value from the config after running the beforeSession hook, and includes the value in the "sessionStarted" message, which is then passed back to the launcher when the worker ends. * updated pnpm-lock --------- Co-authored-by: bgrozev <[email protected]>
1 parent fd31977 commit e5df2d1

4 files changed

Lines changed: 85 additions & 8 deletions

File tree

packages/wdio-jasmine-framework/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"url": "https://github.com/webdriverio/webdriverio/issues"
3535
},
3636
"dependencies": {
37+
"@types/jasmine": "^5.1.13",
3738
"@types/node": "^20.1.0",
3839
"@wdio/globals": "workspace:*",
3940
"@wdio/logger": "workspace:*",
@@ -42,7 +43,6 @@
4243
"jasmine": "^5.0.0"
4344
},
4445
"devDependencies": {
45-
"@types/jasmine": "5.1.13",
4646
"expect-webdriverio": "^5.3.4"
4747
},
4848
"peerDependencies": {

packages/wdio-sauce-service/src/service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ export default class SauceService implements Services.ServiceInstance {
113113
* This tweak allows us to set the real suite name for jasmine jobs.
114114
*/
115115
/* istanbul ignore if */
116-
if (this._suiteTitle === 'Jasmine__TopLevel__Suite') {
117-
this._suiteTitle = test.fullName.slice(0, test.fullName.indexOf(test.description || '') - 1)
116+
/* istanbul ignore if */
117+
if (this._suiteTitle === 'Jasmine__TopLevel__Suite' && test.fullName) {
118+
const descriptionIndex = test.fullName.indexOf(test.description || '')
119+
this._suiteTitle = descriptionIndex > 0 ? test.fullName.slice(0, descriptionIndex - 1) : test.title || this._suiteTitle
118120
}
119121

120122
if (this._browser && !this._isJobNameSet) {

packages/wdio-sauce-service/tests/service.test.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,81 @@ test('setAnnotation for VDC and RDC with multi remote', async () => {
10681068
expect(browserChromeC.executeScript).toBeCalledWith('sauce:context=foo', [])
10691069
})
10701070

1071+
test('beforeTest should not throw if fullName is undefined (Jasmine hook)', async () => {
1072+
const service = new SauceService({}, {}, { user: 'foobar', key: '123' } as any)
1073+
service['_browser'] = browser
1074+
service['_suiteTitle'] = 'Jasmine__TopLevel__Suite'
1075+
1076+
// Simulate a test object that lacks fullName, which reportedly happens in some Jasmine hooks
1077+
const testObj = {
1078+
description: 'some test',
1079+
// fullName is missing or undefined
1080+
} as any
1081+
1082+
// This should NOT throw "TypeError: Cannot read properties of undefined (reading 'slice')" anymore
1083+
await expect(service.beforeTest(testObj)).resolves.not.toThrow()
1084+
})
1085+
1086+
test('beforeTest should fallback to title if description is missing in fullName (Jasmine)', async () => {
1087+
const service = new SauceService({}, {}, { user: 'foobar', key: '123' } as any)
1088+
service['_browser'] = browser
1089+
service['_suiteTitle'] = 'Jasmine__TopLevel__Suite'
1090+
1091+
const testObj = {
1092+
fullName: 'My Suite My Test',
1093+
description: undefined, // description missing
1094+
title: 'My Test'
1095+
} as any
1096+
1097+
await service.beforeTest(testObj)
1098+
// Fallback to test.title or keep existing suite title if extraction fails
1099+
expect(service['_suiteTitle']).toBe('My Test')
1100+
})
1101+
1102+
test('beforeTest should fallback to title if description is not found in fullName (Jasmine)', async () => {
1103+
const service = new SauceService({}, {}, { user: 'foobar', key: '123' } as any)
1104+
service['_browser'] = browser
1105+
service['_suiteTitle'] = 'Jasmine__TopLevel__Suite'
1106+
1107+
const testObj = {
1108+
fullName: 'My Suite My Test',
1109+
description: 'Other Test', // description not in fullName
1110+
title: 'My Test'
1111+
} as any
1112+
1113+
await service.beforeTest(testObj)
1114+
expect(service['_suiteTitle']).toBe('My Test')
1115+
})
1116+
1117+
test('beforeTest should keep existing suite title if extraction fails and no test title (Jasmine)', async () => {
1118+
const service = new SauceService({}, {}, { user: 'foobar', key: '123' } as any)
1119+
service['_browser'] = browser
1120+
service['_suiteTitle'] = 'Jasmine__TopLevel__Suite'
1121+
1122+
const testObj = {
1123+
fullName: 'My Suite My Test',
1124+
description: 'Other Test',
1125+
// no title
1126+
} as any
1127+
1128+
await service.beforeTest(testObj)
1129+
expect(service['_suiteTitle']).toBe('Jasmine__TopLevel__Suite')
1130+
})
1131+
1132+
test('beforeTest should correctly extract suite title when description is present (Jasmine Happy Path)', async () => {
1133+
const service = new SauceService({}, {}, { user: 'foobar', key: '123' } as any)
1134+
service['_browser'] = browser
1135+
service['_suiteTitle'] = 'Jasmine__TopLevel__Suite'
1136+
1137+
const testObj = {
1138+
fullName: 'My Suite My Test',
1139+
description: 'My Test'
1140+
} as any
1141+
1142+
await service.beforeTest(testObj)
1143+
expect(service['_suiteTitle']).toBe('My Suite')
1144+
})
1145+
10711146
afterEach(() => {
10721147
// @ts-ignore
10731148
browser = undefined

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)