test: Add a browser runner playgrounds with vue - #2178
Conversation
Greptile SummaryThe PR adds a Vue-based WebdriverIO browser-runner playground with component interaction and matcher coverage.
Confidence Score: 3/5The PR is not yet safe to merge because the browser-runner style test remains guaranteed to fail and the nested lockfile still misrepresents the package dependency graph. The test expects Tailwind-generated styling without loading Tailwind, while npm commands launched inside the new playground can consume a stale nested lockfile that omits the playground and its dependencies. Files Needing Attention: playgrounds/browser-runner/test/specs/vue.test.ts, playgrounds/browser-runner/package-lock.json
|
| Filename | Overview |
|---|---|
| playgrounds/browser-runner/test/specs/vue.test.ts | Adds Vue interaction and style assertions, but the Tailwind color assertion remains unsupported by the playground configuration. |
| playgrounds/browser-runner/package-lock.json | The nested lockfile remains stale and does not describe the browser-runner package or its dependencies. |
| playgrounds/package-lock.json | Updates the authoritative parent lockfile to include the browser-runner workspace and dependency graph. |
| playgrounds/browser-runner/wdio.conf.ts | Configures the WebdriverIO browser runner with the Vue preset and platform-specific browser capabilities. |
| playgrounds/browser-runner/components/Component.vue | Adds the counter component exercised by the browser-runner tests. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Test["vue.test.ts"] --> Render["Vue Testing Library / Vue Test Utils"]
Render --> Component["Component.vue"]
Test --> WDIO["WebdriverIO browser runner"]
WDIO --> Matchers["expect-webdriverio matchers"]
Reviews (2): Last reviewed commit: "Ensure to override all occurences of `ex..." | Re-trigger Greptile
| it('should support tailwindcss', async () => { | ||
| const { getByText } = render(Component) | ||
| const elem = await $(getByText('Times clicked: 0')) | ||
| await expect(elem).toHaveStyle({ color: 'rgba(217,119,6,1)' }) |
There was a problem hiding this comment.
Can you help set up that?
There was a problem hiding this comment.
Here's what needs to be added to make the Tailwind test pass. The wdio.conf.ts uses the browser runner's vue preset, which runs through Vite — so you just need to wire in Tailwind's Vite plugin and a CSS entry point.
1. Add the dependency to package.json:
| it('should support tailwindcss', async () => { | |
| const { getByText } = render(Component) | |
| const elem = await $(getByText('Times clicked: 0')) | |
| await expect(elem).toHaveStyle({ color: 'rgba(217,119,6,1)' }) | |
| "devDependencies": { | |
| "vite": "^5.4.21", | |
| "@testing-library/vue": "^8.1.0", | |
| "@vue/test-utils": "^2.4.11", | |
| "eslint-plugin-mocha": "^11.3.0", | |
| "@wdio/browser-runner": "^9.30.1", | |
| "@vitejs/plugin-vue": "^5.2.4", | |
| "expect": "^30.4.1", | |
| "tailwindcss": "^4.0.0", | |
| "@tailwindcss/vite": "^4.0.0" | |
| }, |
2. Create playgrounds/browser-runner/src/tailwind.css (or any path you prefer):
@import "tailwindcss";3. Update wdio.conf.ts to pass a custom Vite config that loads the plugin and the CSS:
import tailwindcss from '@tailwindcss/vite'
// inside the runner config:
runner: ['browser', {
preset: 'vue',
viteConfig: {
plugins: [tailwindcss()],
},
}],4. Import the CSS in your test file so Vite includes it in the bundle:
import '../src/tailwind.css' // add near the top of vue.test.tsThis is the Tailwind v4 approach (Vite plugin only, no postcss.config.js needed). If you want to stay on v3, swap to tailwindcss + autoprefixer in a postcss.config.js and use @tailwind base/components/utilities in the CSS file instead.
|
@greptileai, how can I override the dependencies of the browser-runner that spawns a node_module at runtime? |
|
The PR's approach is using npm // playgrounds/package.json
"overrides": {
"@wdio/browser-runner": {
"expect-webdriverio": "$expect-webdriverio"
}
}The For deeper Vite-level control (if the browser-runner's bundler resolves modules independently of npm), you can use the commented-out runner: ['browser', {
preset: 'vue',
viteConfig: {
resolve: {
alias: {
'expect-webdriverio': path.resolve(__dirname, '../../src/index.ts')
}
}
}
}],This forces Vite to use your local source directly, bypassing whatever The tricky part here (per the PR description) is that the browser-runner registers matchers using only the bare |
|
@greptileai, can you help fix the issue below? |
|
The 1. Create declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>
export default component
}2. Add the shim to The shim tells TypeScript how to type any |
Working with jest 30.3.0 Working version on expect `30.4.1` Skip clean if it fails
08ce71a to
6a7b420
Compare
The browser runner uses only the
expectlibrary when registering custom wdio matchers, which makes things tricky!Adding a playground to test this configuration