Skip to content

Commit f93f680

Browse files
authored
Improve accessibility of playwright fixture documentation (#34087)
* Improve accessibility of playwright fixture documentation Empirically. by pulling the type definitions for the playwright fixtures out to a type alias, we get better documentation for those fixtures. * Exclude playwright-common from coverage checks
1 parent f354453 commit f93f680

5 files changed

Lines changed: 16 additions & 18 deletions

File tree

packages/playwright-common/src/fixtures/axe.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ Please see LICENSE files in the repository root for full details.
99
import { test as base } from "@playwright/test";
1010
import { AxeBuilder } from "@axe-core/playwright";
1111

12-
// This fixture is useful for simple component library tests that won't want any extra services like a homeserver, so we
13-
// explicitly avoid pulling anything more than playwright's base fixtures in.
14-
export const test = base.extend<{
12+
export type TestFixtures = {
1513
/**
1614
* AxeBuilder instance for the current page
1715
*/
1816
axe: AxeBuilder;
19-
}>({
17+
};
18+
19+
// This fixture is useful for simple component library tests that won't want any extra services like a homeserver, so we
20+
// explicitly avoid pulling anything more than playwright's base fixtures in.
21+
export const test = base.extend<TestFixtures>({
2022
axe: async ({ page }, use) => {
2123
const builder = new AxeBuilder({ page });
2224
await use(builder);

packages/playwright-common/src/fixtures/panel.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { test as base } from "./services.js";
1414
*/
1515
const LEFT_PANEL_WIDTH = "368.6875px";
1616

17-
export const test = base.extend<{
17+
export type TestFixtures = {
1818
/**
1919
* Whether the left panel should have its width fixed.
2020
* This is done because the library that we use for rendering collapsible
@@ -25,7 +25,9 @@ export const test = base.extend<{
2525
* behaviour.
2626
*/
2727
lockLeftPanelWidth: boolean;
28-
}>({
28+
};
29+
30+
export const test = base.extend<TestFixtures>({
2931
lockLeftPanelWidth: true,
3032
page: async ({ lockLeftPanelWidth, page }, use) => {
3133
const listener = async (page: Page) => {

packages/playwright-common/src/fixtures/user.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function populateLocalStorageWithCredentials(page: Page, credential
4141
);
4242
}
4343

44-
export const test = base.extend<{
44+
export interface TestFixtures {
4545
/**
4646
* The displayname to use for the user registered in {@link #credentials}.
4747
*
@@ -71,7 +71,9 @@ export const test = base.extend<{
7171
* app.
7272
*/
7373
user: Credentials;
74-
}>({
74+
}
75+
76+
export const test = base.extend<TestFixtures>({
7577
displayName: undefined,
7678

7779
// We don't directly depend upon the `context` fixture, but we do need to make sure that it has been run

packages/playwright-common/src/index.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,6 @@ export interface TestFixtures {
6868

6969
labsFlags: string[];
7070
disablePresence: boolean;
71-
/**
72-
* Whether the left panel should have its width fixed.
73-
* This is done because the library that we use for rendering collapsible
74-
* panels uses math to calculate the width which can sometimes leads to +/-1px
75-
* difference. While this does not matter to the user, it can lead to screenshot
76-
* tests failing.
77-
* Defaults to true, should be set to false via {@link base.use} when you want to test the collapse
78-
* behaviour.
79-
*/
80-
lockLeftPanelWidth: boolean;
8171
}
8272

8373
export const test = base.extend<TestFixtures>({

vitest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export default defineConfig({
6060
"**/src/test/**",
6161
// Exclude type definition files
6262
"**/*.d.ts",
63+
// Exclude playwright-common as it is just test utilities
64+
"packages/playwright-common/**",
6365
],
6466
reporter: [["lcov"]],
6567
},

0 commit comments

Comments
 (0)