playwright-clipboard-testing 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sergii Oleksenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine/)
2
+
3
+ # Playwright Clipboard Testing
4
+
5
+ Custom Playwright fixture and matchers for testing clipboard functionality in your web applications.
6
+
7
+ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg?style=flat&color=blue)](LICENSE)
8
+
9
+ ## Table of Contents
10
+ - [Installation](#installation)
11
+ - [Browser Support](#browser-support)
12
+ - [Usage](#usage)
13
+ - [Direct Usage](#direct-usage)
14
+ - [Extended Usage](#extended-usage)
15
+ - [API](#api)
16
+ - [Clipboard Fixture](#clipboard-fixture)
17
+ - [toHaveData Matcher](#tohavedata-matcher)
18
+ - [Author](#author)
19
+ - [License](#license)
20
+
21
+ ## Installation
22
+ Install as one of your dev dependencies:
23
+ ```bash
24
+ npm install --save-dev playwright-clipboard-testing
25
+ ```
26
+
27
+ ## Browser Support
28
+ ![NOTE](https://img.shields.io/badge/NOTE-Only%20supported%20in%20Chromium%20browsers-yellow)
29
+
30
+ The Web Clipboard Permissions API is currently only supported in Chromium-based browsers.
31
+ If your Playwright setup runs tests across multiple browsers, skip non-Chromium runs in tests that use the clipboard:
32
+ ```ts
33
+ test('should copy text to clipboard', async ({ page, clipboard, browserName }) => {
34
+ test.skip(browserName !== 'chromium', 'Clipboard API is only supported in Chromium');
35
+
36
+ // test logic...
37
+ });
38
+ ```
39
+
40
+ ## Usage
41
+ ### Direct Usage
42
+
43
+ Import `test` and `expect` directly from the package:
44
+ ```ts
45
+ import { test, expect } from 'playwright-clipboard-testing';
46
+
47
+ test('should copy text to clipboard', async ({ page, clipboard }) => {
48
+ await page.goto('https://example.com');
49
+ await page.click('#copy-button');
50
+
51
+ await expect(clipboard).toHaveData('Hello, World!');
52
+ });
53
+ ```
54
+
55
+ ### Extended Usage
56
+
57
+ If you already have a custom test fixture file, extend Playwright's `test` and `expect` with `clipboardFixture` and `clipboardMatchers`:
58
+ ```ts
59
+ import { expect as baseExpect, test as baseTest } from '@playwright/test';
60
+ import { type ClipboardHandler, clipboardFixture, clipboardMatchers } from 'playwright-clipboard-testing';
61
+
62
+ export const test = baseTest.extend<{ clipboard: ClipboardHandler }>({
63
+ clipboard: clipboardFixture,
64
+ });
65
+
66
+ export const expect = baseExpect.extend(clipboardMatchers);
67
+ ```
68
+
69
+ ## API
70
+ ### Clipboard Fixture
71
+ The `clipboard` fixture provides direct access to the browser clipboard during tests:
72
+ - `clipboard.read(): Promise<string>` - reads the current plain text content from the clipboard.
73
+ - `clipboard.readJSON<T>(): Promise<T>` - reads the current clipboard content and parses it as a JSON object of type `T`. Throws an error if the content is not valid JSON.
74
+
75
+ ![NOTE](https://img.shields.io/badge/NOTE-For%20your%20tests%20we%20recommend%20using%20the%20toHaveData%20matcher-yellow)
76
+
77
+ ### toHaveData Matcher
78
+ `expect(clipboard).toHaveData(expected, options?)`
79
+
80
+ Asserts that the clipboard content matches the expected string or JSON object. Uses Playwright's smart polling mechanism to wait for the clipboard to update.
81
+ - `expected: unknown` — Expected text or object to compare against.
82
+ - `options.timeout: number (optional, default: 10000ms)` — Time in milliseconds to wait for the clipboard data to match.
83
+ ```ts
84
+ // assert that the clipboard contains the expected text
85
+ await expect(clipboard).toHaveData('Hello, World!');
86
+ ```
87
+ ```ts
88
+ // assert that the clipboard contains the expected JSON data
89
+ await expect(clipboard).toHaveData({ message: 'Hello, World!' });
90
+ ```
91
+ ```ts
92
+ // Custom timeout
93
+ await expect(clipboard).toHaveData('Async copied value', { timeout: 5000 });
94
+ ```
95
+
96
+ ## Author
97
+ Sergii Oleksenko <serg.oleksenko@gmail.com>
98
+
99
+ ## License
100
+ [MIT](LICENSE)
package/dist/index.cjs ADDED
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ ClipboardHandler: () => ClipboardHandler,
24
+ clipboardFixture: () => clipboardFixture,
25
+ clipboardMatchers: () => clipboardMatchers,
26
+ expect: () => expect2,
27
+ test: () => test
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/utils/clipboardHandler.ts
32
+ var ClipboardHandler = class {
33
+ constructor(page, context) {
34
+ this.page = page;
35
+ this.context = context;
36
+ this.isPermissionGranted = false;
37
+ }
38
+ page;
39
+ context;
40
+ isPermissionGranted;
41
+ /**
42
+ * Grants the necessary clipboard permissions ('clipboard-read' and 'clipboard-write') to the browser context.
43
+ * This method is called internally before any clipboard read operation to ensure permissions are set.
44
+ * @private
45
+ */
46
+ async grantPermissions() {
47
+ if (!this.isPermissionGranted) {
48
+ await this.context.grantPermissions(["clipboard-read", "clipboard-write"]);
49
+ this.isPermissionGranted = true;
50
+ }
51
+ }
52
+ /**
53
+ * Reads the current text content from the browser clipboard.
54
+ * If the content is a JSON-encoded string (e.g., has extra quotes),
55
+ * it will be returned as is. Use readJSON for automatic parsing.
56
+ *
57
+ * @returns A promise that resolves to the clipboard string content.
58
+ */
59
+ async read() {
60
+ await this.grantPermissions();
61
+ return await this.page.evaluate(() => navigator.clipboard.readText());
62
+ }
63
+ /**
64
+ * Reads the clipboard content and parses it as JSON.
65
+ * If the content is a string literal (e.g., '"value"'), it returns the unwrapped string ('value').
66
+ *
67
+ * @template T - The expected type of the parsed JSON object.
68
+ * @returns A promise that resolves to the parsed JSON object of type T.
69
+ * @throws {Error} If the clipboard content is not a valid JSON string.
70
+ */
71
+ async readJSON() {
72
+ const text = await this.read();
73
+ try {
74
+ return JSON.parse(text);
75
+ } catch {
76
+ throw new Error(`Clipboard content is not a valid JSON: ${JSON.stringify(text)}`);
77
+ }
78
+ }
79
+ };
80
+
81
+ // src/fixtures/clipboardFixture.ts
82
+ var clipboardFixture = async ({ page, context, browserName }, use) => {
83
+ if (browserName !== "chromium") {
84
+ throw new Error(
85
+ `[playwright-clipboard] Browser '${browserName}' is not supported. Clipboard Permissions API is currently only supported in Chromium-based browsers.
86
+ Use test.skip(browserName !== 'chromium') in your tests to skip non-Chromium runs.`
87
+ );
88
+ }
89
+ const handler = new ClipboardHandler(page, context);
90
+ await use(handler);
91
+ };
92
+
93
+ // src/fixtures.ts
94
+ var import_test2 = require("@playwright/test");
95
+
96
+ // src/matchers/toHaveData.ts
97
+ var import_test = require("@playwright/test");
98
+
99
+ // src/utils/matcherUtils.ts
100
+ function getErrorMessage(name, expected, actual, error, errorMessage) {
101
+ const message = `${this.utils.matcherHint(name, void 0, void 0, { isNot: this.isNot })}
102
+
103
+ `;
104
+ if (error) {
105
+ return () => `${message}An unexpected error occurred:
106
+ ${error.message}`;
107
+ }
108
+ if (errorMessage) {
109
+ return () => `${message}${errorMessage}`;
110
+ }
111
+ return () => message + `Expected: ${this.isNot ? "not " : ""}${this.utils.printExpected(expected)}
112
+ Received: ${this.utils.printReceived(actual)}`;
113
+ }
114
+
115
+ // src/matchers/toHaveData.ts
116
+ async function toHaveData(clipboard, expected, options = {}) {
117
+ const name = "toHaveData";
118
+ let pass;
119
+ let actual;
120
+ const { timeout = 1e4 } = options;
121
+ const poll = import_test.expect.poll(
122
+ async () => {
123
+ try {
124
+ actual = await clipboard.readJSON();
125
+ } catch {
126
+ actual = await clipboard.read();
127
+ }
128
+ if (typeof expected === "string" && actual !== null && actual !== void 0) {
129
+ return String(actual);
130
+ }
131
+ return actual;
132
+ },
133
+ { timeout }
134
+ );
135
+ try {
136
+ const expectation = this.isNot ? poll.not : poll;
137
+ await expectation.toEqual(expected);
138
+ pass = true;
139
+ } catch {
140
+ pass = false;
141
+ }
142
+ if (this.isNot) pass = !pass;
143
+ const matcherReturn = {
144
+ message: getErrorMessage.call(this, name, expected, actual),
145
+ pass,
146
+ name,
147
+ expected,
148
+ actual
149
+ };
150
+ return matcherReturn;
151
+ }
152
+
153
+ // src/matchers/clipboardMatchers.ts
154
+ var clipboardMatchers = {
155
+ toHaveData
156
+ };
157
+
158
+ // src/fixtures.ts
159
+ var test = import_test2.test.extend({
160
+ /**
161
+ * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
162
+ * It allows reading from the clipboard during tests.
163
+ */
164
+ clipboard: clipboardFixture
165
+ });
166
+ var expect2 = import_test2.expect.extend({ ...clipboardMatchers });
167
+ // Annotate the CommonJS export names for ESM import in node:
168
+ 0 && (module.exports = {
169
+ ClipboardHandler,
170
+ clipboardFixture,
171
+ clipboardMatchers,
172
+ expect,
173
+ test
174
+ });
175
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/clipboardHandler.ts","../src/fixtures/clipboardFixture.ts","../src/fixtures.ts","../src/matchers/toHaveData.ts","../src/utils/matcherUtils.ts","../src/matchers/clipboardMatchers.ts"],"sourcesContent":["export { clipboardFixture } from './fixtures/clipboardFixture.js';\nexport { expect, test } from './fixtures.js';\nexport { clipboardMatchers } from './matchers/clipboardMatchers.js';\nexport { ClipboardHandler } from './utils/clipboardHandler.js';\n","/**\n * Playwright-compatible Clipboard utilities.\n *\n * Core functions for interacting with the browser clipboard within Playwright tests.\n * Provides wrappers for reading plain text and JSON.\n *\n * @remarks\n * These utilities require 'clipboard-read' and 'clipboard-write' permissions\n * to be granted in the browser context.\n */\n\nimport type { BrowserContext, Page } from '@playwright/test';\n\nexport class ClipboardHandler {\n private isPermissionGranted: boolean;\n\n constructor(\n private readonly page: Page,\n private readonly context: BrowserContext,\n ) {\n this.isPermissionGranted = false;\n }\n\n /**\n * Grants the necessary clipboard permissions ('clipboard-read' and 'clipboard-write') to the browser context.\n * This method is called internally before any clipboard read operation to ensure permissions are set.\n * @private\n */\n private async grantPermissions() {\n if (!this.isPermissionGranted) {\n await this.context.grantPermissions(['clipboard-read', 'clipboard-write']);\n this.isPermissionGranted = true;\n }\n }\n\n /**\n * Reads the current text content from the browser clipboard.\n * If the content is a JSON-encoded string (e.g., has extra quotes),\n * it will be returned as is. Use readJSON for automatic parsing.\n *\n * @returns A promise that resolves to the clipboard string content.\n */\n async read(): Promise<string> {\n await this.grantPermissions();\n return await this.page.evaluate(() => navigator.clipboard.readText());\n }\n\n /**\n * Reads the clipboard content and parses it as JSON.\n * If the content is a string literal (e.g., '\"value\"'), it returns the unwrapped string ('value').\n *\n * @template T - The expected type of the parsed JSON object.\n * @returns A promise that resolves to the parsed JSON object of type T.\n * @throws {Error} If the clipboard content is not a valid JSON string.\n */\n async readJSON<T = unknown>(): Promise<T> {\n const text = await this.read();\n try {\n return JSON.parse(text);\n } catch {\n throw new Error(`Clipboard content is not a valid JSON: ${JSON.stringify(text)}`);\n }\n }\n}\n","import type { BrowserContext, Page, TestFixture } from '@playwright/test';\nimport { ClipboardHandler } from '../utils/clipboardHandler.js';\n\n/**\n * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.\n * It allows reading from the clipboard during tests.\n */\nexport const clipboardFixture: TestFixture<\n ClipboardHandler,\n { page: Page; context: BrowserContext; browserName: string }\n> = async ({ page, context, browserName }, use) => {\n if (browserName !== 'chromium') {\n throw new Error(\n `[playwright-clipboard] Browser '${browserName}' is not supported. ` +\n 'Clipboard Permissions API is currently only supported in Chromium-based browsers.\\n' +\n `Use test.skip(browserName !== 'chromium') in your tests to skip non-Chromium runs.`,\n );\n }\n\n const handler = new ClipboardHandler(page, context);\n await use(handler);\n};\n","import { expect as baseExpect, test as baseTest } from '@playwright/test';\nimport { clipboardFixture } from './fixtures/clipboardFixture.js';\nimport { clipboardMatchers } from './matchers/clipboardMatchers.js';\nimport type { ClipboardHandler } from './utils/clipboardHandler.js';\n\nexport const test = baseTest.extend<{\n clipboard: ClipboardHandler;\n}>({\n /**\n * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.\n * It allows reading from the clipboard during tests.\n */\n clipboard: clipboardFixture,\n});\n\nexport const expect = baseExpect.extend({ ...clipboardMatchers });\n","import { type ExpectMatcherState, expect, type MatcherReturnType } from '@playwright/test';\nimport type { ClipboardHandler } from '../utils/clipboardHandler.js';\nimport { getErrorMessage } from '../utils/matcherUtils.js';\nimport type { MatcherOptions } from './types.js';\n\n/**\n * Asserts that the clipboard content matches the expected value.\n * Uses smart polling to wait for the clipboard to be updated.\n * If the `expected` value is an object, it attempts to parse the clipboard\n * content as JSON before comparing.\n *\n * @this ExpectMatcherState\n * @param clipboard The Clipboard utility instance.\n * @param expected The string or object to compare against the clipboard content.\n * @param options Optional settings for the matcher, such as timeout.\n * @returns A Promise that resolves to a MatcherReturnType object.\n */\nexport async function toHaveData(\n this: ExpectMatcherState,\n clipboard: ClipboardHandler,\n expected: unknown,\n options: MatcherOptions = {},\n) {\n const name = 'toHaveData';\n let pass: boolean;\n let actual: unknown;\n\n const { timeout = 10_000 } = options;\n\n const poll = expect.poll(\n async () => {\n try {\n actual = await clipboard.readJSON();\n } catch {\n actual = await clipboard.read();\n }\n\n if (typeof expected === 'string' && actual !== null && actual !== undefined) {\n return String(actual);\n }\n\n return actual;\n },\n { timeout },\n );\n\n try {\n const expectation = this.isNot ? poll.not : poll;\n await expectation.toEqual(expected);\n pass = true;\n } catch {\n pass = false;\n }\n\n /**\n * NOTE ON INVERSION:\n * In Playwright custom matchers, if `this.isNot` is true, the matcher must return\n * `pass: false` for the assertion to pass. Since `poll.not.toEqual` resolves\n * to `true` when the condition is met, we invert it back to align with Playwright's expectations.\n */\n if (this.isNot) pass = !pass;\n\n const matcherReturn: MatcherReturnType = {\n message: getErrorMessage.call(this, name, expected, actual),\n pass,\n name,\n expected,\n actual,\n };\n\n return matcherReturn;\n}\n","import type { ExpectMatcherState } from '@playwright/test';\n\n/**\n * Generates an error message for a custom matcher.\n *\n * @this ExpectMatcherState\n * @param name The name of the matcher.\n * @param expected The expected value.\n * @param actual The actual value.\n * @param error An optional error object.\n * @param errorMessage An optional error message string.\n * @returns A function that returns the error message string.\n */\nexport function getErrorMessage(\n this: ExpectMatcherState,\n name: string,\n expected: unknown,\n actual: unknown,\n error?: Error | null,\n errorMessage?: string | undefined | null,\n): () => string {\n const message = `${this.utils.matcherHint(name, undefined, undefined, { isNot: this.isNot })}\\n\\n`;\n\n if (error) {\n return () => `${message}An unexpected error occurred:\\n${error.message}`;\n }\n\n if (errorMessage) {\n return () => `${message}${errorMessage}`;\n }\n\n return () =>\n message +\n `Expected: ${this.isNot ? 'not ' : ''}${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(actual)}`;\n}\n","import { toHaveData } from './toHaveData.js';\n\n/**\n * Export an object containing all the custom clipboard matchers for Playwright.\n */\nexport const clipboardMatchers = {\n toHaveData,\n};\n"],"mappings":"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","names":["expect","import_test","baseTest","expect","baseExpect"]}
@@ -0,0 +1,108 @@
1
+ import * as _playwright_test from '@playwright/test';
2
+ import { Page, BrowserContext, TestFixture, ExpectMatcherState, MatcherReturnType } from '@playwright/test';
3
+
4
+ /**
5
+ * Playwright-compatible Clipboard utilities.
6
+ *
7
+ * Core functions for interacting with the browser clipboard within Playwright tests.
8
+ * Provides wrappers for reading plain text and JSON.
9
+ *
10
+ * @remarks
11
+ * These utilities require 'clipboard-read' and 'clipboard-write' permissions
12
+ * to be granted in the browser context.
13
+ */
14
+
15
+ declare class ClipboardHandler {
16
+ private readonly page;
17
+ private readonly context;
18
+ private isPermissionGranted;
19
+ constructor(page: Page, context: BrowserContext);
20
+ /**
21
+ * Grants the necessary clipboard permissions ('clipboard-read' and 'clipboard-write') to the browser context.
22
+ * This method is called internally before any clipboard read operation to ensure permissions are set.
23
+ * @private
24
+ */
25
+ private grantPermissions;
26
+ /**
27
+ * Reads the current text content from the browser clipboard.
28
+ * If the content is a JSON-encoded string (e.g., has extra quotes),
29
+ * it will be returned as is. Use readJSON for automatic parsing.
30
+ *
31
+ * @returns A promise that resolves to the clipboard string content.
32
+ */
33
+ read(): Promise<string>;
34
+ /**
35
+ * Reads the clipboard content and parses it as JSON.
36
+ * If the content is a string literal (e.g., '"value"'), it returns the unwrapped string ('value').
37
+ *
38
+ * @template T - The expected type of the parsed JSON object.
39
+ * @returns A promise that resolves to the parsed JSON object of type T.
40
+ * @throws {Error} If the clipboard content is not a valid JSON string.
41
+ */
42
+ readJSON<T = unknown>(): Promise<T>;
43
+ }
44
+
45
+ /**
46
+ * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
47
+ * It allows reading from the clipboard during tests.
48
+ */
49
+ declare const clipboardFixture: TestFixture<ClipboardHandler, {
50
+ page: Page;
51
+ context: BrowserContext;
52
+ browserName: string;
53
+ }>;
54
+
55
+ type MatcherOptions = {
56
+ timeout?: number;
57
+ };
58
+ declare global {
59
+ namespace PlaywrightTest {
60
+ interface Matchers<R> {
61
+ /**
62
+ * Asserts that the clipboard content matches the expected value.
63
+ * Uses smart polling to wait for the clipboard to be updated.
64
+ * If the `expected` value is an object, it attempts to parse the clipboard
65
+ * content as JSON before comparing.
66
+ *
67
+ * @param expected The string or object to compare against the clipboard content.
68
+ * @param options Optional settings for the matcher, such as timeout.
69
+ * @returns A Promise that resolves when the assertion completes.
70
+ *
71
+ * @example
72
+ * await expect(clipboard).toHaveData('Copied value');
73
+ * await expect(clipboard).toHaveData({ id: 123, status: 'success' });
74
+ */
75
+ toHaveData(expected: unknown, options?: MatcherOptions): Promise<R>;
76
+ }
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Asserts that the clipboard content matches the expected value.
82
+ * Uses smart polling to wait for the clipboard to be updated.
83
+ * If the `expected` value is an object, it attempts to parse the clipboard
84
+ * content as JSON before comparing.
85
+ *
86
+ * @this ExpectMatcherState
87
+ * @param clipboard The Clipboard utility instance.
88
+ * @param expected The string or object to compare against the clipboard content.
89
+ * @param options Optional settings for the matcher, such as timeout.
90
+ * @returns A Promise that resolves to a MatcherReturnType object.
91
+ */
92
+ declare function toHaveData(this: ExpectMatcherState, clipboard: ClipboardHandler, expected: unknown, options?: MatcherOptions): Promise<MatcherReturnType>;
93
+
94
+ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & {
95
+ clipboard: ClipboardHandler;
96
+ }, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;
97
+ declare const expect: _playwright_test.Expect<{
98
+ toHaveData: typeof toHaveData;
99
+ }>;
100
+
101
+ /**
102
+ * Export an object containing all the custom clipboard matchers for Playwright.
103
+ */
104
+ declare const clipboardMatchers: {
105
+ toHaveData: typeof toHaveData;
106
+ };
107
+
108
+ export { ClipboardHandler, clipboardFixture, clipboardMatchers, expect, test };
@@ -0,0 +1,108 @@
1
+ import * as _playwright_test from '@playwright/test';
2
+ import { Page, BrowserContext, TestFixture, ExpectMatcherState, MatcherReturnType } from '@playwright/test';
3
+
4
+ /**
5
+ * Playwright-compatible Clipboard utilities.
6
+ *
7
+ * Core functions for interacting with the browser clipboard within Playwright tests.
8
+ * Provides wrappers for reading plain text and JSON.
9
+ *
10
+ * @remarks
11
+ * These utilities require 'clipboard-read' and 'clipboard-write' permissions
12
+ * to be granted in the browser context.
13
+ */
14
+
15
+ declare class ClipboardHandler {
16
+ private readonly page;
17
+ private readonly context;
18
+ private isPermissionGranted;
19
+ constructor(page: Page, context: BrowserContext);
20
+ /**
21
+ * Grants the necessary clipboard permissions ('clipboard-read' and 'clipboard-write') to the browser context.
22
+ * This method is called internally before any clipboard read operation to ensure permissions are set.
23
+ * @private
24
+ */
25
+ private grantPermissions;
26
+ /**
27
+ * Reads the current text content from the browser clipboard.
28
+ * If the content is a JSON-encoded string (e.g., has extra quotes),
29
+ * it will be returned as is. Use readJSON for automatic parsing.
30
+ *
31
+ * @returns A promise that resolves to the clipboard string content.
32
+ */
33
+ read(): Promise<string>;
34
+ /**
35
+ * Reads the clipboard content and parses it as JSON.
36
+ * If the content is a string literal (e.g., '"value"'), it returns the unwrapped string ('value').
37
+ *
38
+ * @template T - The expected type of the parsed JSON object.
39
+ * @returns A promise that resolves to the parsed JSON object of type T.
40
+ * @throws {Error} If the clipboard content is not a valid JSON string.
41
+ */
42
+ readJSON<T = unknown>(): Promise<T>;
43
+ }
44
+
45
+ /**
46
+ * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
47
+ * It allows reading from the clipboard during tests.
48
+ */
49
+ declare const clipboardFixture: TestFixture<ClipboardHandler, {
50
+ page: Page;
51
+ context: BrowserContext;
52
+ browserName: string;
53
+ }>;
54
+
55
+ type MatcherOptions = {
56
+ timeout?: number;
57
+ };
58
+ declare global {
59
+ namespace PlaywrightTest {
60
+ interface Matchers<R> {
61
+ /**
62
+ * Asserts that the clipboard content matches the expected value.
63
+ * Uses smart polling to wait for the clipboard to be updated.
64
+ * If the `expected` value is an object, it attempts to parse the clipboard
65
+ * content as JSON before comparing.
66
+ *
67
+ * @param expected The string or object to compare against the clipboard content.
68
+ * @param options Optional settings for the matcher, such as timeout.
69
+ * @returns A Promise that resolves when the assertion completes.
70
+ *
71
+ * @example
72
+ * await expect(clipboard).toHaveData('Copied value');
73
+ * await expect(clipboard).toHaveData({ id: 123, status: 'success' });
74
+ */
75
+ toHaveData(expected: unknown, options?: MatcherOptions): Promise<R>;
76
+ }
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Asserts that the clipboard content matches the expected value.
82
+ * Uses smart polling to wait for the clipboard to be updated.
83
+ * If the `expected` value is an object, it attempts to parse the clipboard
84
+ * content as JSON before comparing.
85
+ *
86
+ * @this ExpectMatcherState
87
+ * @param clipboard The Clipboard utility instance.
88
+ * @param expected The string or object to compare against the clipboard content.
89
+ * @param options Optional settings for the matcher, such as timeout.
90
+ * @returns A Promise that resolves to a MatcherReturnType object.
91
+ */
92
+ declare function toHaveData(this: ExpectMatcherState, clipboard: ClipboardHandler, expected: unknown, options?: MatcherOptions): Promise<MatcherReturnType>;
93
+
94
+ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & {
95
+ clipboard: ClipboardHandler;
96
+ }, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;
97
+ declare const expect: _playwright_test.Expect<{
98
+ toHaveData: typeof toHaveData;
99
+ }>;
100
+
101
+ /**
102
+ * Export an object containing all the custom clipboard matchers for Playwright.
103
+ */
104
+ declare const clipboardMatchers: {
105
+ toHaveData: typeof toHaveData;
106
+ };
107
+
108
+ export { ClipboardHandler, clipboardFixture, clipboardMatchers, expect, test };
package/dist/index.js ADDED
@@ -0,0 +1,144 @@
1
+ // src/utils/clipboardHandler.ts
2
+ var ClipboardHandler = class {
3
+ constructor(page, context) {
4
+ this.page = page;
5
+ this.context = context;
6
+ this.isPermissionGranted = false;
7
+ }
8
+ page;
9
+ context;
10
+ isPermissionGranted;
11
+ /**
12
+ * Grants the necessary clipboard permissions ('clipboard-read' and 'clipboard-write') to the browser context.
13
+ * This method is called internally before any clipboard read operation to ensure permissions are set.
14
+ * @private
15
+ */
16
+ async grantPermissions() {
17
+ if (!this.isPermissionGranted) {
18
+ await this.context.grantPermissions(["clipboard-read", "clipboard-write"]);
19
+ this.isPermissionGranted = true;
20
+ }
21
+ }
22
+ /**
23
+ * Reads the current text content from the browser clipboard.
24
+ * If the content is a JSON-encoded string (e.g., has extra quotes),
25
+ * it will be returned as is. Use readJSON for automatic parsing.
26
+ *
27
+ * @returns A promise that resolves to the clipboard string content.
28
+ */
29
+ async read() {
30
+ await this.grantPermissions();
31
+ return await this.page.evaluate(() => navigator.clipboard.readText());
32
+ }
33
+ /**
34
+ * Reads the clipboard content and parses it as JSON.
35
+ * If the content is a string literal (e.g., '"value"'), it returns the unwrapped string ('value').
36
+ *
37
+ * @template T - The expected type of the parsed JSON object.
38
+ * @returns A promise that resolves to the parsed JSON object of type T.
39
+ * @throws {Error} If the clipboard content is not a valid JSON string.
40
+ */
41
+ async readJSON() {
42
+ const text = await this.read();
43
+ try {
44
+ return JSON.parse(text);
45
+ } catch {
46
+ throw new Error(`Clipboard content is not a valid JSON: ${JSON.stringify(text)}`);
47
+ }
48
+ }
49
+ };
50
+
51
+ // src/fixtures/clipboardFixture.ts
52
+ var clipboardFixture = async ({ page, context, browserName }, use) => {
53
+ if (browserName !== "chromium") {
54
+ throw new Error(
55
+ `[playwright-clipboard] Browser '${browserName}' is not supported. Clipboard Permissions API is currently only supported in Chromium-based browsers.
56
+ Use test.skip(browserName !== 'chromium') in your tests to skip non-Chromium runs.`
57
+ );
58
+ }
59
+ const handler = new ClipboardHandler(page, context);
60
+ await use(handler);
61
+ };
62
+
63
+ // src/fixtures.ts
64
+ import { expect as baseExpect, test as baseTest } from "@playwright/test";
65
+
66
+ // src/matchers/toHaveData.ts
67
+ import { expect } from "@playwright/test";
68
+
69
+ // src/utils/matcherUtils.ts
70
+ function getErrorMessage(name, expected, actual, error, errorMessage) {
71
+ const message = `${this.utils.matcherHint(name, void 0, void 0, { isNot: this.isNot })}
72
+
73
+ `;
74
+ if (error) {
75
+ return () => `${message}An unexpected error occurred:
76
+ ${error.message}`;
77
+ }
78
+ if (errorMessage) {
79
+ return () => `${message}${errorMessage}`;
80
+ }
81
+ return () => message + `Expected: ${this.isNot ? "not " : ""}${this.utils.printExpected(expected)}
82
+ Received: ${this.utils.printReceived(actual)}`;
83
+ }
84
+
85
+ // src/matchers/toHaveData.ts
86
+ async function toHaveData(clipboard, expected, options = {}) {
87
+ const name = "toHaveData";
88
+ let pass;
89
+ let actual;
90
+ const { timeout = 1e4 } = options;
91
+ const poll = expect.poll(
92
+ async () => {
93
+ try {
94
+ actual = await clipboard.readJSON();
95
+ } catch {
96
+ actual = await clipboard.read();
97
+ }
98
+ if (typeof expected === "string" && actual !== null && actual !== void 0) {
99
+ return String(actual);
100
+ }
101
+ return actual;
102
+ },
103
+ { timeout }
104
+ );
105
+ try {
106
+ const expectation = this.isNot ? poll.not : poll;
107
+ await expectation.toEqual(expected);
108
+ pass = true;
109
+ } catch {
110
+ pass = false;
111
+ }
112
+ if (this.isNot) pass = !pass;
113
+ const matcherReturn = {
114
+ message: getErrorMessage.call(this, name, expected, actual),
115
+ pass,
116
+ name,
117
+ expected,
118
+ actual
119
+ };
120
+ return matcherReturn;
121
+ }
122
+
123
+ // src/matchers/clipboardMatchers.ts
124
+ var clipboardMatchers = {
125
+ toHaveData
126
+ };
127
+
128
+ // src/fixtures.ts
129
+ var test = baseTest.extend({
130
+ /**
131
+ * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
132
+ * It allows reading from the clipboard during tests.
133
+ */
134
+ clipboard: clipboardFixture
135
+ });
136
+ var expect2 = baseExpect.extend({ ...clipboardMatchers });
137
+ export {
138
+ ClipboardHandler,
139
+ clipboardFixture,
140
+ clipboardMatchers,
141
+ expect2 as expect,
142
+ test
143
+ };
144
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/clipboardHandler.ts","../src/fixtures/clipboardFixture.ts","../src/fixtures.ts","../src/matchers/toHaveData.ts","../src/utils/matcherUtils.ts","../src/matchers/clipboardMatchers.ts"],"sourcesContent":["/**\n * Playwright-compatible Clipboard utilities.\n *\n * Core functions for interacting with the browser clipboard within Playwright tests.\n * Provides wrappers for reading plain text and JSON.\n *\n * @remarks\n * These utilities require 'clipboard-read' and 'clipboard-write' permissions\n * to be granted in the browser context.\n */\n\nimport type { BrowserContext, Page } from '@playwright/test';\n\nexport class ClipboardHandler {\n private isPermissionGranted: boolean;\n\n constructor(\n private readonly page: Page,\n private readonly context: BrowserContext,\n ) {\n this.isPermissionGranted = false;\n }\n\n /**\n * Grants the necessary clipboard permissions ('clipboard-read' and 'clipboard-write') to the browser context.\n * This method is called internally before any clipboard read operation to ensure permissions are set.\n * @private\n */\n private async grantPermissions() {\n if (!this.isPermissionGranted) {\n await this.context.grantPermissions(['clipboard-read', 'clipboard-write']);\n this.isPermissionGranted = true;\n }\n }\n\n /**\n * Reads the current text content from the browser clipboard.\n * If the content is a JSON-encoded string (e.g., has extra quotes),\n * it will be returned as is. Use readJSON for automatic parsing.\n *\n * @returns A promise that resolves to the clipboard string content.\n */\n async read(): Promise<string> {\n await this.grantPermissions();\n return await this.page.evaluate(() => navigator.clipboard.readText());\n }\n\n /**\n * Reads the clipboard content and parses it as JSON.\n * If the content is a string literal (e.g., '\"value\"'), it returns the unwrapped string ('value').\n *\n * @template T - The expected type of the parsed JSON object.\n * @returns A promise that resolves to the parsed JSON object of type T.\n * @throws {Error} If the clipboard content is not a valid JSON string.\n */\n async readJSON<T = unknown>(): Promise<T> {\n const text = await this.read();\n try {\n return JSON.parse(text);\n } catch {\n throw new Error(`Clipboard content is not a valid JSON: ${JSON.stringify(text)}`);\n }\n }\n}\n","import type { BrowserContext, Page, TestFixture } from '@playwright/test';\nimport { ClipboardHandler } from '../utils/clipboardHandler.js';\n\n/**\n * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.\n * It allows reading from the clipboard during tests.\n */\nexport const clipboardFixture: TestFixture<\n ClipboardHandler,\n { page: Page; context: BrowserContext; browserName: string }\n> = async ({ page, context, browserName }, use) => {\n if (browserName !== 'chromium') {\n throw new Error(\n `[playwright-clipboard] Browser '${browserName}' is not supported. ` +\n 'Clipboard Permissions API is currently only supported in Chromium-based browsers.\\n' +\n `Use test.skip(browserName !== 'chromium') in your tests to skip non-Chromium runs.`,\n );\n }\n\n const handler = new ClipboardHandler(page, context);\n await use(handler);\n};\n","import { expect as baseExpect, test as baseTest } from '@playwright/test';\nimport { clipboardFixture } from './fixtures/clipboardFixture.js';\nimport { clipboardMatchers } from './matchers/clipboardMatchers.js';\nimport type { ClipboardHandler } from './utils/clipboardHandler.js';\n\nexport const test = baseTest.extend<{\n clipboard: ClipboardHandler;\n}>({\n /**\n * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.\n * It allows reading from the clipboard during tests.\n */\n clipboard: clipboardFixture,\n});\n\nexport const expect = baseExpect.extend({ ...clipboardMatchers });\n","import { type ExpectMatcherState, expect, type MatcherReturnType } from '@playwright/test';\nimport type { ClipboardHandler } from '../utils/clipboardHandler.js';\nimport { getErrorMessage } from '../utils/matcherUtils.js';\nimport type { MatcherOptions } from './types.js';\n\n/**\n * Asserts that the clipboard content matches the expected value.\n * Uses smart polling to wait for the clipboard to be updated.\n * If the `expected` value is an object, it attempts to parse the clipboard\n * content as JSON before comparing.\n *\n * @this ExpectMatcherState\n * @param clipboard The Clipboard utility instance.\n * @param expected The string or object to compare against the clipboard content.\n * @param options Optional settings for the matcher, such as timeout.\n * @returns A Promise that resolves to a MatcherReturnType object.\n */\nexport async function toHaveData(\n this: ExpectMatcherState,\n clipboard: ClipboardHandler,\n expected: unknown,\n options: MatcherOptions = {},\n) {\n const name = 'toHaveData';\n let pass: boolean;\n let actual: unknown;\n\n const { timeout = 10_000 } = options;\n\n const poll = expect.poll(\n async () => {\n try {\n actual = await clipboard.readJSON();\n } catch {\n actual = await clipboard.read();\n }\n\n if (typeof expected === 'string' && actual !== null && actual !== undefined) {\n return String(actual);\n }\n\n return actual;\n },\n { timeout },\n );\n\n try {\n const expectation = this.isNot ? poll.not : poll;\n await expectation.toEqual(expected);\n pass = true;\n } catch {\n pass = false;\n }\n\n /**\n * NOTE ON INVERSION:\n * In Playwright custom matchers, if `this.isNot` is true, the matcher must return\n * `pass: false` for the assertion to pass. Since `poll.not.toEqual` resolves\n * to `true` when the condition is met, we invert it back to align with Playwright's expectations.\n */\n if (this.isNot) pass = !pass;\n\n const matcherReturn: MatcherReturnType = {\n message: getErrorMessage.call(this, name, expected, actual),\n pass,\n name,\n expected,\n actual,\n };\n\n return matcherReturn;\n}\n","import type { ExpectMatcherState } from '@playwright/test';\n\n/**\n * Generates an error message for a custom matcher.\n *\n * @this ExpectMatcherState\n * @param name The name of the matcher.\n * @param expected The expected value.\n * @param actual The actual value.\n * @param error An optional error object.\n * @param errorMessage An optional error message string.\n * @returns A function that returns the error message string.\n */\nexport function getErrorMessage(\n this: ExpectMatcherState,\n name: string,\n expected: unknown,\n actual: unknown,\n error?: Error | null,\n errorMessage?: string | undefined | null,\n): () => string {\n const message = `${this.utils.matcherHint(name, undefined, undefined, { isNot: this.isNot })}\\n\\n`;\n\n if (error) {\n return () => `${message}An unexpected error occurred:\\n${error.message}`;\n }\n\n if (errorMessage) {\n return () => `${message}${errorMessage}`;\n }\n\n return () =>\n message +\n `Expected: ${this.isNot ? 'not ' : ''}${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(actual)}`;\n}\n","import { toHaveData } from './toHaveData.js';\n\n/**\n * Export an object containing all the custom clipboard matchers for Playwright.\n */\nexport const clipboardMatchers = {\n toHaveData,\n};\n"],"mappings":"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","names":["expect"]}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "playwright-clipboard-testing",
3
+ "version": "0.1.0",
4
+ "description": "Playwright fixture and custom matchers for clipboard testing and assertions.",
5
+ "author": "Sergii Oleksenko <serg.oleksenko@gmail.com>",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "homepage": "https://github.com/sergoleksenko/playwright-clipboard-testing#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/sergoleksenko/playwright-clipboard-testing/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/sergoleksenko/playwright-clipboard-testing.git"
15
+ },
16
+ "keywords": [
17
+ "playwright",
18
+ "typescript",
19
+ "clipboard",
20
+ "testing",
21
+ "fixture",
22
+ "matcher",
23
+ "integration",
24
+ "e2e"
25
+ ],
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": {
32
+ "import": "./dist/index.d.ts",
33
+ "require": "./dist/index.d.cts"
34
+ },
35
+ "import": "./dist/index.js",
36
+ "require": "./dist/index.cjs"
37
+ }
38
+ },
39
+ "files": [
40
+ "dist"
41
+ ],
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ },
45
+ "sideEffects": false,
46
+ "scripts": {
47
+ "build": "tsup",
48
+ "dev": "tsup --watch",
49
+ "lint": "biome check .",
50
+ "lint:fix": "biome check --write .",
51
+ "typecheck": "tsc --noEmit",
52
+ "format": "biome format --write .",
53
+ "test": "echo \"Error: no test specified\" && exit 1"
54
+ },
55
+ "devDependencies": {
56
+ "@biomejs/biome": "2.5.10",
57
+ "@playwright/test": "1.62.1",
58
+ "tsup": "^8.5.1",
59
+ "typescript": "5.8.3"
60
+ },
61
+ "peerDependencies": {
62
+ "@playwright/test": ">=1.40.0"
63
+ }
64
+ }