@get-skipper/playwright 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Skipper Contributors
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,74 @@
1
+ # @get-skipper/playwright
2
+
3
+ Skipper plugin for [Playwright](https://playwright.dev/) — enable/disable tests from a Google Spreadsheet.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add -D @get-skipper/playwright
9
+ # or
10
+ npm install --save-dev @get-skipper/playwright
11
+ ```
12
+
13
+ ## Setup
14
+
15
+ ### 1. Configure `playwright.config.ts`
16
+
17
+ ```ts
18
+ import { defineConfig } from '@playwright/test';
19
+ import { createSkipperGlobalSetup, SkipperReporter } from '@get-skipper/playwright';
20
+
21
+ const skipperConfig = {
22
+ spreadsheetId: process.env.SKIPPER_SPREADSHEET_ID!,
23
+ credentials: { credentialsBase64: process.env.GOOGLE_CREDS_B64! },
24
+ // Or for local dev:
25
+ // credentials: { credentialsFile: './service-account.json' },
26
+ };
27
+
28
+ export default defineConfig({
29
+ globalSetup: createSkipperGlobalSetup(skipperConfig),
30
+ reporter: [
31
+ ['list'],
32
+ [SkipperReporter, skipperConfig], // handles sync mode
33
+ ],
34
+ // ... rest of your config
35
+ });
36
+ ```
37
+
38
+ ### 2. Update test file imports
39
+
40
+ Replace the `@playwright/test` import with `@get-skipper/playwright`:
41
+
42
+ ```ts
43
+ // Before:
44
+ import { test, expect } from '@playwright/test';
45
+
46
+ // After:
47
+ import { test, expect } from '@get-skipper/playwright';
48
+ ```
49
+
50
+ The API is identical — `test` and `expect` work exactly as before. Tests with a future `disabledUntil` date in the spreadsheet are automatically skipped.
51
+
52
+ ## Test ID Format
53
+
54
+ Tests are identified in the spreadsheet as:
55
+
56
+ ```
57
+ {relative file path} > {describe block(s)} > {test name}
58
+ ```
59
+
60
+ Example:
61
+ ```
62
+ tests/auth/login.spec.ts > login > should log in with valid credentials
63
+ ```
64
+
65
+ ## Modes
66
+
67
+ - **`read-only`** (default): reads the spreadsheet, skips disabled tests. No writes.
68
+ - **`sync`** (`SKIPPER_MODE=sync`): same as read-only + reconciles the spreadsheet after the run.
69
+
70
+ See the [root README](../../README.md) for full setup instructions including Google Sheets configuration.
71
+
72
+ ## License
73
+
74
+ MIT
@@ -0,0 +1,45 @@
1
+ import { SkipperConfig, SkipperResolver } from '@get-skipper/core';
2
+ export { SkipperConfig } from '@get-skipper/core';
3
+ import * as _playwright_test from '@playwright/test';
4
+ export { expect } from '@playwright/test';
5
+ import { Reporter, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
6
+
7
+ declare function createSkipperGlobalSetup(config: SkipperConfig): () => Promise<void>;
8
+
9
+ type SkipperWorkerFixtures = {
10
+ _skipperResolver: SkipperResolver;
11
+ };
12
+ type SkipperTestFixtures = {
13
+ _skipperAutoSkip: void;
14
+ };
15
+ /**
16
+ * Extended Playwright `test` that automatically skips tests disabled in the spreadsheet.
17
+ *
18
+ * The resolver is initialized once per worker (reading from the cache file written
19
+ * by the globalSetup). Each test is checked via an auto-use fixture.
20
+ *
21
+ * Usage: replace `import { test } from '@playwright/test'`
22
+ * with `import { test } from '@get-skipper/playwright'`
23
+ */
24
+ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & SkipperTestFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & SkipperWorkerFixtures>;
25
+
26
+ /**
27
+ * SkipperReporter collects all test IDs discovered during the run.
28
+ * In sync mode (`SKIPPER_MODE=sync`), it reconciles the spreadsheet on completion:
29
+ * - Adds new tests (with empty disabledUntil)
30
+ * - Removes rows for tests no longer in the suite
31
+ *
32
+ * Add to playwright.config.ts:
33
+ * ```ts
34
+ * reporter: [['list'], [SkipperReporter, skipperConfig]]
35
+ * ```
36
+ */
37
+ declare class SkipperReporter implements Reporter {
38
+ private readonly config;
39
+ private readonly discoveredIds;
40
+ constructor(config: SkipperConfig);
41
+ onTestEnd(test: TestCase, _result: TestResult): void;
42
+ onEnd(_result: FullResult): Promise<void>;
43
+ }
44
+
45
+ export { SkipperReporter, createSkipperGlobalSetup, test };
@@ -0,0 +1,45 @@
1
+ import { SkipperConfig, SkipperResolver } from '@get-skipper/core';
2
+ export { SkipperConfig } from '@get-skipper/core';
3
+ import * as _playwright_test from '@playwright/test';
4
+ export { expect } from '@playwright/test';
5
+ import { Reporter, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
6
+
7
+ declare function createSkipperGlobalSetup(config: SkipperConfig): () => Promise<void>;
8
+
9
+ type SkipperWorkerFixtures = {
10
+ _skipperResolver: SkipperResolver;
11
+ };
12
+ type SkipperTestFixtures = {
13
+ _skipperAutoSkip: void;
14
+ };
15
+ /**
16
+ * Extended Playwright `test` that automatically skips tests disabled in the spreadsheet.
17
+ *
18
+ * The resolver is initialized once per worker (reading from the cache file written
19
+ * by the globalSetup). Each test is checked via an auto-use fixture.
20
+ *
21
+ * Usage: replace `import { test } from '@playwright/test'`
22
+ * with `import { test } from '@get-skipper/playwright'`
23
+ */
24
+ declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & SkipperTestFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions & SkipperWorkerFixtures>;
25
+
26
+ /**
27
+ * SkipperReporter collects all test IDs discovered during the run.
28
+ * In sync mode (`SKIPPER_MODE=sync`), it reconciles the spreadsheet on completion:
29
+ * - Adds new tests (with empty disabledUntil)
30
+ * - Removes rows for tests no longer in the suite
31
+ *
32
+ * Add to playwright.config.ts:
33
+ * ```ts
34
+ * reporter: [['list'], [SkipperReporter, skipperConfig]]
35
+ * ```
36
+ */
37
+ declare class SkipperReporter implements Reporter {
38
+ private readonly config;
39
+ private readonly discoveredIds;
40
+ constructor(config: SkipperConfig);
41
+ onTestEnd(test: TestCase, _result: TestResult): void;
42
+ onEnd(_result: FullResult): Promise<void>;
43
+ }
44
+
45
+ export { SkipperReporter, createSkipperGlobalSetup, test };
package/dist/index.js ADDED
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ SkipperReporter: () => SkipperReporter,
34
+ createSkipperGlobalSetup: () => createSkipperGlobalSetup,
35
+ expect: () => import_test2.expect,
36
+ test: () => test
37
+ });
38
+ module.exports = __toCommonJS(index_exports);
39
+
40
+ // src/globalSetup.ts
41
+ var fs = __toESM(require("fs"));
42
+ var os = __toESM(require("os"));
43
+ var path = __toESM(require("path"));
44
+ var import_core = require("@get-skipper/core");
45
+ var SKIPPER_CACHE_PATH = path.join(os.tmpdir(), ".skipper-playwright-cache.json");
46
+ function createSkipperGlobalSetup(config) {
47
+ return async function skipperGlobalSetup() {
48
+ const resolver = new import_core.SkipperResolver(config);
49
+ await resolver.initialize();
50
+ fs.writeFileSync(SKIPPER_CACHE_PATH, JSON.stringify(resolver.toJSON()), "utf8");
51
+ (0, import_core.log)("[skipper] Spreadsheet loaded and cache written.");
52
+ };
53
+ }
54
+
55
+ // src/fixtures.ts
56
+ var fs2 = __toESM(require("fs"));
57
+ var import_test = require("@playwright/test");
58
+ var import_core2 = require("@get-skipper/core");
59
+ var import_test2 = require("@playwright/test");
60
+ var test = import_test.test.extend({
61
+ _skipperResolver: [
62
+ async ({}, use) => {
63
+ const raw = fs2.readFileSync(SKIPPER_CACHE_PATH, "utf8");
64
+ const data = JSON.parse(raw);
65
+ const resolver = import_core2.SkipperResolver.fromJSON(data);
66
+ await use(resolver);
67
+ },
68
+ { scope: "worker" }
69
+ ],
70
+ _skipperAutoSkip: [
71
+ async ({ _skipperResolver }, use, testInfo) => {
72
+ const titlePath = testInfo.titlePath.filter(Boolean);
73
+ const testId = (0, import_core2.buildTestId)(testInfo.file, titlePath);
74
+ if (!_skipperResolver.isTestEnabled(testId)) {
75
+ testInfo.skip(true, `[skipper] Disabled until date in spreadsheet has not passed yet.`);
76
+ }
77
+ await use();
78
+ },
79
+ { auto: true }
80
+ ]
81
+ });
82
+
83
+ // src/reporter.ts
84
+ var import_core3 = require("@get-skipper/core");
85
+ var SkipperReporter = class {
86
+ constructor(config) {
87
+ this.discoveredIds = [];
88
+ this.config = config;
89
+ }
90
+ onTestEnd(test2, _result) {
91
+ const titlePath = test2.titlePath().filter(Boolean);
92
+ const testId = (0, import_core3.buildTestId)(test2.location.file, titlePath);
93
+ this.discoveredIds.push(testId);
94
+ }
95
+ async onEnd(_result) {
96
+ const mode = process.env.SKIPPER_MODE;
97
+ if (mode !== "sync") return;
98
+ if (this.discoveredIds.length === 0) {
99
+ (0, import_core3.log)("[skipper] No tests discovered \u2014 skipping spreadsheet sync.");
100
+ return;
101
+ }
102
+ (0, import_core3.log)(`[skipper] Syncing ${this.discoveredIds.length} test(s) to spreadsheet\u2026`);
103
+ const writer = new import_core3.SheetsWriter(this.config);
104
+ await writer.sync(this.discoveredIds);
105
+ }
106
+ };
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ SkipperReporter,
110
+ createSkipperGlobalSetup,
111
+ expect,
112
+ test
113
+ });
114
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/globalSetup.ts","../src/fixtures.ts","../src/reporter.ts"],"sourcesContent":["export { createSkipperGlobalSetup } from './globalSetup';\nexport { test, expect } from './fixtures';\nexport { SkipperReporter } from './reporter';\nexport type { SkipperConfig } from '@get-skipper/core';\n","import * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { SkipperResolver, log } from '@get-skipper/core';\nimport type { SkipperConfig } from '@get-skipper/core';\n\nexport const SKIPPER_CACHE_PATH = path.join(os.tmpdir(), '.skipper-playwright-cache.json');\n\nexport function createSkipperGlobalSetup(config: SkipperConfig) {\n return async function skipperGlobalSetup(): Promise<void> {\n const resolver = new SkipperResolver(config);\n await resolver.initialize();\n fs.writeFileSync(SKIPPER_CACHE_PATH, JSON.stringify(resolver.toJSON()), 'utf8');\n log('[skipper] Spreadsheet loaded and cache written.');\n };\n}\n","import * as fs from 'fs';\nimport { test as base } from '@playwright/test';\nimport { SkipperResolver, buildTestId } from '@get-skipper/core';\nimport { SKIPPER_CACHE_PATH } from './globalSetup';\n\ntype SkipperWorkerFixtures = {\n _skipperResolver: SkipperResolver;\n};\n\ntype SkipperTestFixtures = {\n _skipperAutoSkip: void;\n};\n\n/**\n * Extended Playwright `test` that automatically skips tests disabled in the spreadsheet.\n *\n * The resolver is initialized once per worker (reading from the cache file written\n * by the globalSetup). Each test is checked via an auto-use fixture.\n *\n * Usage: replace `import { test } from '@playwright/test'`\n * with `import { test } from '@get-skipper/playwright'`\n */\nexport const test = base.extend<SkipperTestFixtures, SkipperWorkerFixtures>({\n _skipperResolver: [\n async ({}, use) => {\n const raw = fs.readFileSync(SKIPPER_CACHE_PATH, 'utf8');\n const data = JSON.parse(raw) as Record<string, string | null>;\n const resolver = SkipperResolver.fromJSON(data);\n await use(resolver);\n },\n { scope: 'worker' },\n ],\n\n _skipperAutoSkip: [\n async ({ _skipperResolver }, use, testInfo) => {\n const titlePath = testInfo.titlePath.filter(Boolean);\n const testId = buildTestId(testInfo.file, titlePath);\n\n if (!_skipperResolver.isTestEnabled(testId)) {\n testInfo.skip(true, `[skipper] Disabled until date in spreadsheet has not passed yet.`);\n }\n\n await use();\n },\n { auto: true },\n ],\n});\n\nexport { expect } from '@playwright/test';\n","import type { Reporter, TestCase, TestResult, FullResult } from '@playwright/test/reporter';\nimport { SheetsWriter, buildTestId, log } from '@get-skipper/core';\nimport type { SkipperConfig } from '@get-skipper/core';\n\n/**\n * SkipperReporter collects all test IDs discovered during the run.\n * In sync mode (`SKIPPER_MODE=sync`), it reconciles the spreadsheet on completion:\n * - Adds new tests (with empty disabledUntil)\n * - Removes rows for tests no longer in the suite\n *\n * Add to playwright.config.ts:\n * ```ts\n * reporter: [['list'], [SkipperReporter, skipperConfig]]\n * ```\n */\nexport class SkipperReporter implements Reporter {\n private readonly config: SkipperConfig;\n private readonly discoveredIds: string[] = [];\n\n constructor(config: SkipperConfig) {\n this.config = config;\n }\n\n onTestEnd(test: TestCase, _result: TestResult): void {\n const titlePath = test.titlePath().filter(Boolean);\n const testId = buildTestId(test.location.file, titlePath);\n this.discoveredIds.push(testId);\n }\n\n async onEnd(_result: FullResult): Promise<void> {\n const mode = process.env.SKIPPER_MODE;\n if (mode !== 'sync') return;\n\n if (this.discoveredIds.length === 0) {\n log('[skipper] No tests discovered — skipping spreadsheet sync.');\n return;\n }\n\n log(`[skipper] Syncing ${this.discoveredIds.length} test(s) to spreadsheet…`);\n const writer = new SheetsWriter(this.config);\n await writer.sync(this.discoveredIds);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAoB;AACpB,SAAoB;AACpB,WAAsB;AACtB,kBAAqC;AAG9B,IAAM,qBAA0B,UAAQ,UAAO,GAAG,gCAAgC;AAElF,SAAS,yBAAyB,QAAuB;AAC9D,SAAO,eAAe,qBAAoC;AACxD,UAAM,WAAW,IAAI,4BAAgB,MAAM;AAC3C,UAAM,SAAS,WAAW;AAC1B,IAAG,iBAAc,oBAAoB,KAAK,UAAU,SAAS,OAAO,CAAC,GAAG,MAAM;AAC9E,yBAAI,iDAAiD;AAAA,EACvD;AACF;;;ACfA,IAAAA,MAAoB;AACpB,kBAA6B;AAC7B,IAAAC,eAA6C;AA8C7C,IAAAC,eAAuB;AA1BhB,IAAM,OAAO,YAAAC,KAAK,OAAmD;AAAA,EAC1E,kBAAkB;AAAA,IAChB,OAAO,CAAC,GAAG,QAAQ;AACjB,YAAM,MAAS,iBAAa,oBAAoB,MAAM;AACtD,YAAM,OAAO,KAAK,MAAM,GAAG;AAC3B,YAAM,WAAW,6BAAgB,SAAS,IAAI;AAC9C,YAAM,IAAI,QAAQ;AAAA,IACpB;AAAA,IACA,EAAE,OAAO,SAAS;AAAA,EACpB;AAAA,EAEA,kBAAkB;AAAA,IAChB,OAAO,EAAE,iBAAiB,GAAG,KAAK,aAAa;AAC7C,YAAM,YAAY,SAAS,UAAU,OAAO,OAAO;AACnD,YAAM,aAAS,0BAAY,SAAS,MAAM,SAAS;AAEnD,UAAI,CAAC,iBAAiB,cAAc,MAAM,GAAG;AAC3C,iBAAS,KAAK,MAAM,kEAAkE;AAAA,MACxF;AAEA,YAAM,IAAI;AAAA,IACZ;AAAA,IACA,EAAE,MAAM,KAAK;AAAA,EACf;AACF,CAAC;;;AC7CD,IAAAC,eAA+C;AAcxC,IAAM,kBAAN,MAA0C;AAAA,EAI/C,YAAY,QAAuB;AAFnC,SAAiB,gBAA0B,CAAC;AAG1C,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,UAAUC,OAAgB,SAA2B;AACnD,UAAM,YAAYA,MAAK,UAAU,EAAE,OAAO,OAAO;AACjD,UAAM,aAAS,0BAAYA,MAAK,SAAS,MAAM,SAAS;AACxD,SAAK,cAAc,KAAK,MAAM;AAAA,EAChC;AAAA,EAEA,MAAM,MAAM,SAAoC;AAC9C,UAAM,OAAO,QAAQ,IAAI;AACzB,QAAI,SAAS,OAAQ;AAErB,QAAI,KAAK,cAAc,WAAW,GAAG;AACnC,4BAAI,iEAA4D;AAChE;AAAA,IACF;AAEA,0BAAI,qBAAqB,KAAK,cAAc,MAAM,+BAA0B;AAC5E,UAAM,SAAS,IAAI,0BAAa,KAAK,MAAM;AAC3C,UAAM,OAAO,KAAK,KAAK,aAAa;AAAA,EACtC;AACF;","names":["fs","import_core","import_test","base","import_core","test"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,74 @@
1
+ // src/globalSetup.ts
2
+ import * as fs from "fs";
3
+ import * as os from "os";
4
+ import * as path from "path";
5
+ import { SkipperResolver, log } from "@get-skipper/core";
6
+ var SKIPPER_CACHE_PATH = path.join(os.tmpdir(), ".skipper-playwright-cache.json");
7
+ function createSkipperGlobalSetup(config) {
8
+ return async function skipperGlobalSetup() {
9
+ const resolver = new SkipperResolver(config);
10
+ await resolver.initialize();
11
+ fs.writeFileSync(SKIPPER_CACHE_PATH, JSON.stringify(resolver.toJSON()), "utf8");
12
+ log("[skipper] Spreadsheet loaded and cache written.");
13
+ };
14
+ }
15
+
16
+ // src/fixtures.ts
17
+ import * as fs2 from "fs";
18
+ import { test as base } from "@playwright/test";
19
+ import { SkipperResolver as SkipperResolver2, buildTestId } from "@get-skipper/core";
20
+ import { expect } from "@playwright/test";
21
+ var test = base.extend({
22
+ _skipperResolver: [
23
+ async ({}, use) => {
24
+ const raw = fs2.readFileSync(SKIPPER_CACHE_PATH, "utf8");
25
+ const data = JSON.parse(raw);
26
+ const resolver = SkipperResolver2.fromJSON(data);
27
+ await use(resolver);
28
+ },
29
+ { scope: "worker" }
30
+ ],
31
+ _skipperAutoSkip: [
32
+ async ({ _skipperResolver }, use, testInfo) => {
33
+ const titlePath = testInfo.titlePath.filter(Boolean);
34
+ const testId = buildTestId(testInfo.file, titlePath);
35
+ if (!_skipperResolver.isTestEnabled(testId)) {
36
+ testInfo.skip(true, `[skipper] Disabled until date in spreadsheet has not passed yet.`);
37
+ }
38
+ await use();
39
+ },
40
+ { auto: true }
41
+ ]
42
+ });
43
+
44
+ // src/reporter.ts
45
+ import { SheetsWriter, buildTestId as buildTestId2, log as log2 } from "@get-skipper/core";
46
+ var SkipperReporter = class {
47
+ constructor(config) {
48
+ this.discoveredIds = [];
49
+ this.config = config;
50
+ }
51
+ onTestEnd(test2, _result) {
52
+ const titlePath = test2.titlePath().filter(Boolean);
53
+ const testId = buildTestId2(test2.location.file, titlePath);
54
+ this.discoveredIds.push(testId);
55
+ }
56
+ async onEnd(_result) {
57
+ const mode = process.env.SKIPPER_MODE;
58
+ if (mode !== "sync") return;
59
+ if (this.discoveredIds.length === 0) {
60
+ log2("[skipper] No tests discovered \u2014 skipping spreadsheet sync.");
61
+ return;
62
+ }
63
+ log2(`[skipper] Syncing ${this.discoveredIds.length} test(s) to spreadsheet\u2026`);
64
+ const writer = new SheetsWriter(this.config);
65
+ await writer.sync(this.discoveredIds);
66
+ }
67
+ };
68
+ export {
69
+ SkipperReporter,
70
+ createSkipperGlobalSetup,
71
+ expect,
72
+ test
73
+ };
74
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/globalSetup.ts","../src/fixtures.ts","../src/reporter.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { SkipperResolver, log } from '@get-skipper/core';\nimport type { SkipperConfig } from '@get-skipper/core';\n\nexport const SKIPPER_CACHE_PATH = path.join(os.tmpdir(), '.skipper-playwright-cache.json');\n\nexport function createSkipperGlobalSetup(config: SkipperConfig) {\n return async function skipperGlobalSetup(): Promise<void> {\n const resolver = new SkipperResolver(config);\n await resolver.initialize();\n fs.writeFileSync(SKIPPER_CACHE_PATH, JSON.stringify(resolver.toJSON()), 'utf8');\n log('[skipper] Spreadsheet loaded and cache written.');\n };\n}\n","import * as fs from 'fs';\nimport { test as base } from '@playwright/test';\nimport { SkipperResolver, buildTestId } from '@get-skipper/core';\nimport { SKIPPER_CACHE_PATH } from './globalSetup';\n\ntype SkipperWorkerFixtures = {\n _skipperResolver: SkipperResolver;\n};\n\ntype SkipperTestFixtures = {\n _skipperAutoSkip: void;\n};\n\n/**\n * Extended Playwright `test` that automatically skips tests disabled in the spreadsheet.\n *\n * The resolver is initialized once per worker (reading from the cache file written\n * by the globalSetup). Each test is checked via an auto-use fixture.\n *\n * Usage: replace `import { test } from '@playwright/test'`\n * with `import { test } from '@get-skipper/playwright'`\n */\nexport const test = base.extend<SkipperTestFixtures, SkipperWorkerFixtures>({\n _skipperResolver: [\n async ({}, use) => {\n const raw = fs.readFileSync(SKIPPER_CACHE_PATH, 'utf8');\n const data = JSON.parse(raw) as Record<string, string | null>;\n const resolver = SkipperResolver.fromJSON(data);\n await use(resolver);\n },\n { scope: 'worker' },\n ],\n\n _skipperAutoSkip: [\n async ({ _skipperResolver }, use, testInfo) => {\n const titlePath = testInfo.titlePath.filter(Boolean);\n const testId = buildTestId(testInfo.file, titlePath);\n\n if (!_skipperResolver.isTestEnabled(testId)) {\n testInfo.skip(true, `[skipper] Disabled until date in spreadsheet has not passed yet.`);\n }\n\n await use();\n },\n { auto: true },\n ],\n});\n\nexport { expect } from '@playwright/test';\n","import type { Reporter, TestCase, TestResult, FullResult } from '@playwright/test/reporter';\nimport { SheetsWriter, buildTestId, log } from '@get-skipper/core';\nimport type { SkipperConfig } from '@get-skipper/core';\n\n/**\n * SkipperReporter collects all test IDs discovered during the run.\n * In sync mode (`SKIPPER_MODE=sync`), it reconciles the spreadsheet on completion:\n * - Adds new tests (with empty disabledUntil)\n * - Removes rows for tests no longer in the suite\n *\n * Add to playwright.config.ts:\n * ```ts\n * reporter: [['list'], [SkipperReporter, skipperConfig]]\n * ```\n */\nexport class SkipperReporter implements Reporter {\n private readonly config: SkipperConfig;\n private readonly discoveredIds: string[] = [];\n\n constructor(config: SkipperConfig) {\n this.config = config;\n }\n\n onTestEnd(test: TestCase, _result: TestResult): void {\n const titlePath = test.titlePath().filter(Boolean);\n const testId = buildTestId(test.location.file, titlePath);\n this.discoveredIds.push(testId);\n }\n\n async onEnd(_result: FullResult): Promise<void> {\n const mode = process.env.SKIPPER_MODE;\n if (mode !== 'sync') return;\n\n if (this.discoveredIds.length === 0) {\n log('[skipper] No tests discovered — skipping spreadsheet sync.');\n return;\n }\n\n log(`[skipper] Syncing ${this.discoveredIds.length} test(s) to spreadsheet…`);\n const writer = new SheetsWriter(this.config);\n await writer.sync(this.discoveredIds);\n }\n}\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,iBAAiB,WAAW;AAG9B,IAAM,qBAA0B,UAAQ,UAAO,GAAG,gCAAgC;AAElF,SAAS,yBAAyB,QAAuB;AAC9D,SAAO,eAAe,qBAAoC;AACxD,UAAM,WAAW,IAAI,gBAAgB,MAAM;AAC3C,UAAM,SAAS,WAAW;AAC1B,IAAG,iBAAc,oBAAoB,KAAK,UAAU,SAAS,OAAO,CAAC,GAAG,MAAM;AAC9E,QAAI,iDAAiD;AAAA,EACvD;AACF;;;ACfA,YAAYA,SAAQ;AACpB,SAAS,QAAQ,YAAY;AAC7B,SAAS,mBAAAC,kBAAiB,mBAAmB;AA8C7C,SAAS,cAAc;AA1BhB,IAAM,OAAO,KAAK,OAAmD;AAAA,EAC1E,kBAAkB;AAAA,IAChB,OAAO,CAAC,GAAG,QAAQ;AACjB,YAAM,MAAS,iBAAa,oBAAoB,MAAM;AACtD,YAAM,OAAO,KAAK,MAAM,GAAG;AAC3B,YAAM,WAAWC,iBAAgB,SAAS,IAAI;AAC9C,YAAM,IAAI,QAAQ;AAAA,IACpB;AAAA,IACA,EAAE,OAAO,SAAS;AAAA,EACpB;AAAA,EAEA,kBAAkB;AAAA,IAChB,OAAO,EAAE,iBAAiB,GAAG,KAAK,aAAa;AAC7C,YAAM,YAAY,SAAS,UAAU,OAAO,OAAO;AACnD,YAAM,SAAS,YAAY,SAAS,MAAM,SAAS;AAEnD,UAAI,CAAC,iBAAiB,cAAc,MAAM,GAAG;AAC3C,iBAAS,KAAK,MAAM,kEAAkE;AAAA,MACxF;AAEA,YAAM,IAAI;AAAA,IACZ;AAAA,IACA,EAAE,MAAM,KAAK;AAAA,EACf;AACF,CAAC;;;AC7CD,SAAS,cAAc,eAAAC,cAAa,OAAAC,YAAW;AAcxC,IAAM,kBAAN,MAA0C;AAAA,EAI/C,YAAY,QAAuB;AAFnC,SAAiB,gBAA0B,CAAC;AAG1C,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,UAAUC,OAAgB,SAA2B;AACnD,UAAM,YAAYA,MAAK,UAAU,EAAE,OAAO,OAAO;AACjD,UAAM,SAASF,aAAYE,MAAK,SAAS,MAAM,SAAS;AACxD,SAAK,cAAc,KAAK,MAAM;AAAA,EAChC;AAAA,EAEA,MAAM,MAAM,SAAoC;AAC9C,UAAM,OAAO,QAAQ,IAAI;AACzB,QAAI,SAAS,OAAQ;AAErB,QAAI,KAAK,cAAc,WAAW,GAAG;AACnC,MAAAD,KAAI,iEAA4D;AAChE;AAAA,IACF;AAEA,IAAAA,KAAI,qBAAqB,KAAK,cAAc,MAAM,+BAA0B;AAC5E,UAAM,SAAS,IAAI,aAAa,KAAK,MAAM;AAC3C,UAAM,OAAO,KAAK,KAAK,aAAa;AAAA,EACtC;AACF;","names":["fs","SkipperResolver","SkipperResolver","buildTestId","log","test"]}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@get-skipper/playwright",
3
+ "version": "1.0.0",
4
+ "description": "Skipper plugin for Playwright — enable/disable tests from a Google Spreadsheet",
5
+ "keywords": [
6
+ "skipper",
7
+ "playwright",
8
+ "testing",
9
+ "google-sheets",
10
+ "test-gating"
11
+ ],
12
+ "license": "MIT",
13
+ "main": "dist/index.js",
14
+ "module": "dist/index.mjs",
15
+ "types": "dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "dependencies": {
29
+ "@get-skipper/core": "1.0.0"
30
+ },
31
+ "peerDependencies": {
32
+ "@playwright/test": ">=1.40.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup",
39
+ "dev": "tsup --watch",
40
+ "typecheck": "tsc --noEmit",
41
+ "test": "jest --config ../../jest.config.js --testPathPattern=packages/playwright/"
42
+ }
43
+ }