Skip to content

Part5d(en): Fix Playwright describe and beforeEach examples#4294

Open
Okamissu wants to merge 1 commit into
fullstack-hy2020:sourcefrom
Okamissu:patch-2
Open

Part5d(en): Fix Playwright describe and beforeEach examples#4294
Okamissu wants to merge 1 commit into
fullstack-hy2020:sourcefrom
Okamissu:patch-2

Conversation

@Okamissu
Copy link
Copy Markdown
Contributor

@Okamissu Okamissu commented Jun 4, 2026

What changed

This PR updates the Playwright examples to use Playwright Test helpers through the test object:

  • test.describe(...)
  • test.beforeEach(...)

The examples now import only test and expect from @playwright/test.

Why

The current examples destructure helpers like describe and beforeEach directly from @playwright/test, for example:

const { test, describe, expect } = require('@playwright/test')

and:

const { test, expect, beforeEach } = require('@playwright/test')

However, the Playwright docs document these APIs as methods on the test object:

The docs also show examples importing test and expect from @playwright/test, then calling test.describe(...) and test.beforeEach(...).

Using the documented form makes the examples clearer and avoids confusion for learners who will run into describe or beforeEach being undefined.

Example

Before:

const { test, describe, expect } = require('@playwright/test')

describe('Note app', () => {
  test('front page can be opened', async ({ page }) => {
    // ...
  })
})

After:

const { test, expect } = require('@playwright/test')

test.describe('Note app', () => {
  test('front page can be opened', async ({ page }) => {
    // ...
  })
})

Before:

const { test, expect, beforeEach } = require('@playwright/test')

beforeEach(async ({ page }) => {
  await page.goto('http://localhost:5173')
})

After:

const { test, expect } = require('@playwright/test')

test.beforeEach(async ({ page }) => {
  await page.goto('http://localhost:5173')
})

Scope

This PR only updates Playwright API usage in the course material. It does not change the test logic, exercise requirements, or expected application output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant