Skip to content

Commit 5d608bc

Browse files
committed
Enable test with jasmine.stringContaining + fix typing tests
1 parent 55d420f commit 5d608bc

14 files changed

Lines changed: 223 additions & 526 deletions

jasmine.d.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,19 @@ declare namespace jasmine {
1212
* With Jasmine, only custom matchers are available under `expectAsync`, and not the one from Jest `expect` Library.
1313
*/
1414
// eslint-disable-next-line @typescript-eslint/no-unused-vars
15-
interface AsyncMatchers<T, U> extends ExpectWebdriverIO.CustomMatchers<Promise<void>, T> {}
15+
interface AsyncMatchers<T, U> extends ExpectWebdriverIO.CustomMatchers<Promise<void>, T> {
16+
17+
/**
18+
* snapshot matcher
19+
* @param label optional snapshot label
20+
*/
21+
toMatchSnapshot(label?: string): Promise<void>
22+
23+
/**
24+
* inline snapshot matcher
25+
* @param snapshot snapshot string (autogenerated if not specified)
26+
* @param label optional snapshot label
27+
*/
28+
toMatchInlineSnapshot(snapshot?: string, label?: string): Promise<void>
29+
}
1630
}

playgrounds/jasmine/test/specs/expectWdioImport/wdio-matchers.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,4 @@ describe('WebdriverIO Custom Matchers', () => {
177177
await expect(nonExistent).not.toExist()
178178
})
179179
})
180-
181-
describe('Wdio custom matcher with Jasmine asymmetric matchers', () => {
182-
it('should not work with jasmine.stringContaining', async () => {
183-
await browser.url('https://the-internet.herokuapp.com/login')
184-
185-
const username = await $('#username')
186-
await username.setValue('testuser123')
187-
188-
await expect(expect(username).toHaveValue(jasmine.stringContaining('testuser'))).rejects.toThrow()
189-
})
190-
})
191180
})

playgrounds/jasmine/test/specs/globalImport/jasmine-specific.test.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ describe('Jasmine-Specific Features', () => {
6464
await expect(searchButton).withContext('Search button should exist on the homepage').toExist()
6565
})
6666

67-
// TODO failing on jasmine.stringContaining not working properly with wdio matchers
68-
xit('should use asymmetric matchers in toHaveAttribute', async () => {
67+
it('should use asymmetric matchers in toHaveAttribute', async () => {
6968
const docsLink = await $('a[href="/docs/gettingstarted"]')
7069
await expect(docsLink).toHaveAttribute('href', jasmine.stringContaining('docs'))
7170
})
7271

73-
// TODO failing on jasmine.stringContaining not working properly with wdio matchers
74-
xit('should use asymmetric matchers in toHaveText', async () => {
72+
it('should use asymmetric matchers in toHaveText', async () => {
7573
const heading = await $$('h1')[1]
7674
await expect(heading).toHaveText(jasmine.stringContaining('Open'))
7775
})
@@ -91,8 +89,7 @@ describe('Jasmine-Specific Features', () => {
9189
})
9290

9391
describe('Array and collection validation', () => {
94-
// TODO asymmetric matchers are not working properly in this test
95-
xit('should validate collections with jasmine matchers', async () => {
92+
it('should validate collections with jasmine matchers', async () => {
9693
const navLinks = await $$('nav a')
9794
const count = navLinks.length
9895

@@ -117,19 +114,18 @@ describe('Jasmine-Specific Features', () => {
117114
})
118115
})
119116

120-
// failing on jasmine.stringContaining not working properly with wdio matchers
121117
describe('Browser state validation', () => {
122-
fit('should validate browser properties with asymmetric matchers', async () => {
118+
it('should validate browser properties with asymmetric matchers', async () => {
123119
const title = await browser.getTitle()
124120
const url = await browser.getUrl()
125121

126122
await expect(title).toEqual(jasmine.stringMatching(/WebdriverIO/i))
127123
await expect(url).toEqual(jasmine.stringContaining('webdriver.io'))
128124

129125
// Combined with WebdriverIO matchers
130-
// await expect(browser).toHaveUrl(jasmine.stringContaining('webdriver.io'))
131-
// await expect(browser).toHaveTitle(jasmine.stringContaining('WebdriverIO'))
132-
// await expect(browser).toHaveUrl(jasmine.stringContaining('WEBDRIVER.io'),{ignoreCase: true})
126+
await expect(browser).toHaveUrl(jasmine.stringContaining('webdriver.io'))
127+
await expect(browser).toHaveTitle(jasmine.stringContaining('WebdriverIO'))
128+
await expect(browser).toHaveUrl(jasmine.stringContaining('WEBDRIVER.io'),{ignoreCase: true})
133129
await expect(browser).toHaveTitle(jasmine.stringContaining('WEBDRIVERIO'), {ignoreCase: true})
134130
})
135131
})
@@ -148,8 +144,7 @@ describe('Jasmine-Specific Features', () => {
148144
await expect(size.height).toBeGreaterThan(0)
149145
})
150146

151-
// TODO failing with Error: Can't call getText on element with selector ".non-existent-element-xyz" because element wasn't found
152-
xit('should validate element attributes', async () => {
147+
it('should validate element attributes', async () => {
153148
const searchButton = await $('.DocSearch-Button')
154149
const classList = await searchButton.getAttribute('class')
155150

@@ -181,7 +176,7 @@ describe('Jasmine-Specific Features', () => {
181176
})
182177

183178
describe('Jasmine core matcher use cases with expect', () => {
184-
fit('should use all core Jasmine matchers with expect', async () => {
179+
it('should use all core Jasmine matchers with expect', async () => {
185180
const title = await browser.getTitle()
186181
const navLinks = await $$('nav a')
187182
const count = navLinks.length

playgrounds/jasmine/wdio.conf.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export const config: WebdriverIO.Config = {
1515
// ==================
1616
//
1717
specs: [
18-
'./test/specs/**/*.test.ts'
19-
// './test/specs/**/jasmine-specific.test.ts',
18+
'./test/specs/**/*.test.ts',
2019
// './test/specs/expectWdioImport/basic-matchers.test.ts',
2120
// './test/specs/expectWdioImport/wdio-matchers.test.ts'
22-
'./test/specs/globalImport/jasmine-specific.test.ts',
21+
// './test/specs/globalImport/jasmine-specific.test.ts',
22+
//'./test/specs/globalImport/snapshot.test.ts',
2323
],
2424

2525
//

test-types/jasmine-async/customMatchers/customMatchers-module-expect.d.ts renamed to test-types/jasmine-global-expect-async/customMatchers/customMatchers-module-expect.d.ts

File renamed without changes.

test-types/jasmine-async/customMatchers/customMatchers-namespace-expectwebdriverio.d.ts renamed to test-types/jasmine-global-expect-async/customMatchers/customMatchers-namespace-expectwebdriverio.d.ts

File renamed without changes.
File renamed without changes.

test-types/jasmine-async/types-jasmine_async.test.ts renamed to test-types/jasmine-global-expect-async/types-jasmine_async.test.ts

File renamed without changes.

test-types/jasmine/customMatchers/customMatchers-module-expect.d.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

test-types/jasmine/customMatchers/customMatchers-namespace-expectwebdriverio.d.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)