@muritavo/playwright-toolkit 1.0.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/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Playwright Toolkit
2
+
3
+ A testing toolkit for Playwright with Firebase emulator integration.
4
+
5
+ ## Features
6
+
7
+ - Firebase Emulator support (Firestore, Auth, Storage)
8
+ - Test environment setup and teardown
9
+ - Administrative operations (user management, data clearing)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @muritavo/playwright-toolkit
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### Basic Setup
20
+
21
+ ```typescript
22
+ import { setEmulatorConfig } from '@muritavo/playwright-toolkit';
23
+
24
+ // Configure emulator in your test setup
25
+ const firebaseConfig = require('../firebase.json');
26
+ setEmulatorConfig(firebaseConfig);
27
+ ```
28
+
29
+ ### Running Tests
30
+
31
+ ```typescript
32
+ import { startEmulator, killEmulator, setupEmulator } from '@muritavo/playwright-toolkit';
33
+
34
+ test('my test', async ({ page }) => {
35
+ await startEmulator('my-project');
36
+
37
+ await setupEmulator(async (firestore, storage, admin) => {
38
+ // Your test code here
39
+ }, 'my-project');
40
+
41
+ await killEmulator();
42
+ });
43
+ ```
44
+
45
+ ## API Reference
46
+
47
+ ### `setEmulatorConfig(config)`
48
+ Sets the Firebase emulator configuration.
49
+
50
+ ### `startEmulator(projectName, databaseToImport?, tenantId?, suiteId?, exportDataOnExit?, only?)`
51
+ Starts the Firebase emulator for testing.
52
+
53
+ ### `killEmulator()`
54
+ Stops the running emulator instance.
55
+
56
+ ### `setupEmulator(callback, projectId, storageBucket?, authTenantId?)`
57
+ Sets up the emulator with security rules disabled for testing.
58
+
59
+ ## License
60
+
61
+ MIT
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Playwright command registration utility
3
+ * Similar to Cypress Commands.add but adapted for Playwright
4
+ */
5
+ type CommandOptions = {
6
+ prevSubject?: boolean | 'optional';
7
+ timeout?: number;
8
+ log?: boolean;
9
+ };
10
+ type CommandHandler<T = any> = (subject: T, ...args: any[]) => Promise<any> | void;
11
+ export declare function addCommand<T = any>(name: string, usage: string, optionsOrHandler: CommandOptions | CommandHandler<T>, maybeHandler?: CommandHandler<T>): void;
12
+ export declare function getCommand(name: string): CommandHandler | undefined;
13
+ export declare function executeCommand(name: string, subject: any, ...args: any[]): Promise<any>;
14
+ export {};
15
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/_shared/register.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,cAAc,GAAG;IACpB,WAAW,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,KAAK,cAAc,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAInF,wBAAgB,UAAU,CAAC,CAAC,GAAG,GAAG,EAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,cAAc,GAAG,cAAc,CAAC,CAAC,CAAC,EACpD,YAAY,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAC/B,IAAI,CAUN;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEnE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAMvF"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * Playwright command registration utility
4
+ * Similar to Cypress Commands.add but adapted for Playwright
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.addCommand = addCommand;
8
+ exports.getCommand = getCommand;
9
+ exports.executeCommand = executeCommand;
10
+ const commands = new Map();
11
+ function addCommand(name, usage, optionsOrHandler, maybeHandler) {
12
+ const hasOptions = typeof optionsOrHandler === 'object' && !('apply' in optionsOrHandler);
13
+ const options = hasOptions ? optionsOrHandler : {};
14
+ const handler = hasOptions ? maybeHandler : optionsOrHandler;
15
+ commands.set(name, { handler, options });
16
+ // In Playwright, you would typically attach this to the Page object or use fixtures
17
+ // This is a simplified implementation
18
+ console.log(`Command registered: ${name} - ${usage}`);
19
+ }
20
+ function getCommand(name) {
21
+ return commands.get(name)?.handler;
22
+ }
23
+ function executeCommand(name, subject, ...args) {
24
+ const command = commands.get(name);
25
+ if (!command) {
26
+ throw new Error(`Command "${name}" not found`);
27
+ }
28
+ return command.handler(subject, ...args);
29
+ }
30
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/_shared/register.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAYH,gCAeC;AAED,gCAEC;AAED,wCAMC;AA7BD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAgE,CAAC;AAEzF,SAAgB,UAAU,CACxB,IAAY,EACZ,KAAa,EACb,gBAAoD,EACpD,YAAgC;IAEhC,MAAM,UAAU,GAAG,OAAO,gBAAgB,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC;IAC1F,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAE,gBAAmC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAE,YAAkC,CAAC,CAAC,CAAE,gBAAsC,CAAC;IAE3G,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAEzC,oFAAoF;IACpF,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC;AACxD,CAAC;AAED,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;AACrC,CAAC;AAED,SAAgB,cAAc,CAAC,IAAY,EAAE,OAAY,EAAE,GAAG,IAAW;IACvE,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,aAAa,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const execTask: (task: "pwd", args?: any, options?: any) => Promise<any>;
2
+ //# sourceMappingURL=playwright.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../src/augmentation/playwright.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,QAAQ,GACnB,MAAM,KAAK,EACX,OAAO,GAAG,EACV,UAAU,GAAG,KACZ,OAAO,CAAC,GAAG,CAWb,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /// <reference types="node"/>
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.execTask = void 0;
5
+ /**
6
+ * Playwright equivalent of Cypress execTask
7
+ * This allows calling Node.js tasks from Playwright tests
8
+ */
9
+ const child_process_1 = require("child_process");
10
+ const execTask = async (task, args, options) => {
11
+ // In Playwright, we typically use Node.js directly or spawn processes
12
+ // This is a simplified implementation - adjust based on your needs
13
+ if (task === "pwd") {
14
+ return (0, child_process_1.execSync)("pwd", { encoding: "utf-8" }).trim();
15
+ }
16
+ // For other tasks, you can implement specific logic
17
+ // This is a placeholder - implement based on your actual task requirements
18
+ console.log(`Task executed: ${task}`, args);
19
+ return null;
20
+ };
21
+ exports.execTask = execTask;
22
+ //# sourceMappingURL=playwright.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright.js","sourceRoot":"","sources":["../../src/augmentation/playwright.ts"],"names":[],"mappings":";AAAA,6BAA6B;;;AAE7B;;;GAGG;AAEH,iDAAyC;AAElC,MAAM,QAAQ,GAAG,KAAK,EAC3B,IAAW,EACX,IAAU,EACV,OAAa,EACC,EAAE;IAChB,sEAAsE;IACtE,mEAAmE;IACnE,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,OAAO,IAAA,wBAAQ,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,CAAC;IAED,oDAAoD;IACpD,2EAA2E;IAC3E,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAfW,QAAA,QAAQ,YAenB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * For some reason, on node 18 "node-fetch" fails when connecting to "localhost" domain
3
+ * So I needed to change to 127.0.0.1
4
+ */
5
+ export declare const LOCALHOST_DOMAIN = "127.0.0.1";
6
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,cAAc,CAAC"}
package/dist/consts.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LOCALHOST_DOMAIN = void 0;
4
+ /**
5
+ * For some reason, on node 18 "node-fetch" fails when connecting to "localhost" domain
6
+ * So I needed to change to 127.0.0.1
7
+ */
8
+ exports.LOCALHOST_DOMAIN = "127.0.0.1";
9
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,gBAAgB,GAAG,WAAW,CAAC"}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * These are a series of functions to control an emulator from the Playwright tests
3
+ */
4
+ import { FirebaseConfigShape } from "./emulator.types";
5
+ /**
6
+ * Sets the Firebase emulator configuration
7
+ * Must be called before any emulator operations
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { setEmulatorConfig } from '@muritavo/playwright-toolkit';
12
+ *
13
+ * beforeAll() {
14
+ * setEmulatorConfig(require("./firebase.json"));
15
+ * }
16
+ * ```
17
+ */
18
+ export declare function setEmulatorConfig(config: FirebaseConfigShape): void;
19
+ /**
20
+ * Kills the running Firebase emulator instance
21
+ * Cleans up environment variables and stops the emulator process
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * import { killEmulator } from '@muritavo/playwright-toolkit';
26
+ *
27
+ * afterAll(async () => {
28
+ * await killEmulator();
29
+ * });
30
+ * ```
31
+ */
32
+ export declare function killEmulator(): Promise<void>;
33
+ /**
34
+ * Starts the Firebase emulator for testing
35
+ *
36
+ * @param projectName - Firebase project name
37
+ * @param databaseToImport - Optional database name to import
38
+ * @param tenantId - Optional tenant ID
39
+ * @param suiteId - Optional suite identifier
40
+ * @param exportDataOnExit - Whether to export data when emulator exits
41
+ * @param only - Array of features to enable (firestore, storage, etc.)
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * import { startEmulator } from '@muritavo/playwright-toolkit';
46
+ *
47
+ * test('my test', async () => {
48
+ * await startEmulator('my-project', 'my-database');
49
+ * // ... run tests
50
+ * });
51
+ * ```
52
+ */
53
+ export declare function startEmulator(projectName: string, databaseToImport?: string, tenantId?: string, suiteId?: string, exportDataOnExit?: boolean, only?: string[]): Promise<void>;
54
+ /**
55
+ * Clears all data from the Firestore emulator for a project
56
+ *
57
+ * @param projectId - Firebase project ID
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * import { clearFirestore } from '@muritavo/playwright-toolkit';
62
+ *
63
+ * test('my test', async () => {
64
+ * await clearFirestore('my-project');
65
+ * // ... run tests with clean Firestore
66
+ * });
67
+ * ```
68
+ */
69
+ export declare function clearFirestore(projectId: string): Promise<void>;
70
+ /**
71
+ * Clears authentication data for a project
72
+ *
73
+ * @param projectId - Firebase project ID
74
+ * @param tenantId - Optional tenant ID
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * import { clearAuth } from '@muritavo/playwright-toolkit';
79
+ *
80
+ * test('my test', async () => {
81
+ * await clearAuth('my-project');
82
+ * // ... run tests with clean Auth
83
+ * });
84
+ * ```
85
+ */
86
+ export declare function clearAuth(projectId: string, tenantId?: string): Promise<void>;
87
+ /**
88
+ * Adds a user to the emulator
89
+ *
90
+ * @param email - User email
91
+ * @param password - User password
92
+ * @param projectId - Firebase project ID
93
+ * @param localId - Optional predictable user ID
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * import { addUser } from '@muritavo/playwright-toolkit';
98
+ *
99
+ * test('my test', async () => {
100
+ * await addUser('user@test.com', 'password123', 'my-project', 'user-123');
101
+ * // ... test with authenticated user
102
+ * });
103
+ * ```
104
+ */
105
+ export declare function addUser(email: string, password: string, projectId: string, localId?: string): Promise<void>;
106
+ /**
107
+ * Clears storage data from the emulator
108
+ *
109
+ * @param projectId - Firebase project ID
110
+ * @param storageBucket - Storage bucket name
111
+ * @param folder - Folder path to clear
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * import { clearEmulatorStorage } from '@muritavo/playwright-toolkit';
116
+ *
117
+ * test('my test', async () => {
118
+ * await clearEmulatorStorage('my-project', 'my-bucket', 'uploads');
119
+ * // ... run tests with clean storage
120
+ * });
121
+ * ```
122
+ */
123
+ export declare function clearEmulatorStorage(projectId: string, storageBucket: string, folder: string): Promise<void>;
124
+ /**
125
+ * Sets up the emulator with a callback for testing
126
+ * Runs the callback with security rules disabled
127
+ *
128
+ * @param cb - Callback function that receives firestore, storage, and admin objects
129
+ * @param projectId - Firebase project ID
130
+ * @param storageBucket - Optional storage bucket name
131
+ * @param authTenantId - Optional auth tenant ID
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * import { setupEmulator } from '@muritavo/playwright-toolkit';
136
+ *
137
+ * test('my test', async () => {
138
+ * await setupEmulator(async (firestore, storage, admin) => {
139
+ * // Test with security rules disabled
140
+ * await firestore.collection('users').add({ name: 'Test' });
141
+ * }, 'my-project');
142
+ * });
143
+ * ```
144
+ */
145
+ export declare function setupEmulator(cb: (firestore: any, storage: any, admin: any) => Promise<void> | void, projectId: string, storageBucket?: string, authTenantId?: string): Promise<void>;
146
+ /**
147
+ * Deletes a Firestore collection by path
148
+ *
149
+ * @param path - Collection path to delete
150
+ * @param project - Firebase project ID
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * import { deleteCollection } from '@muritavo/playwright-toolkit';
155
+ *
156
+ * test('my test', async () => {
157
+ * await deleteCollection('users', 'my-project');
158
+ * // ... run tests
159
+ * });
160
+ * ```
161
+ */
162
+ export declare function deleteCollection(path: string, project: string): Promise<Response>;
163
+ /**
164
+ * Registers an emulator instance
165
+ *
166
+ * @param projectName - Firebase project name
167
+ * @param tenantId - Optional tenant ID
168
+ * @param suiteId - Optional suite identifier
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * import { registerEmulator } from '@muritavo/playwright-toolkit';
173
+ *
174
+ * test('my test', async () => {
175
+ * await registerEmulator('my-project', undefined, 'suite-1');
176
+ * });
177
+ * ```
178
+ */
179
+ export declare function registerEmulator(projectName: string, tenantId?: string, suiteId?: string): Promise<void>;
180
+ //# sourceMappingURL=emulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator.d.ts","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;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;;;;;;;;;;GAeG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,GAAE,MAAW,iBAUrB"}
@@ -0,0 +1,368 @@
1
+ "use strict";
2
+ /**
3
+ * These are a series of functions to control an emulator from the Playwright tests
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.setEmulatorConfig = setEmulatorConfig;
40
+ exports.killEmulator = killEmulator;
41
+ exports.startEmulator = startEmulator;
42
+ exports.clearFirestore = clearFirestore;
43
+ exports.clearAuth = clearAuth;
44
+ exports.addUser = addUser;
45
+ exports.clearEmulatorStorage = clearEmulatorStorage;
46
+ exports.setupEmulator = setupEmulator;
47
+ exports.deleteCollection = deleteCollection;
48
+ exports.registerEmulator = registerEmulator;
49
+ const consts_1 = require("./consts");
50
+ const emulator_1 = require("@muritavo/testing-toolkit/dist/native/emulator");
51
+ let emulatorConfig;
52
+ /**
53
+ * Sets the Firebase emulator configuration
54
+ * Must be called before any emulator operations
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * import { setEmulatorConfig } from '@muritavo/playwright-toolkit';
59
+ *
60
+ * beforeAll() {
61
+ * setEmulatorConfig(require("./firebase.json"));
62
+ * }
63
+ * ```
64
+ */
65
+ function setEmulatorConfig(config) {
66
+ emulatorConfig = config;
67
+ }
68
+ async function initializeTestEnvironment(...args) {
69
+ const { initializeTestEnvironment } = await Promise.resolve().then(() => __importStar(require("@firebase/rules-unit-testing")));
70
+ return initializeTestEnvironment(...args);
71
+ }
72
+ /**
73
+ * Kills the running Firebase emulator instance
74
+ * Cleans up environment variables and stops the emulator process
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * import { killEmulator } from '@muritavo/playwright-toolkit';
79
+ *
80
+ * afterAll(async () => {
81
+ * await killEmulator();
82
+ * });
83
+ * ```
84
+ */
85
+ async function killEmulator() {
86
+ delete process.env.LAST_DATABASE;
87
+ await (0, emulator_1.killEmulator)();
88
+ }
89
+ function _getPort(emulator) {
90
+ if (!emulatorConfig) {
91
+ throw new Error(`You didn't set the emulator config. Provide it by using the following at your Playwright setup file:
92
+
93
+ import { setEmulatorConfig } from '@muritavo/playwright-toolkit/dist/support/emulator'
94
+ ...
95
+ ...
96
+ ...
97
+ beforeAll() {
98
+ setEmulatorConfig(require("THE_PATH_TO_YOUR_FIREBASE_JSON"))
99
+ }
100
+ `);
101
+ }
102
+ const emulatorConfigSet = emulatorConfig.emulators[emulator];
103
+ if (!emulatorConfigSet || !emulatorConfigSet.port) {
104
+ throw new Error(`Emulator config not found`);
105
+ }
106
+ return emulatorConfigSet.port;
107
+ }
108
+ /**
109
+ * Starts the Firebase emulator for testing
110
+ *
111
+ * @param projectName - Firebase project name
112
+ * @param databaseToImport - Optional database name to import
113
+ * @param tenantId - Optional tenant ID
114
+ * @param suiteId - Optional suite identifier
115
+ * @param exportDataOnExit - Whether to export data when emulator exits
116
+ * @param only - Array of features to enable (firestore, storage, etc.)
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * import { startEmulator } from '@muritavo/playwright-toolkit';
121
+ *
122
+ * test('my test', async () => {
123
+ * await startEmulator('my-project', 'my-database');
124
+ * // ... run tests
125
+ * });
126
+ * ```
127
+ */
128
+ async function startEmulator(projectName, databaseToImport = "", tenantId, suiteId, exportDataOnExit = false, only = []) {
129
+ if (!emulatorConfig)
130
+ throw new Error("You didn't provide the emulator config via 'setEmulatorConfig'");
131
+ if (!emulatorConfig.emulators)
132
+ throw new Error("The provided firebase config doesn't contain emulators config. Please review the firebase.json file.");
133
+ await (0, emulator_1.startEmulator)({
134
+ projectId: projectName,
135
+ databaseToImport,
136
+ tenantId,
137
+ suiteId,
138
+ only,
139
+ UIPort: 4000,
140
+ ports: [],
141
+ shouldSaveData: exportDataOnExit,
142
+ startAtCwd: undefined,
143
+ });
144
+ // Store database info in environment variable
145
+ process.env.LAST_DATABASE = databaseToImport;
146
+ }
147
+ /**
148
+ * Clears all data from the Firestore emulator for a project
149
+ *
150
+ * @param projectId - Firebase project ID
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * import { clearFirestore } from '@muritavo/playwright-toolkit';
155
+ *
156
+ * test('my test', async () => {
157
+ * await clearFirestore('my-project');
158
+ * // ... run tests with clean Firestore
159
+ * });
160
+ * ```
161
+ */
162
+ async function clearFirestore(projectId) {
163
+ const testEnv = await initializeTestEnvironment({
164
+ projectId: projectId,
165
+ firestore: {
166
+ host: consts_1.LOCALHOST_DOMAIN,
167
+ port: _getPort("firestore"),
168
+ },
169
+ });
170
+ await testEnv.clearFirestore();
171
+ testEnv.cleanup();
172
+ }
173
+ /**
174
+ * Clears authentication data for a project
175
+ *
176
+ * @param projectId - Firebase project ID
177
+ * @param tenantId - Optional tenant ID
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * import { clearAuth } from '@muritavo/playwright-toolkit';
182
+ *
183
+ * test('my test', async () => {
184
+ * await clearAuth('my-project');
185
+ * // ... run tests with clean Auth
186
+ * });
187
+ * ```
188
+ */
189
+ async function clearAuth(projectId, tenantId) {
190
+ const response = await fetch(`http://${consts_1.LOCALHOST_DOMAIN}:${_getPort("auth")}/emulator/v1/projects/${projectId}${tenantId ? `/tenants/${tenantId}/accounts` : "/accounts"}`, {
191
+ method: "delete",
192
+ });
193
+ if (response.status >= 300) {
194
+ throw new Error(`Cleaning accounts returned ${response.status}`);
195
+ }
196
+ }
197
+ /**
198
+ * Adds a user to the emulator
199
+ *
200
+ * @param email - User email
201
+ * @param password - User password
202
+ * @param projectId - Firebase project ID
203
+ * @param localId - Optional predictable user ID
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * import { addUser } from '@muritavo/playwright-toolkit';
208
+ *
209
+ * test('my test', async () => {
210
+ * await addUser('user@test.com', 'password123', 'my-project', 'user-123');
211
+ * // ... test with authenticated user
212
+ * });
213
+ * ```
214
+ */
215
+ async function addUser(email, password, projectId, localId) {
216
+ await setupEmulator(async (_f, _s, a) => {
217
+ if (localId)
218
+ a.getUser(localId)
219
+ .then((u) => {
220
+ if (u) {
221
+ return a.deleteUser(localId);
222
+ }
223
+ })
224
+ .then(() => a.createUser({ email, password, uid: localId }));
225
+ else
226
+ a.createUser({ email, password, uid: localId });
227
+ }, projectId);
228
+ }
229
+ /**
230
+ * Clears storage data from the emulator
231
+ *
232
+ * @param projectId - Firebase project ID
233
+ * @param storageBucket - Storage bucket name
234
+ * @param folder - Folder path to clear
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * import { clearEmulatorStorage } from '@muritavo/playwright-toolkit';
239
+ *
240
+ * test('my test', async () => {
241
+ * await clearEmulatorStorage('my-project', 'my-bucket', 'uploads');
242
+ * // ... run tests with clean storage
243
+ * });
244
+ * ```
245
+ */
246
+ async function clearEmulatorStorage(projectId, storageBucket, folder) {
247
+ await setupEmulator(async (_f, s) => {
248
+ async function removeFiles(path) {
249
+ const files = await s.ref(path).listAll();
250
+ for (let preffix of files.prefixes)
251
+ await removeFiles([path, preffix.name].join("/"));
252
+ for (let file of files.items)
253
+ await file.delete();
254
+ }
255
+ await removeFiles(folder);
256
+ }, projectId, storageBucket);
257
+ }
258
+ /**
259
+ * Sets up the emulator with a callback for testing
260
+ * Runs the callback with security rules disabled
261
+ *
262
+ * @param cb - Callback function that receives firestore, storage, and admin objects
263
+ * @param projectId - Firebase project ID
264
+ * @param storageBucket - Optional storage bucket name
265
+ * @param authTenantId - Optional auth tenant ID
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * import { setupEmulator } from '@muritavo/playwright-toolkit';
270
+ *
271
+ * test('my test', async () => {
272
+ * await setupEmulator(async (firestore, storage, admin) => {
273
+ * // Test with security rules disabled
274
+ * await firestore.collection('users').add({ name: 'Test' });
275
+ * }, 'my-project');
276
+ * });
277
+ * ```
278
+ */
279
+ async function setupEmulator(cb, projectId, storageBucket, authTenantId) {
280
+ try {
281
+ const testEnv = await initializeTestEnvironment({
282
+ projectId: projectId,
283
+ firestore: {
284
+ host: consts_1.LOCALHOST_DOMAIN,
285
+ port: _getPort("firestore"),
286
+ },
287
+ storage: {
288
+ host: consts_1.LOCALHOST_DOMAIN,
289
+ port: _getPort("storage"),
290
+ },
291
+ });
292
+ await testEnv.withSecurityRulesDisabled(async (ctx) => {
293
+ await cb(ctx.firestore({
294
+ experimentalForceLongPolling: true,
295
+ }), ctx.storage(storageBucket), new Proxy({}, {
296
+ get: (_, authInterfaceFunctionName) => {
297
+ return (...params) => {
298
+ for (let param of params)
299
+ if (typeof param === "function")
300
+ throw new Error(`The admin is called via proxy to the native node process. A function cannot be passed as parameter to the function ${authInterfaceFunctionName}`);
301
+ return (0, emulator_1.invokeAuthAdmin)({
302
+ projectId,
303
+ functionName: authInterfaceFunctionName,
304
+ params: params,
305
+ port: _getPort("auth").toString(),
306
+ overrideAuthTenant: authTenantId,
307
+ });
308
+ };
309
+ },
310
+ }));
311
+ });
312
+ }
313
+ catch (e) {
314
+ throw e;
315
+ }
316
+ }
317
+ /**
318
+ * Deletes a Firestore collection by path
319
+ *
320
+ * @param path - Collection path to delete
321
+ * @param project - Firebase project ID
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * import { deleteCollection } from '@muritavo/playwright-toolkit';
326
+ *
327
+ * test('my test', async () => {
328
+ * await deleteCollection('users', 'my-project');
329
+ * // ... run tests
330
+ * });
331
+ * ```
332
+ */
333
+ async function deleteCollection(path, project) {
334
+ const response = await fetch(`http://${consts_1.LOCALHOST_DOMAIN}:${_getPort("firestore")}/emulator/v1/projects/${project}/databases/(default)/documents${path}`, {
335
+ method: "delete",
336
+ });
337
+ if (!response.ok) {
338
+ throw new Error(`Delete collection failed with status ${response.status}`);
339
+ }
340
+ return response;
341
+ }
342
+ /**
343
+ * Registers an emulator instance
344
+ *
345
+ * @param projectName - Firebase project name
346
+ * @param tenantId - Optional tenant ID
347
+ * @param suiteId - Optional suite identifier
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * import { registerEmulator } from '@muritavo/playwright-toolkit';
352
+ *
353
+ * test('my test', async () => {
354
+ * await registerEmulator('my-project', undefined, 'suite-1');
355
+ * });
356
+ * ```
357
+ */
358
+ async function registerEmulator(projectName, tenantId, suiteId = "") {
359
+ console.log("CALLING REGISTER", projectName, tenantId);
360
+ await (0, emulator_1.registerEmulator)({
361
+ databaseToImport: "",
362
+ projectId: projectName,
363
+ suiteId: suiteId,
364
+ process: undefined,
365
+ tenantId,
366
+ });
367
+ }
368
+ //# sourceMappingURL=emulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator.js","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;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;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAe;IAClE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,UAAU,yBAAgB,IAAI,QAAQ,CACpC,WAAW,CACZ,yBAAyB,OAAO,iCAAiC,IAAI,EAAE,EACxE;QACE,MAAM,EAAE,QAAQ;KACjB,CACF,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,wCAAwC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,QAAiB,EACjB,UAAkB,EAAE;IAEpB,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACvD,MAAM,IAAA,2BAAsB,EAAC;QAC3B,gBAAgB,EAAE,EAAE;QACpB,SAAS,EAAE,WAAW;QACtB,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,SAAS;QAClB,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,31 @@
1
+ declare const FirebaseConfigShapeExample: {
2
+ emulators: {
3
+ auth: {
4
+ port: number;
5
+ };
6
+ functions: {
7
+ port: number;
8
+ };
9
+ firestore: {
10
+ port: number;
11
+ };
12
+ hosting: {
13
+ port: number;
14
+ };
15
+ storage: {
16
+ port: number;
17
+ };
18
+ pubsub: {
19
+ port: number;
20
+ };
21
+ ui: {
22
+ enabled: boolean;
23
+ port: number;
24
+ };
25
+ };
26
+ };
27
+ export type FirebaseConfigShape = {
28
+ emulators: Partial<typeof FirebaseConfigShapeExample['emulators']>;
29
+ };
30
+ export {};
31
+ //# sourceMappingURL=emulator.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator.types.d.ts","sourceRoot":"","sources":["../src/emulator.types.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;CAyB/B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,SAAS,EAAE,OAAO,CAAC,OAAO,0BAA0B,CAAC,WAAW,CAAC,CAAC,CAAA;CACrE,CAAA"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const FirebaseConfigShapeExample = {
4
+ "emulators": {
5
+ "auth": {
6
+ "port": 9099,
7
+ },
8
+ "functions": {
9
+ "port": 5001,
10
+ },
11
+ "firestore": {
12
+ "port": 8080,
13
+ },
14
+ "hosting": {
15
+ "port": 5000,
16
+ },
17
+ "storage": {
18
+ "port": 9199,
19
+ },
20
+ "pubsub": {
21
+ "port": 8055,
22
+ },
23
+ "ui": {
24
+ "enabled": true,
25
+ "port": 4000,
26
+ }
27
+ },
28
+ };
29
+ //# sourceMappingURL=emulator.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator.types.js","sourceRoot":"","sources":["../src/emulator.types.ts"],"names":[],"mappings":";;AAAA,MAAM,0BAA0B,GAAG;IAC/B,WAAW,EAAE;QACT,MAAM,EAAE;YACJ,MAAM,EAAE,IAAI;SACf;QACD,WAAW,EAAE;YACT,MAAM,EAAE,IAAI;SACf;QACD,WAAW,EAAE;YACT,MAAM,EAAE,IAAI;SACf;QACD,SAAS,EAAE;YACP,MAAM,EAAE,IAAI;SACf;QACD,SAAS,EAAE;YACP,MAAM,EAAE,IAAI;SACf;QACD,QAAQ,EAAE;YACN,MAAM,EAAE,IAAI;SACf;QACD,IAAI,EAAE;YACF,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;SACf;KACJ;CACJ,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Playwright Toolkit - Main Entry Point
3
+ *
4
+ * Provides Firebase emulator integration for Playwright testing
5
+ */
6
+ export { setEmulatorConfig, killEmulator, clearFirestore, clearAuth, addUser, clearEmulatorStorage, setupEmulator, deleteCollection, registerEmulator } from './emulator';
7
+ export { FirebaseConfigShape } from './emulator.types';
8
+ export { LOCALHOST_DOMAIN } from './consts';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAC3D,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAC9D,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Playwright Toolkit - Main Entry Point
4
+ *
5
+ * Provides Firebase emulator integration for Playwright testing
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.LOCALHOST_DOMAIN = exports.registerEmulator = exports.deleteCollection = exports.setupEmulator = exports.clearEmulatorStorage = exports.addUser = exports.clearAuth = exports.clearFirestore = exports.killEmulator = exports.setEmulatorConfig = void 0;
9
+ var emulator_1 = require("./emulator");
10
+ Object.defineProperty(exports, "setEmulatorConfig", { enumerable: true, get: function () { return emulator_1.setEmulatorConfig; } });
11
+ Object.defineProperty(exports, "killEmulator", { enumerable: true, get: function () { return emulator_1.killEmulator; } });
12
+ Object.defineProperty(exports, "clearFirestore", { enumerable: true, get: function () { return emulator_1.clearFirestore; } });
13
+ Object.defineProperty(exports, "clearAuth", { enumerable: true, get: function () { return emulator_1.clearAuth; } });
14
+ Object.defineProperty(exports, "addUser", { enumerable: true, get: function () { return emulator_1.addUser; } });
15
+ Object.defineProperty(exports, "clearEmulatorStorage", { enumerable: true, get: function () { return emulator_1.clearEmulatorStorage; } });
16
+ Object.defineProperty(exports, "setupEmulator", { enumerable: true, get: function () { return emulator_1.setupEmulator; } });
17
+ Object.defineProperty(exports, "deleteCollection", { enumerable: true, get: function () { return emulator_1.deleteCollection; } });
18
+ Object.defineProperty(exports, "registerEmulator", { enumerable: true, get: function () { return emulator_1.registerEmulator; } });
19
+ var consts_1 = require("./consts");
20
+ Object.defineProperty(exports, "LOCALHOST_DOMAIN", { enumerable: true, get: function () { return consts_1.LOCALHOST_DOMAIN; } });
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAE6C;AAFpC,6GAAA,iBAAiB,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,qGAAA,SAAS,OAAA;AAC3D,mGAAA,OAAO,OAAA;AAAE,gHAAA,oBAAoB,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,4GAAA,gBAAgB,OAAA;AAC9D,4GAAA,gBAAgB,OAAA;AAExB,mCAA4C;AAAnC,0GAAA,gBAAgB,OAAA"}
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@muritavo/playwright-toolkit",
3
+ "version": "1.0.0",
4
+ "description": "Playwright testing toolkit for Firebase emulator integration",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "dev": "tsc --watch",
10
+ "test": "playwright test"
11
+ },
12
+ "dependencies": {
13
+ "@firebase/rules-unit-testing": "^5.0.0",
14
+ "@muritavo/testing-toolkit": "^0.6.10",
15
+ "debug": "^4.4.3",
16
+ "firebase-admin": "^13.8.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^25.6.0",
20
+ "playwright": "^1.40.0",
21
+ "typescript": "^5.0.0"
22
+ }
23
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": ["ES2020", "DOM"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true
15
+ },
16
+ "include": ["src/**/*"],
17
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
18
+ }