@seedmancer/playwright 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/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @seedmancer/playwright
2
+
3
+ Playwright integration for [Seedmancer](https://seedmancer.dev). Automatically seeds your database with a named scenario before each test.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install --save-dev @seedmancer/playwright
9
+ ```
10
+
11
+ The [Seedmancer CLI](https://seedmancer.dev/docs/install) must be installed and available in `PATH`.
12
+
13
+ ## Usage
14
+
15
+ Replace the standard Playwright `test` import with the one from this package:
16
+
17
+ ```ts
18
+ import { test, expect } from "@seedmancer/playwright";
19
+
20
+ test.use({
21
+ seedmancerScenario: "api-test",
22
+ });
23
+
24
+ test("user can open dashboard", async ({ page }) => {
25
+ await page.goto("/dashboard");
26
+ await expect(page.getByRole("heading", { name: "Dashboard" })).toBeVisible();
27
+ });
28
+ ```
29
+
30
+ Before each test, `seedmancer seed <scenario> --yes` is executed automatically. If `seedmancerScenario` is not set, the fixture is a no-op and no seeding occurs.
31
+
32
+ ## Options
33
+
34
+ Set options via `test.use()` at the file or describe level:
35
+
36
+ | Option | Type | Description |
37
+ |---|---|---|
38
+ | `seedmancerScenario` | `string` | Scenario name to seed. No seeding happens when omitted. |
39
+ | `seedmancerEnv` | `string` | Target environment (`--env` flag). Defaults to the project default. |
40
+ | `seedmancerCwd` | `string` | Working directory for the CLI. Defaults to `process.cwd()`. |
41
+
42
+ ## Scoping
43
+
44
+ Options follow Playwright's standard scoping rules. You can apply them globally in `playwright.config.ts`, per file with `test.use()`, or per describe block:
45
+
46
+ ```ts
47
+ // playwright.config.ts
48
+ import { defineConfig } from "@playwright/test";
49
+
50
+ export default defineConfig({
51
+ use: {
52
+ seedmancerScenario: "baseline",
53
+ },
54
+ });
55
+ ```
56
+
57
+ ```ts
58
+ // override for one describe block
59
+ test.describe("admin flows", () => {
60
+ test.use({ seedmancerScenario: "admin-data" });
61
+
62
+ test("admin can manage users", async ({ page }) => {
63
+ // ...
64
+ });
65
+ });
66
+ ```
67
+
68
+ ## Error handling
69
+
70
+ | Situation | Error message |
71
+ |---|---|
72
+ | CLI not found | `Seedmancer CLI not found. Make sure it is installed and available in PATH.` |
73
+ | Non-zero exit | `Seedmancer exited with status <N>: <stderr/stdout>` |
74
+ | Killed by signal | `Seedmancer was terminated by signal: <signal>` |
@@ -0,0 +1,12 @@
1
+ import { expect } from '@playwright/test';
2
+ export type SeedmancerOptions = {
3
+ seedmancerScenario: string | undefined;
4
+ seedmancerEnv: string | undefined;
5
+ seedmancerCwd: string | undefined;
6
+ };
7
+ type SeedmancerFixtures = {
8
+ _seedmancerSeed: void;
9
+ };
10
+ export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & SeedmancerOptions & SeedmancerFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
11
+ export { expect };
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAGxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,eAAe,EAAE,IAAI,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,IAAI,sRAoDf,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expect = exports.test = void 0;
4
+ const test_1 = require("@playwright/test");
5
+ Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_1.expect; } });
6
+ const node_child_process_1 = require("node:child_process");
7
+ exports.test = test_1.test.extend({
8
+ seedmancerScenario: [undefined, { option: true }],
9
+ seedmancerEnv: [undefined, { option: true }],
10
+ seedmancerCwd: [undefined, { option: true }],
11
+ _seedmancerSeed: [
12
+ async ({ seedmancerScenario, seedmancerEnv, seedmancerCwd }, use) => {
13
+ if (seedmancerScenario !== undefined) {
14
+ const args = ['seed', seedmancerScenario, '--yes'];
15
+ if (seedmancerEnv !== undefined) {
16
+ args.push('--env', seedmancerEnv);
17
+ }
18
+ const result = (0, node_child_process_1.spawnSync)('seedmancer', args, {
19
+ cwd: seedmancerCwd ?? process.cwd(),
20
+ stdio: 'pipe',
21
+ encoding: 'utf-8',
22
+ });
23
+ if (result.error !== undefined) {
24
+ const err = result.error;
25
+ if (err.code === 'ENOENT') {
26
+ throw new Error('Seedmancer CLI not found. Make sure it is installed and available in PATH.\n' +
27
+ 'See https://seedmancer.dev/docs/install for installation instructions.');
28
+ }
29
+ throw result.error;
30
+ }
31
+ if (result.signal !== null) {
32
+ throw new Error(`Seedmancer was terminated by signal: ${result.signal}`);
33
+ }
34
+ if (result.status !== 0) {
35
+ const output = [result.stderr?.trim(), result.stdout?.trim()]
36
+ .filter(Boolean)
37
+ .join('\n');
38
+ throw new Error(`Seedmancer exited with status ${result.status}` +
39
+ (output.length > 0 ? `:\n${output}` : ''));
40
+ }
41
+ }
42
+ await use();
43
+ },
44
+ { auto: true },
45
+ ],
46
+ });
47
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAAwD;AAmE/C,uFAnEc,aAAM,OAmEd;AAlEf,2DAA+C;AAYlC,QAAA,IAAI,GAAG,WAAI,CAAC,MAAM,CAAyC;IACtE,kBAAkB,EAAE,CAAC,SAAS,EAAE,EA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AG,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;yBAC1D,MAAM,CAAC,OAAO,CAAC;yBACf,IAAI,CAAC,IAAI,CAAC,CAAC;oBACd,MAAM,IAAI,KAAK,CACb,iCAAiC,MAAM,CAAC,MAAM,EAAE;wBAC9C,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5C,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,MAAM,GAAG,EAAE,CAAC;QACd,CAAC;QACD,EAAE,IAAI,EAAE,IAAI,EAAE;KACf;CACF,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@seedmancer/playwright",
3
+ "version": "0.1.0",
4
+ "description": "Playwright integration for Seedmancer – automatically seed your database before each test",
5
+ "keywords": [
6
+ "playwright",
7
+ "seedmancer",
8
+ "testing",
9
+ "seed",
10
+ "database",
11
+ "fixtures"
12
+ ],
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/KazanKK/seedmancer.git",
17
+ "directory": "packages/playwright"
18
+ },
19
+ "main": "dist/index.js",
20
+ "types": "dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "peerDependencies": {
36
+ "@playwright/test": ">=1.40.0"
37
+ },
38
+ "devDependencies": {
39
+ "@playwright/test": "^1.50.0",
40
+ "@types/node": "^26.0.1",
41
+ "typescript": "^5.7.0"
42
+ }
43
+ }