-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Open
Description
## 🚀 Feature Request
The VS Code Playwright extension does not work when `test` and `expect` are imported from a custom package that wraps `@playwright/test` with extended fixtures.
## Current Behavior
When running tests via the VS Code extension that import from a custom fixtures package:
```typescript
// my-test.spec.ts
import { test, expect } from '@my-company/e2e-test' // custom package
test.describe('My tests', () => {
test('example', async ({ page, customFixture }) => {
// ...
})
})The extension throws:
Error: Playwright Test did not expect test.describe() to be called here.
Most common reasons include:
- You have two different versions of @playwright/test.
Expected Behavior
The VS Code extension should recognize and work with test objects that are extended via test.extend() and re-exported from third-party packages.
Root Cause Analysis
The issue occurs because:
- The VS Code extension loads its own instance of
@playwright/test - The test file imports
testfrom a custom package (e.g.,@my-company/e2e-test) - The custom package internally imports from
@playwright/test(potentially a different module instance due to Node.js module resolution) - Playwright detects two different instances and throws an error
Reproduction Steps
- Create a custom fixtures package:
// packages/e2e-test/src/fixtures.ts
import { test as base } from '@playwright/test'
export const test = base.extend({
customFixture: async ({ page }, use) => {
// custom setup
await use(new CustomHelper(page))
},
})
export { expect } from '@playwright/test'- Create a test file using the custom package:
// tests/example.spec.ts
import { test, expect } from '@my-company/e2e-test'
test.describe('Example', () => {
test('works', async ({ page, customFixture }) => {
await page.goto('/')
})
})- Run tests via CLI: ✅ Works perfectly
- Run tests via VS Code extension: ❌ Throws error
Workarounds
Currently, we have to:
- Use CLI (
npx playwright test) or F5 debugging instead of the extension - Or abandon custom fixtures entirely and import directly from
@playwright/test
Environment
- VS Code: 1.95.x
- Playwright: 1.48.x
- Playwright VS Code Extension: 1.1.x
- OS: Windows 11
- Package Manager: pnpm (monorepo)
Motivation
Many teams create shared test utilities with custom fixtures for:
- Common page object models
- Shared authentication flows
- Domain-specific helpers
- AI-powered testing tools (e.g., Midscene)
The current limitation forces teams to choose between:
- Using the excellent VS Code extension features (run/debug individual tests, pick locators, etc.)
- Using custom fixtures for better code reuse
andreiancas22
Metadata
Metadata
Assignees
Labels
No labels