Skip to content

Commit

Permalink
(@wdio/browser-runner): move assertions to Node.js environment (#12005)
Browse files Browse the repository at this point in the history
* (@wdio/browser-runner): move assertions to Node.js environment

* partially rewrite messgae parsing between testrunner and worker

* parse mocha hooks safely

* fix command response

* resolve unit tests

* add more unit tests

* fix peer check

* move wdio deps to peer deps

* support chainablepromiselements in expect

* fix component tests

* maintain browser state

* add component tests for custom commands
  • Loading branch information
christian-bromann committed Jan 16, 2024
1 parent f4f924b commit 8f6766a
Show file tree
Hide file tree
Showing 72 changed files with 1,038 additions and 985 deletions.
4 changes: 4 additions & 0 deletions e2e/browser-runner/lit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ describe('Lit Component testing', () => {
.toBe('Buffer')
})

it('supports custom command registration in before hook', async () => {
expect(await browser.someCustomCommand()).toBe('Hello World')
})

describe('a11y selectors', () => {
it('aria label is received from element content', async () => {
// https://www.w3.org/TR/accname-1.1/#step2B
Expand Down
1 change: 1 addition & 0 deletions e2e/browser-runner/vue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('Vue Component Testing', () => {

getByText('Times clicked: 2')
await expect($('p=Times clicked: 2')).toExist()
await expect($('p=Times clicked: 123')).not.toExist()
})

it('should support tailwindcss', async () => {
Expand Down
11 changes: 11 additions & 0 deletions e2e/browser-runner/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,16 @@ export const config = {
ui: 'bdd',
timeout: 150000,
require: ['./__fixtures__/setup.js']
},

before: () => {
/**
* only run this test in lit
*/
if (process.env.WDIO_PRESET !== 'lit') {
return
}

browser.addCommand('someCustomCommand', () => 'Hello World')
}
}
2 changes: 1 addition & 1 deletion e2e/element.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeAll, beforeEach, afterAll, describe, it, expect } from 'vitest'
import DevTools from '../packages/devtools/build/index.js'
import { ELEMENT_KEY } from '../packages/devtools/build/constants.js'
import { ELEMENT_KEY } from '../packages/webdriver/build/constants.js'
import type { Client } from '../packages/devtools/build/index.js'

let browser: Client
Expand Down
2 changes: 1 addition & 1 deletion e2e/protocol.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeAll, afterAll, describe, it, expect, vi } from 'vitest'

import DevTools from '../packages/devtools/build/index.js'
import { ELEMENT_KEY } from '../packages/devtools/build/constants.js'
import { ELEMENT_KEY } from '../packages/webdriver/build/constants.js'

import type { Client } from '../packages/devtools/build/index.js'

Expand Down
2 changes: 1 addition & 1 deletion e2e/transitions.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeAll, afterAll, test, expect } from 'vitest'
import DevTools from '../packages/devtools/build/index.js'
import { ELEMENT_KEY } from '../packages/devtools/build/constants.js'
import { ELEMENT_KEY } from '../packages/webdriver/build/constants.js'
import type { Client } from '../packages/devtools/build/index.js'

let browser: Client
Expand Down
52 changes: 27 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 15 additions & 19 deletions packages/wdio-browser-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,9 @@
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@types/istanbul-lib-source-maps": "^4.0.1",
"@types/node": "^20.1.0",
"@vitest/spy": "^1.0.1",
"@wdio/globals": "8.27.2",
"@wdio/local-runner": "8.27.2",
"@wdio/logger": "8.24.12",
"@wdio/mocha-framework": "8.27.2",
"@wdio/protocols": "8.24.12",
"@wdio/types": "8.27.2",
"@wdio/utils": "8.27.2",
"ast-types": "^0.14.2",
"deepmerge-ts": "^5.0.0",
"expect-webdriverio": "^4.8.0",
"fast-safe-stringify": "^2.1.1",
"expect-webdriverio": "^4.8.1",
"get-port": "^7.0.0",
"import-meta-resolve": "^4.0.0",
"istanbul-lib-coverage": "^3.2.0",
Expand All @@ -55,23 +45,29 @@
"mlly": "^1.4.0",
"modern-node-polyfills": "^1.0.0",
"recast": "^0.23.2",
"serialize-error": "^11.0.0",
"safe-stringify": "^1.1.0",
"source-map-support": "^0.5.21",
"vite": "~4.5.0",
"vite-plugin-istanbul": "^5.0.0",
"vite-plugin-top-level-await": "^1.3.0",
"webdriver": "8.27.2",
"webdriverio": "8.27.2",
"ws": "^8.13.0"
"vite-plugin-top-level-await": "^1.3.0"
},
"scripts": {
"prepare": "rimraf node_modules/@wdio/config node_modules/@wdio/repl node_modules/@wdio/utils"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@types/ws": "^8.5.4",
"@wdio/runner": "8.27.2"
"peerDependencies": {
"@wdio/globals": "8.27.2",
"@wdio/local-runner": "8.27.2",
"@wdio/logger": "8.24.12",
"@wdio/mocha-framework": "8.27.2",
"@wdio/protocols": "8.24.12",
"@wdio/types": "8.27.2",
"@wdio/utils": "8.27.2",
"@wdio/runner": "8.27.2",
"expect": "^29.7.0",
"webdriver": "8.27.2",
"webdriverio": "8.27.2"
}
}
1 change: 1 addition & 0 deletions packages/wdio-browser-runner/src/@types/vite.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ declare module '@wdio/mocha-framework/common'
declare module 'virtual:wdio' {
export const commands: string[]
export const automationProtocolPath: string
export const matchers: string[]
}

0 comments on commit 8f6766a

Please sign in to comment.