Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(expect): do not rely on displayName (#9523)
Dmitry Gozmanc711fb35addb
diff --git a/installation-tests/failing.spec.js b/installation-tests/failing.spec.jsnew file mode 100644index 0000000000..a2d60d0787--- /dev/null+++ b/installation-tests/failing.spec.js@@ -0,0 +1,6 @@+const { test, expect } = require('@playwright/test');++test('failing test', async ({ page }) => {+ await page.setContent(`<div>hello</div><span>world</span>`);+ await expect(page.locator('span')).toHaveText('hello', { timeout: 1000 });+});diff --git a/installation-tests/installation-tests.sh b/installation-tests/installation-tests.shindex 4b78391fb9..08ab248437 100755--- a/installation-tests/installation-tests.sh+++ b/installation-tests/installation-tests.sh@@ -52,6 +52,7 @@ function copy_test_scripts {cp "${SCRIPTS_PATH}/electron-app.js" .cp "${SCRIPTS_PATH}/driver-client.js" .cp "${SCRIPTS_PATH}/sample.spec.js" .+ cp "${SCRIPTS_PATH}/failing.spec.js" .cp "${SCRIPTS_PATH}/read-json-report.js" .cp "${SCRIPTS_PATH}/playwright-test-types.ts" .}@@ -80,6 +81,7 @@ function run_tests {test_playwright_chromium_should_worktest_playwright_webkit_should_worktest_playwright_firefox_should_work+ test_playwright_test_stacks_should_work}function test_screencast {@@ -606,7 +608,7 @@ function test_playwright_test_should_work {PLAYWRIGHT_BROWSERS_PATH="0" npx playwright installecho "Running playwright test"- PLAYWRIGHT_JSON_OUTPUT_NAME=report.json PLAYWRIGHT_BROWSERS_PATH="0" npx playwright test -c . --browser=all --reporter=list,json+ PLAYWRIGHT_JSON_OUTPUT_NAME=report.json PLAYWRIGHT_BROWSERS_PATH="0" npx playwright test -c . --browser=all --reporter=list,json sample.spec.jsecho "Checking the report"node ./read-json-report.js ./report.json@@ -621,6 +623,28 @@ function test_playwright_test_should_work {echo "${FUNCNAME[0]} success"}+function test_playwright_test_stacks_should_work {+ initialize_test "${FUNCNAME[0]}"++ npm install ${PLAYWRIGHT_CORE_TGZ}+ npm install ${PLAYWRIGHT_TEST_TGZ}+ PLAYWRIGHT_BROWSERS_PATH="0" npx playwright install chromium+ copy_test_scripts++ echo "Running playwright test"+ OUTPUT=$(DEBUG=pw:api npx playwright test -c . failing.spec.js || true)+ if [[ "${OUTPUT}" != *"expect.toHaveText started"* ]]; then+ echo "ERROR: missing 'expect.toHaveText started' in the output"+ exit 1+ fi+ if [[ "${OUTPUT}" != *"failing.spec.js:5:38"* ]]; then+ echo "ERROR: missing 'failing.spec.js:5:38' in the output"+ exit 1+ fi++ echo "${FUNCNAME[0]} success"+}+function initialize_test {cd ${TEST_ROOT}local TEST_NAME="./$1"diff --git a/packages/playwright-test/src/expect.ts b/packages/playwright-test/src/expect.tsindex 68990447ce..b6bc304035 100644--- a/packages/playwright-test/src/expect.ts+++ b/packages/playwright-test/src/expect.ts@@ -156,7 +156,7 @@ function wrap(matcherName: string, matcher: any) {reportStepError(e);}};- result.displayName = '__PWTRAP__[expect.' + matcherName + ']';+ Object.defineProperty(result, 'name', { value: '__PWTRAP__[expect.' + matcherName + ']' });return result;}