Skip to content

Commit fd9de48

Browse files
committed
unit test fixes
1 parent 2118cc8 commit fd9de48

File tree

1 file changed

+41
-32
lines changed

1 file changed

+41
-32
lines changed

tests/service.test.ts

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test('beforeSession should set to unknown creds if no lambdatest user and key ar
2222
const service = new LambdaTestService({}, [] as any, {} as any)
2323
service['_browser'] = browser
2424
service.beforeSession({} as any, {})
25-
expect(service['_isServiceEnabled']).toBe(false)
25+
expect(service['_isServiceEnabled']).toBe(undefined)
2626
})
2727

2828
test('beforeSuite', () => {
@@ -111,8 +111,10 @@ test('after', () => {
111111
service['_browser'].isMultiremote = false
112112
service['_browser'].sessionId = 'foobar'
113113
service.after(5)
114-
115-
expect(updateSpy).toBeCalledWith('foobar', 5)
114+
expect(updateSpy).toBeCalledWith({
115+
sessionId: 'foobar',
116+
failures: 5
117+
});
116118
})
117119

118120
test('after with mochaOpt bail set to 1', () => {
@@ -128,7 +130,10 @@ test('after with mochaOpt bail set to 1', () => {
128130
service['_browser'].config = { mochaOpts: { bail: 1 } }
129131
service.after(1)
130132

131-
expect(updateSpy).toBeCalledWith('foobar', 1)
133+
expect(updateSpy).toBeCalledWith({
134+
'sessionId': 'foobar',
135+
'failures': 1
136+
})
132137
})
133138

134139
test('after in multiremote', () => {
@@ -145,24 +150,24 @@ test('after in multiremote', () => {
145150
service['_browser'].sessionId = 'foobar'
146151
service.after(5)
147152

148-
expect(updateSpy).toBeCalledWith(
149-
'sessionChromeA',
150-
5,
151-
false,
152-
'chromeA'
153-
)
154-
expect(updateSpy).toBeCalledWith(
155-
'sessionChromeB',
156-
5,
157-
false,
158-
'chromeB'
159-
)
160-
expect(updateSpy).toBeCalledWith(
161-
'sessionChromeC',
162-
5,
163-
false,
164-
'chromeC'
165-
)
153+
expect(updateSpy).toBeCalledWith({
154+
'browserName': 'chromeA',
155+
'failures': 5,
156+
'calledOnReload': false,
157+
'sessionId': 'sessionChromeA',
158+
})
159+
expect(updateSpy).toBeCalledWith({
160+
'browserName': 'chromeB',
161+
'failures': 5,
162+
'calledOnReload': false,
163+
'sessionId': 'sessionChromeB',
164+
})
165+
expect(updateSpy).toBeCalledWith({
166+
'browserName': 'chromeC',
167+
'failures': 5,
168+
'calledOnReload': false,
169+
'sessionId': 'sessionChromeC',
170+
})
166171
})
167172

168173
test('after in multiremote', () => {
@@ -180,12 +185,12 @@ test('after in multiremote', () => {
180185
service['_browser'].chromeB.sessionId = 'newSessionChromeB'
181186
service.onReload('sessionChromeB', 'newSessionChromeB')
182187

183-
expect(updateSpy).toBeCalledWith(
184-
'sessionChromeB',
185-
5,
186-
true,
187-
'chromeB'
188-
)
188+
expect(updateSpy).toBeCalledWith({
189+
'browserName': 'chromeB',
190+
'calledOnReload': true,
191+
'failures': 5,
192+
'sessionId': 'sessionChromeB',
193+
})
189194
})
190195

191196
test('onReload', () => {
@@ -199,7 +204,12 @@ test('onReload', () => {
199204
service['_browser'].sessionId = 'foobar'
200205
service.onReload('oldbar', 'newbar')
201206

202-
expect(updateSpy).toBeCalledWith('oldbar', 5, true)
207+
expect(updateSpy).toBeCalledWith({
208+
'calledOnReload': true,
209+
'fullTitle': undefined,
210+
'sessionId': 'oldbar',
211+
'status': 'failed',
212+
})
203213
})
204214

205215
describe('beforeSuite', () => {
@@ -211,7 +221,6 @@ describe('beforeSuite', () => {
211221
expect(service['_fullTitle']).toBeUndefined()
212222
await service.beforeSuite({ title: 'foobar' } as any)
213223
expect(service['_suiteTitle']).toBe('foobar')
214-
// expect(service['_fullTitle']).toBe('foobar')
215224
expect(setSessionNameSpy).toBeCalledWith('foobar')
216225
})
217226

@@ -332,7 +341,7 @@ describe('beforeTest', () => {
332341
await service.beforeSuite({ title: 'Jasmine__TopLevel__Suite' } as any)
333342
await service.beforeTest({ fullName: 'foo bar baz', description: 'baz' } as any)
334343
service.afterTest({ fullName: 'foo bar baz', description: 'baz' } as any, undefined, { passed: true } as any)
335-
expect(setSessionNameSpy).toBeCalledWith('foo bar')
344+
expect(setSessionNameSpy).toBeCalledWith('foo bar baz')
336345
})
337346

338347
it('should set parent suite name as title', async () => {
@@ -345,7 +354,7 @@ describe('beforeTest', () => {
345354
await service.beforeTest({ fullName: 'foo xyz', description: 'xyz' } as any)
346355
service.afterTest({ fullName: 'foo bar baz', description: 'baz' } as any, undefined, { passed: true } as any)
347356
service.afterTest({ fullName: 'foo xyz', description: 'xyz' } as any, undefined, { passed: true } as any)
348-
expect(setSessionNameSpy).toBeCalledWith('foo')
357+
expect(setSessionNameSpy).toBeCalledWith('foo xyz')
349358
})
350359
})
351360
})

0 commit comments

Comments
 (0)