{"_id":"@ciderjs/vitest-plugin-gas-mock","_rev":"5-aeb66eb99b10abeca1910290aa89c7e8","name":"@ciderjs/vitest-plugin-gas-mock","dist-tags":{"latest":"0.2.0"},"versions":{"0.0.1":{"name":"@ciderjs/vitest-plugin-gas-mock","version":"0.0.1","keywords":["vitest","gas","google-apps-script"],"author":{"name":"ciderjs/luth"},"license":"MIT","_id":"@ciderjs/vitest-plugin-gas-mock@0.0.1","maintainers":[{"name":"luth","email":"cider6482+npm@gmail.com"}],"homepage":"https://github.com/luthpg/vitest-plugin-gas-mock#readme","bugs":{"url":"https://github.com/luthpg/vitest-plugin-gas-mock/issues"},"dist":{"shasum":"8423fc86238eccc8960ece69d6d51434a8b4b51a","tarball":"https://registry.npmjs.org/@ciderjs/vitest-plugin-gas-mock/-/vitest-plugin-gas-mock-0.0.1.tgz","fileCount":15,"integrity":"sha512-XCiZqo1Sw8X1ewikY13dubu7n0znJzZmIdd5oAxlyDJKqkkqMnVIBeRQxoNIVyy+GiDSZ37vTpSwKIKWPtBSFw==","signatures":[{"sig":"MEYCIQDs1VjEo6iB9+y2rk7FV1bT/Rb6qGX7YgnBwRcIvxVk0wIhAPJfH6o/kdCtJw0XsnDHkEHjBDTKkqsMAWGBXAq4Y0Uw","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ciderjs%2fvitest-plugin-gas-mock@0.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":3175869},"main":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./setup":{"types":"./dist/setup.d.ts","import":"./dist/setup.mjs","require":"./dist/setup.cjs"}},"gitHead":"377f7beb228bea69c7fdd82a093c4186cfe11776","scripts":{"lint":"biome ci","test":"pnpm generate && vitest run --coverage","build":"pnpm generate && unbuild -c","check":"biome check --write","prepare":"pnpm generate","generate":"jiti ./generator/index.ts","typecheck":"tsc --noEmit","all-checks":"pnpm lint && pnpm typecheck && pnpm test && pnpm build"},"_npmUser":{"name":"luth","email":"cider6482+npm@gmail.com"},"repository":{"url":"git+ssh://git@github.com/luthpg/vitest-plugin-gas-mock.git","type":"git"},"_npmVersion":"10.8.2","description":"Vitest plugin to mock Google Apps Script environment","directories":{},"_nodeVersion":"20.20.0","dependencies":{"vitest":"^4.0.18","ts-morph":"^27.0.2","@types/google-apps-script":"^2.0.8"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.28.2","devDependencies":{"jiti":"^2.6.1","unbuild":"^3.6.1","typescript":"^5.9.3","@types/node":"^25.2.0","@biomejs/biome":"^2.3.14","@vitest/coverage-v8":"4.0.18","@typescript/native-preview":"7.0.0-dev.20260205.1"},"_npmOperationalInternal":{"tmp":"tmp/vitest-plugin-gas-mock_0.0.1_1770298724325_0.49844439375253313","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@ciderjs/vitest-plugin-gas-mock","version":"0.0.2","keywords":["vitest","gas","google-apps-script"],"author":{"name":"ciderjs/luth"},"license":"MIT","_id":"@ciderjs/vitest-plugin-gas-mock@0.0.2","maintainers":[{"name":"luth","email":"cider6482+npm@gmail.com"}],"homepage":"https://github.com/luthpg/vitest-plugin-gas-mock#readme","bugs":{"url":"https://github.com/luthpg/vitest-plugin-gas-mock/issues"},"dist":{"shasum":"fcb18435c7ed42533baa8124abb6d67478aae805","tarball":"https://registry.npmjs.org/@ciderjs/vitest-plugin-gas-mock/-/vitest-plugin-gas-mock-0.0.2.tgz","fileCount":15,"integrity":"sha512-K3Jxf4SW2tACKCC8COk5RqWrM1vF4FlfVvpFwxvBJSfpE5I0pKmso2MUp1o6zfeUpGZLGtLVqVOdS6x9bAvyHQ==","signatures":[{"sig":"MEQCIHVRT0IuL0MHjoTtfbIDetn+QoIJGPiol7Hs6krCQAQ4AiBk97/tuIEN5z8Afyi9+C5qhykUGoxXhoq4QX/rqy8uQw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ciderjs%2fvitest-plugin-gas-mock@0.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":3313189},"main":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./setup":{"types":"./dist/setup.d.ts","import":"./dist/setup.mjs","require":"./dist/setup.cjs"}},"gitHead":"fc3188d782006a2f1ea09034537007317e9fa788","scripts":{"lint":"biome ci","test":"pnpm generate && vitest run --coverage","build":"pnpm generate && unbuild -c","check":"biome check --write","prepare":"pnpm generate","generate":"jiti ./generator/index.ts","typecheck":"tsc --noEmit","all-checks":"pnpm lint && pnpm typecheck && pnpm test && pnpm build"},"_npmUser":{"name":"luth","email":"cider6482+npm@gmail.com"},"repository":{"url":"git+ssh://git@github.com/luthpg/vitest-plugin-gas-mock.git","type":"git"},"_npmVersion":"10.8.2","description":"Vitest plugin to mock Google Apps Script environment","directories":{},"_nodeVersion":"20.20.0","dependencies":{"vitest":"^4.0.18","ts-morph":"^27.0.2","@types/google-apps-script":"^2.0.8"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.28.2","devDependencies":{"jiti":"^2.6.1","unbuild":"^3.6.1","typescript":"^5.9.3","@types/node":"^25.2.0","@biomejs/biome":"^2.3.14","@vitest/coverage-v8":"4.0.18","@typescript/native-preview":"7.0.0-dev.20260205.1"},"_npmOperationalInternal":{"tmp":"tmp/vitest-plugin-gas-mock_0.0.2_1770482305523_0.9698593905898782","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@ciderjs/vitest-plugin-gas-mock","version":"0.1.0","keywords":["vitest","gas","google-apps-script"],"author":{"name":"ciderjs/luth"},"license":"MIT","_id":"@ciderjs/vitest-plugin-gas-mock@0.1.0","maintainers":[{"name":"luth","email":"cider6482+npm@gmail.com"}],"homepage":"https://github.com/luthpg/vitest-plugin-gas-mock#readme","bugs":{"url":"https://github.com/luthpg/vitest-plugin-gas-mock/issues"},"dist":{"shasum":"1528eafe4d139a657e4193dff4523c6b3b84c962","tarball":"https://registry.npmjs.org/@ciderjs/vitest-plugin-gas-mock/-/vitest-plugin-gas-mock-0.1.0.tgz","fileCount":16,"integrity":"sha512-X/QiGyu8WEEXb9kJrEgIoXXjlJWsNZwiVI5Mk0ut0WZA2ARUBCAmmBbAwD+8D+LfLtj5KMmwXeE+U92rRWl1DA==","signatures":[{"sig":"MEQCIGVR7fRunpMMNkJulnlUSQQXO4cZePvdnXSOjtbOyOWxAiBUjevJAETa9gTv28Aw9g7ECnXzjseLC1h9cD2PJBvBqg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ciderjs%2fvitest-plugin-gas-mock@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":881512},"main":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./setup":{"types":"./dist/setup.d.ts","import":"./dist/setup.mjs","require":"./dist/setup.cjs"}},"gitHead":"2ca2294bbdd15ac73b9e2654a054bc9e09809eca","scripts":{"lint":"biome ci","test":"pnpm generate && vitest run --coverage","build":"pnpm generate && unbuild -c","check":"biome check --write","prepare":"pnpm generate","generate":"jiti ./generator/index.ts","typecheck":"tsc --noEmit","all-checks":"pnpm lint && pnpm typecheck && pnpm test && pnpm build"},"_npmUser":{"name":"luth","email":"cider6482+npm@gmail.com"},"repository":{"url":"git+ssh://git@github.com/luthpg/vitest-plugin-gas-mock.git","type":"git"},"_npmVersion":"10.8.2","description":"Vitest plugin to mock Google Apps Script environment","directories":{},"_nodeVersion":"20.20.0","dependencies":{"vitest":"^4.0.18"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.28.2","devDependencies":{"jiti":"^2.6.1","unbuild":"^3.6.1","ts-morph":"^27.0.2","typescript":"^5.9.3","@types/node":"^25.2.0","@biomejs/biome":"^2.3.14","@vitest/coverage-v8":"4.0.18","@types/google-apps-script":"^2.0.8","@typescript/native-preview":"7.0.0-dev.20260205.1"},"peerDependencies":{"vitest":"^4"},"_npmOperationalInternal":{"tmp":"tmp/vitest-plugin-gas-mock_0.1.0_1770522203690_0.286791052088049","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@ciderjs/vitest-plugin-gas-mock","version":"0.1.1","keywords":["vitest","gas","google-apps-script"],"author":{"name":"ciderjs/luth"},"license":"MIT","_id":"@ciderjs/vitest-plugin-gas-mock@0.1.1","maintainers":[{"name":"luth","email":"cider6482+npm@gmail.com"}],"homepage":"https://github.com/luthpg/vitest-plugin-gas-mock#readme","bugs":{"url":"https://github.com/luthpg/vitest-plugin-gas-mock/issues"},"dist":{"shasum":"6b47b273753e813c72b47f8c7c8853ce8b1bcfe6","tarball":"https://registry.npmjs.org/@ciderjs/vitest-plugin-gas-mock/-/vitest-plugin-gas-mock-0.1.1.tgz","fileCount":16,"integrity":"sha512-QQqZfYn5B+hrTDcuaN2PB8nUybCSZ5q55vClbu33iY3Z+OxFIabVuu4QK6A0UoNgq2QDZ0ex6KZObvt+URnzPQ==","signatures":[{"sig":"MEYCIQCBsJokamDRdQNvYwRUBupG7xIFayXmbGOVyw4vbSy2pwIhALlxQH4/NX6OjwQoujFoNSysI6iI5uOgHvWoP36njOzo","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ciderjs%2fvitest-plugin-gas-mock@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":881510},"main":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./setup":{"types":"./dist/setup.d.ts","import":"./dist/setup.mjs","require":"./dist/setup.cjs"}},"gitHead":"840e48c5383e75f665f6b4edcfb3d7b9e26a02d9","scripts":{"lint":"biome ci","test":"pnpm generate && vitest run --coverage","build":"pnpm generate && unbuild -c","check":"biome check --write","prepare":"pnpm generate","generate":"jiti ./generator/index.ts","typecheck":"tsc --noEmit","all-checks":"pnpm lint && pnpm typecheck && pnpm test && pnpm build"},"_npmUser":{"name":"luth","email":"cider6482+npm@gmail.com"},"repository":{"url":"git+ssh://git@github.com/luthpg/vitest-plugin-gas-mock.git","type":"git"},"_npmVersion":"10.8.2","description":"Vitest plugin to mock Google Apps Script environment","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.28.2","devDependencies":{"jiti":"^2.6.1","vitest":"^4.0.18","unbuild":"^3.6.1","ts-morph":"^27.0.2","typescript":"^5.9.3","@types/node":"^25.2.0","@biomejs/biome":"^2.3.14","@vitest/coverage-v8":"4.0.18","@types/google-apps-script":"^2.0.8","@typescript/native-preview":"7.0.0-dev.20260205.1"},"peerDependencies":{"vitest":"^4"},"_npmOperationalInternal":{"tmp":"tmp/vitest-plugin-gas-mock_0.1.1_1770536856526_0.5528010771988296","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@ciderjs/vitest-plugin-gas-mock","version":"0.2.0","description":"Vitest plugin to mock Google Apps Script environment","main":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./setup":{"types":"./dist/setup.d.ts","import":"./dist/setup.mjs","require":"./dist/setup.cjs"}},"scripts":{"all-checks":"pnpm lint && pnpm typecheck && pnpm test && pnpm build","lint":"biome ci","check":"biome check --write","typecheck":"tsc --noEmit","generate":"jiti ./generator/index.ts","build":"pnpm generate && unbuild -c","test":"pnpm generate && vitest --typecheck --run && vitest run --coverage","prepare":"pnpm generate"},"keywords":["vitest","gas","google-apps-script"],"author":{"name":"ciderjs/luth"},"license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/luthpg/vitest-plugin-gas-mock.git"},"bugs":{"url":"https://github.com/luthpg/vitest-plugin-gas-mock/issues"},"packageManager":"pnpm@10.28.2","devDependencies":{"@biomejs/biome":"^2.3.14","@types/google-apps-script":"^2.0.8","@types/node":"^25.2.0","@typescript/native-preview":"7.0.0-dev.20260205.1","@vitest/coverage-v8":"4.0.18","jiti":"^2.6.1","ts-morph":"^27.0.2","typescript":"^5.9.3","unbuild":"^3.6.1","vitest":"^4.0.18"},"peerDependencies":{"vitest":"^4"},"_id":"@ciderjs/vitest-plugin-gas-mock@0.2.0","gitHead":"cf0633145cb00d9e2736dd0b4b88c07b0a0dd20e","homepage":"https://github.com/luthpg/vitest-plugin-gas-mock#readme","_nodeVersion":"20.20.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-1iXY+OZP2NfRU+zXhaEpf+FeOeNReoKF2GESmC3E2OMS4pYIi0EtLKrRNGL6TluNAJtkQsb0JyhejZKQUdyN9A==","shasum":"22cd2102d83f6b3eecbe4fcfca7cc1b543fde0ef","tarball":"https://registry.npmjs.org/@ciderjs/vitest-plugin-gas-mock/-/vitest-plugin-gas-mock-0.2.0.tgz","fileCount":16,"unpackedSize":887911,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ciderjs%2fvitest-plugin-gas-mock@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEsiWKDfEOvFQ0fxZgHjeCL4XSQZnOlfy2jY/4EbzsB0AiBP/E7fvHb9c0H5C9l96HpLvDQXitZZZrHcupAhmYzCKg=="}]},"_npmUser":{"name":"luth","email":"cider6482+npm@gmail.com"},"directories":{},"maintainers":[{"name":"luth","email":"cider6482+npm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vitest-plugin-gas-mock_0.2.0_1771469203836_0.42374139721936244"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-05T13:38:44.218Z","modified":"2026-02-19T02:46:44.376Z","0.0.1":"2026-02-05T13:38:44.540Z","0.0.2":"2026-02-07T16:38:25.722Z","0.1.0":"2026-02-08T03:43:23.865Z","0.1.1":"2026-02-08T07:47:36.678Z","0.2.0":"2026-02-19T02:46:44.021Z"},"bugs":{"url":"https://github.com/luthpg/vitest-plugin-gas-mock/issues"},"author":{"name":"ciderjs/luth"},"license":"MIT","homepage":"https://github.com/luthpg/vitest-plugin-gas-mock#readme","keywords":["vitest","gas","google-apps-script"],"repository":{"type":"git","url":"git+ssh://git@github.com/luthpg/vitest-plugin-gas-mock.git"},"description":"Vitest plugin to mock Google Apps Script environment","maintainers":[{"name":"luth","email":"cider6482+npm@gmail.com"}],"readme":"# @ciderjs/vitest-plugin-gas-mock\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![npm version](https://img.shields.io/npm/v/@ciderjs/vitest-plugin-gas-mock.svg)](https://www.npmjs.com/package/@ciderjs/vitest-plugin-gas-mock)\n[![NPM Downloads](https://img.shields.io/npm/dw/@ciderjs/vitest-plugin-gas-mock)](https://www.npmjs.com/package/@ciderjs/vitest-plugin-gas-mock)\n[![GitHub issues](https://img.shields.io/github/issues/luthpg/vitest-plugin-gas-mock.svg)](https://github.com/luthpg/vitest-plugin-gas-mock/issues)\n\nVitest plugin to mock Google Apps Script (GAS) environment.\n\n## Features\n\n- **Automatic Mocking**: Dynamically generates mocks based on official `@types/google-apps-script`.\n- **Enum Support**: Includes support for GAS enums (e.g., `SpreadsheetApp.BorderStyle.SOLID`).\n- **Method Chaining**: Supports GAS fluent APIs (e.g., `SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1')`).\n- **Global Injection**: Automatically injects mocks into the global scope in tests.\n- **`mockChain` Helper**: Easily override return values for complex method paths.\n\n## Installation\n\n```bash\npnpm add -D @ciderjs/vitest-plugin-gas-mock\n```\n\n## Setup\n\nAdd the plugin to your `vitest.config.ts`:\n\n```typescript\nimport { defineConfig } from 'vitest/config';\nimport { mockGas } from '@ciderjs/vitest-plugin-gas-mock';\n\nexport default defineConfig({\n  plugins: [mockGas()],\n  test: {\n    globals: true, // Required for global injection\n  },\n});\n```\n\n## Usage\n\n### Basic Usage\n\nOnce configured, GAS services like `SpreadsheetApp`, `DriveApp`, etc., are available globally in your tests.\n\n```typescript\nimport { it, expect } from 'vitest';\n\nit('should mock SpreadsheetApp', () => {\n  const ss = SpreadsheetApp.getActiveSpreadsheet();\n  expect(ss).toBeDefined();\n  \n  const sheet = ss.getSheetByName('MySheet');\n  expect(sheet).toBeDefined();\n});\n```\n\n### Overriding Return Values with `mockChain`\n\nUse `mockChain` to set return values for specific method call paths.\n\n```typescript\nimport { it, expect } from 'vitest';\nimport { mockChain } from '@ciderjs/vitest-plugin-gas-mock';\n\nit('should return specific value for a chain', () => {\n  const mockValue = \"Hello from mock\";\n  \n  // Set the override\n  mockChain(\n    'SpreadsheetApp.getActiveSpreadsheet.getName', \n    mockValue\n  );\n\n  const name = SpreadsheetApp.getActiveSpreadsheet().getName();\n  expect(name).toBe(mockValue);\n});\n```\n\n### Dynamic Return Values\n\nYou can pass a callback function to `mockChain` to determine the return value dynamically based on arguments.\n\n```typescript\nmockChain('SpreadsheetApp.getActiveSpreadsheet.getSheetByName', (name) => {\n  if (name === 'Missing') {\n    return null;\n  }\n  // You can return a partial object (DeepPartial),\n  // so you don't need to implement all methods like `activate`, `copy`, etc.\n  return {\n    getName: () => name,\n  };\n});\n```\n\n### Type Safety\n\nThe `mockChain` helper provides strict type inference:\n\n- **Path Validation**: The path string (e.g., `'SpreadsheetApp.getActiveSpreadsheet'`) is validated against GAS types.\n- **Callback Arguments**: Arguments in the callback function are automatically typed.\n- **Return Type**: The return value is checked against the expected GAS type (supports `DeepPartial` for easier mocking).\n\n## How it works\n\nThe plugin performs the following steps:\n\n1. **Analyze**: Parses GAS type definitions to build a map of classes, methods, and return types.\n2. **Generate**: Creates a runtime map that identifies which methods are \"chainable\" (i.e., return another GAS class).\n3. **Inject**: Uses a Proxy-based factory to create spies (`vi.fn()`) that automatically return new proxies for chainable methods.\n\n## Scripts\n\n- `pnpm generate`: Refreshes the internal GAS API map (runs automatically before build/test).\n- `pnpm build`: Builds the plugin.\n- `pnpm test`: Runs integration and unit tests.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}