Skip to content

Commit a3a3544

Browse files
chore: add tests for using commands in sync mode
1 parent a9d17b0 commit a3a3544

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

test/sync.e2e.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Test sync behaviour in a js file so that typescript doesn't complain about the
3+
async commands being declared elsewhere
4+
*/
5+
6+
const sync = require('@wdio/sync').default
7+
8+
const {setupBrowser} = require('../src')
9+
10+
describe('sync mode', () => {
11+
it('can be used with browser commands', async () => {
12+
setupBrowser(browser)
13+
14+
await sync(() => {
15+
const pageHeading = browser.getByText('Page Heading')
16+
17+
expect(pageHeading).toBeDefined()
18+
expect(pageHeading.getText()).toEqual('Page Heading')
19+
})
20+
})
21+
22+
it('can be used with element commands', async () => {
23+
setupBrowser(browser)
24+
25+
await sync(() => {
26+
const button = browser
27+
.$('*[data-testid="nested"]')
28+
.getByText('Button Text')
29+
30+
button.click()
31+
32+
expect(button.getText()).toEqual('Button Clicked')
33+
})
34+
})
35+
})

wdio.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exports.config = {
1818
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
1919
// directory is where your package.json resides, so `wdio` will be called from there.
2020
//
21-
specs: ['./test/**/*.e2e.ts'],
21+
specs: ['./test/**/*.e2e.{js,ts}'],
2222
// Patterns to exclude.
2323
exclude: [
2424
// 'path/to/excluded/files'

0 commit comments

Comments
 (0)