@get-skipper/nightwatch 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,53 @@
1
+ # @get-skipper/nightwatch
2
+
3
+ Skipper plugin for [Nightwatch.js](https://nightwatchjs.org/) — enable/disable tests from a Google Spreadsheet.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add -D @get-skipper/nightwatch
9
+ # or
10
+ npm install --save-dev @get-skipper/nightwatch
11
+ ```
12
+
13
+ ## Setup
14
+
15
+ Update `nightwatch.conf.js` — this is the **only change required**:
16
+
17
+ ```js
18
+ const { createSkipperPlugin } = require('@get-skipper/nightwatch');
19
+
20
+ module.exports = {
21
+ globals: createSkipperPlugin({
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
+ // ... rest of your config
28
+ };
29
+ ```
30
+
31
+ No changes to test files are required. Tests with a future `disabledUntil` date are automatically skipped via `beforeEach`.
32
+
33
+ ## Test ID Format
34
+
35
+ ```
36
+ {module path} > {test name}
37
+ ```
38
+
39
+ If Nightwatch exposes nested describe blocks via `titlePath`, the full path is used:
40
+ ```
41
+ tests/auth/login.js > login > should log in with valid credentials
42
+ ```
43
+
44
+ ## Modes
45
+
46
+ - **`read-only`** (default): reads the spreadsheet, skips disabled tests. No writes.
47
+ - **`sync`** (`SKIPPER_MODE=sync`): same as read-only + reconciles the spreadsheet after the run.
48
+
49
+ See the [root README](../../README.md) for full setup instructions.
50
+
51
+ ## License
52
+
53
+ MIT
@@ -0,0 +1,28 @@
1
+ import { SkipperConfig } from '@get-skipper/core';
2
+ export { SkipperConfig } from '@get-skipper/core';
3
+
4
+ /**
5
+ * Creates a Nightwatch globals object that integrates Skipper.
6
+ *
7
+ * - `before`: initializes the resolver (reads the spreadsheet)
8
+ * - `beforeEach`: skips the test if disabledUntil is in the future
9
+ * - `after`: in sync mode, reconciles the spreadsheet with discovered tests
10
+ *
11
+ * Usage in nightwatch.conf.js:
12
+ * ```js
13
+ * const { createSkipperPlugin } = require('@get-skipper/nightwatch');
14
+ * module.exports = {
15
+ * globals: createSkipperPlugin({ spreadsheetId: '...', credentials: { ... } }),
16
+ * };
17
+ * ```
18
+ */
19
+ declare function createSkipperPlugin(config: SkipperConfig): {
20
+ before(): Promise<void>;
21
+ beforeEach(browser: NightwatchBrowser, done: () => void): void;
22
+ after(): Promise<void>;
23
+ };
24
+ interface NightwatchBrowser {
25
+ skip(): void;
26
+ }
27
+
28
+ export { createSkipperPlugin };
@@ -0,0 +1,28 @@
1
+ import { SkipperConfig } from '@get-skipper/core';
2
+ export { SkipperConfig } from '@get-skipper/core';
3
+
4
+ /**
5
+ * Creates a Nightwatch globals object that integrates Skipper.
6
+ *
7
+ * - `before`: initializes the resolver (reads the spreadsheet)
8
+ * - `beforeEach`: skips the test if disabledUntil is in the future
9
+ * - `after`: in sync mode, reconciles the spreadsheet with discovered tests
10
+ *
11
+ * Usage in nightwatch.conf.js:
12
+ * ```js
13
+ * const { createSkipperPlugin } = require('@get-skipper/nightwatch');
14
+ * module.exports = {
15
+ * globals: createSkipperPlugin({ spreadsheetId: '...', credentials: { ... } }),
16
+ * };
17
+ * ```
18
+ */
19
+ declare function createSkipperPlugin(config: SkipperConfig): {
20
+ before(): Promise<void>;
21
+ beforeEach(browser: NightwatchBrowser, done: () => void): void;
22
+ after(): Promise<void>;
23
+ };
24
+ interface NightwatchBrowser {
25
+ skip(): void;
26
+ }
27
+
28
+ export { createSkipperPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
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
+ createSkipperPlugin: () => createSkipperPlugin
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/globals.ts
28
+ var import_core = require("@get-skipper/core");
29
+ function createSkipperPlugin(config) {
30
+ let resolver;
31
+ const discoveredIds = [];
32
+ return {
33
+ async before() {
34
+ resolver = new import_core.SkipperResolver(config);
35
+ await resolver.initialize();
36
+ (0, import_core.log)("[skipper] Spreadsheet loaded.");
37
+ },
38
+ beforeEach(browser, done) {
39
+ if (!resolver) {
40
+ done();
41
+ return;
42
+ }
43
+ const currentTest = browser.currentTest;
44
+ if (!currentTest) {
45
+ done();
46
+ return;
47
+ }
48
+ const titlePath = currentTest.titlePath ?? [currentTest.name].filter(Boolean);
49
+ const filePath = currentTest.module ?? "";
50
+ const testId = (0, import_core.buildTestId)(filePath, titlePath);
51
+ discoveredIds.push(testId);
52
+ if (!resolver.isTestEnabled(testId)) {
53
+ browser.skip();
54
+ }
55
+ done();
56
+ },
57
+ async after() {
58
+ if (process.env.SKIPPER_MODE !== "sync") return;
59
+ if (discoveredIds.length === 0) {
60
+ (0, import_core.log)("[skipper] No tests discovered \u2014 skipping spreadsheet sync.");
61
+ return;
62
+ }
63
+ (0, import_core.log)(`[skipper] Syncing ${discoveredIds.length} test(s) to spreadsheet\u2026`);
64
+ const writer = new import_core.SheetsWriter(config);
65
+ await writer.sync(discoveredIds);
66
+ }
67
+ };
68
+ }
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ createSkipperPlugin
72
+ });
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/globals.ts"],"sourcesContent":["export { createSkipperPlugin } from './globals';\nexport type { SkipperConfig } from '@get-skipper/core';\n","import { SkipperResolver, SheetsWriter, buildTestId, log } from '@get-skipper/core';\nimport type { SkipperConfig } from '@get-skipper/core';\n\n/**\n * Creates a Nightwatch globals object that integrates Skipper.\n *\n * - `before`: initializes the resolver (reads the spreadsheet)\n * - `beforeEach`: skips the test if disabledUntil is in the future\n * - `after`: in sync mode, reconciles the spreadsheet with discovered tests\n *\n * Usage in nightwatch.conf.js:\n * ```js\n * const { createSkipperPlugin } = require('@get-skipper/nightwatch');\n * module.exports = {\n * globals: createSkipperPlugin({ spreadsheetId: '...', credentials: { ... } }),\n * };\n * ```\n */\nexport function createSkipperPlugin(config: SkipperConfig) {\n let resolver: SkipperResolver;\n const discoveredIds: string[] = [];\n\n return {\n async before(): Promise<void> {\n resolver = new SkipperResolver(config);\n await resolver.initialize();\n log('[skipper] Spreadsheet loaded.');\n },\n\n beforeEach(browser: NightwatchBrowser, done: () => void): void {\n if (!resolver) {\n done();\n return;\n }\n\n const currentTest = (browser as unknown as { currentTest: NightwatchCurrentTest }).currentTest;\n if (!currentTest) {\n done();\n return;\n }\n\n // Build the title path: Nightwatch may expose titlePath or just module + name\n const titlePath: string[] =\n (currentTest as unknown as { titlePath?: string[] }).titlePath ??\n [currentTest.name].filter(Boolean);\n\n const filePath = currentTest.module ?? '';\n const testId = buildTestId(filePath, titlePath);\n discoveredIds.push(testId);\n\n if (!resolver.isTestEnabled(testId)) {\n browser.skip();\n }\n\n done();\n },\n\n async after(): Promise<void> {\n if (process.env.SKIPPER_MODE !== 'sync') return;\n if (discoveredIds.length === 0) {\n log('[skipper] No tests discovered — skipping spreadsheet sync.');\n return;\n }\n\n log(`[skipper] Syncing ${discoveredIds.length} test(s) to spreadsheet…`);\n const writer = new SheetsWriter(config);\n await writer.sync(discoveredIds);\n },\n };\n}\n\n// Minimal type stubs for Nightwatch globals context (avoid requiring nightwatch types as a dep)\ninterface NightwatchCurrentTest {\n name: string;\n module: string;\n}\n\ninterface NightwatchBrowser {\n skip(): void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAgE;AAkBzD,SAAS,oBAAoB,QAAuB;AACzD,MAAI;AACJ,QAAM,gBAA0B,CAAC;AAEjC,SAAO;AAAA,IACL,MAAM,SAAwB;AAC5B,iBAAW,IAAI,4BAAgB,MAAM;AACrC,YAAM,SAAS,WAAW;AAC1B,2BAAI,+BAA+B;AAAA,IACrC;AAAA,IAEA,WAAW,SAA4B,MAAwB;AAC7D,UAAI,CAAC,UAAU;AACb,aAAK;AACL;AAAA,MACF;AAEA,YAAM,cAAe,QAA8D;AACnF,UAAI,CAAC,aAAa;AAChB,aAAK;AACL;AAAA,MACF;AAGA,YAAM,YACH,YAAoD,aACrD,CAAC,YAAY,IAAI,EAAE,OAAO,OAAO;AAEnC,YAAM,WAAW,YAAY,UAAU;AACvC,YAAM,aAAS,yBAAY,UAAU,SAAS;AAC9C,oBAAc,KAAK,MAAM;AAEzB,UAAI,CAAC,SAAS,cAAc,MAAM,GAAG;AACnC,gBAAQ,KAAK;AAAA,MACf;AAEA,WAAK;AAAA,IACP;AAAA,IAEA,MAAM,QAAuB;AAC3B,UAAI,QAAQ,IAAI,iBAAiB,OAAQ;AACzC,UAAI,cAAc,WAAW,GAAG;AAC9B,6BAAI,iEAA4D;AAChE;AAAA,MACF;AAEA,2BAAI,qBAAqB,cAAc,MAAM,+BAA0B;AACvE,YAAM,SAAS,IAAI,yBAAa,MAAM;AACtC,YAAM,OAAO,KAAK,aAAa;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,46 @@
1
+ // src/globals.ts
2
+ import { SkipperResolver, SheetsWriter, buildTestId, log } from "@get-skipper/core";
3
+ function createSkipperPlugin(config) {
4
+ let resolver;
5
+ const discoveredIds = [];
6
+ return {
7
+ async before() {
8
+ resolver = new SkipperResolver(config);
9
+ await resolver.initialize();
10
+ log("[skipper] Spreadsheet loaded.");
11
+ },
12
+ beforeEach(browser, done) {
13
+ if (!resolver) {
14
+ done();
15
+ return;
16
+ }
17
+ const currentTest = browser.currentTest;
18
+ if (!currentTest) {
19
+ done();
20
+ return;
21
+ }
22
+ const titlePath = currentTest.titlePath ?? [currentTest.name].filter(Boolean);
23
+ const filePath = currentTest.module ?? "";
24
+ const testId = buildTestId(filePath, titlePath);
25
+ discoveredIds.push(testId);
26
+ if (!resolver.isTestEnabled(testId)) {
27
+ browser.skip();
28
+ }
29
+ done();
30
+ },
31
+ async after() {
32
+ if (process.env.SKIPPER_MODE !== "sync") return;
33
+ if (discoveredIds.length === 0) {
34
+ log("[skipper] No tests discovered \u2014 skipping spreadsheet sync.");
35
+ return;
36
+ }
37
+ log(`[skipper] Syncing ${discoveredIds.length} test(s) to spreadsheet\u2026`);
38
+ const writer = new SheetsWriter(config);
39
+ await writer.sync(discoveredIds);
40
+ }
41
+ };
42
+ }
43
+ export {
44
+ createSkipperPlugin
45
+ };
46
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/globals.ts"],"sourcesContent":["import { SkipperResolver, SheetsWriter, buildTestId, log } from '@get-skipper/core';\nimport type { SkipperConfig } from '@get-skipper/core';\n\n/**\n * Creates a Nightwatch globals object that integrates Skipper.\n *\n * - `before`: initializes the resolver (reads the spreadsheet)\n * - `beforeEach`: skips the test if disabledUntil is in the future\n * - `after`: in sync mode, reconciles the spreadsheet with discovered tests\n *\n * Usage in nightwatch.conf.js:\n * ```js\n * const { createSkipperPlugin } = require('@get-skipper/nightwatch');\n * module.exports = {\n * globals: createSkipperPlugin({ spreadsheetId: '...', credentials: { ... } }),\n * };\n * ```\n */\nexport function createSkipperPlugin(config: SkipperConfig) {\n let resolver: SkipperResolver;\n const discoveredIds: string[] = [];\n\n return {\n async before(): Promise<void> {\n resolver = new SkipperResolver(config);\n await resolver.initialize();\n log('[skipper] Spreadsheet loaded.');\n },\n\n beforeEach(browser: NightwatchBrowser, done: () => void): void {\n if (!resolver) {\n done();\n return;\n }\n\n const currentTest = (browser as unknown as { currentTest: NightwatchCurrentTest }).currentTest;\n if (!currentTest) {\n done();\n return;\n }\n\n // Build the title path: Nightwatch may expose titlePath or just module + name\n const titlePath: string[] =\n (currentTest as unknown as { titlePath?: string[] }).titlePath ??\n [currentTest.name].filter(Boolean);\n\n const filePath = currentTest.module ?? '';\n const testId = buildTestId(filePath, titlePath);\n discoveredIds.push(testId);\n\n if (!resolver.isTestEnabled(testId)) {\n browser.skip();\n }\n\n done();\n },\n\n async after(): Promise<void> {\n if (process.env.SKIPPER_MODE !== 'sync') return;\n if (discoveredIds.length === 0) {\n log('[skipper] No tests discovered — skipping spreadsheet sync.');\n return;\n }\n\n log(`[skipper] Syncing ${discoveredIds.length} test(s) to spreadsheet…`);\n const writer = new SheetsWriter(config);\n await writer.sync(discoveredIds);\n },\n };\n}\n\n// Minimal type stubs for Nightwatch globals context (avoid requiring nightwatch types as a dep)\ninterface NightwatchCurrentTest {\n name: string;\n module: string;\n}\n\ninterface NightwatchBrowser {\n skip(): void;\n}\n"],"mappings":";AAAA,SAAS,iBAAiB,cAAc,aAAa,WAAW;AAkBzD,SAAS,oBAAoB,QAAuB;AACzD,MAAI;AACJ,QAAM,gBAA0B,CAAC;AAEjC,SAAO;AAAA,IACL,MAAM,SAAwB;AAC5B,iBAAW,IAAI,gBAAgB,MAAM;AACrC,YAAM,SAAS,WAAW;AAC1B,UAAI,+BAA+B;AAAA,IACrC;AAAA,IAEA,WAAW,SAA4B,MAAwB;AAC7D,UAAI,CAAC,UAAU;AACb,aAAK;AACL;AAAA,MACF;AAEA,YAAM,cAAe,QAA8D;AACnF,UAAI,CAAC,aAAa;AAChB,aAAK;AACL;AAAA,MACF;AAGA,YAAM,YACH,YAAoD,aACrD,CAAC,YAAY,IAAI,EAAE,OAAO,OAAO;AAEnC,YAAM,WAAW,YAAY,UAAU;AACvC,YAAM,SAAS,YAAY,UAAU,SAAS;AAC9C,oBAAc,KAAK,MAAM;AAEzB,UAAI,CAAC,SAAS,cAAc,MAAM,GAAG;AACnC,gBAAQ,KAAK;AAAA,MACf;AAEA,WAAK;AAAA,IACP;AAAA,IAEA,MAAM,QAAuB;AAC3B,UAAI,QAAQ,IAAI,iBAAiB,OAAQ;AACzC,UAAI,cAAc,WAAW,GAAG;AAC9B,YAAI,iEAA4D;AAChE;AAAA,MACF;AAEA,UAAI,qBAAqB,cAAc,MAAM,+BAA0B;AACvE,YAAM,SAAS,IAAI,aAAa,MAAM;AACtC,YAAM,OAAO,KAAK,aAAa;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@get-skipper/nightwatch",
3
+ "version": "1.0.0",
4
+ "description": "Skipper plugin for Nightwatch.js — enable/disable tests from a Google Spreadsheet",
5
+ "keywords": [
6
+ "skipper",
7
+ "nightwatch",
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
+ "nightwatch": ">=3.0.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/nightwatch/"
42
+ }
43
+ }