{"_id":"@civitas-cerebrum/context-store","_rev":"2-12e419719a53292ef6e1dc4374df08da","name":"@civitas-cerebrum/context-store","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@civitas-cerebrum/context-store","version":"0.0.1","keywords":["testing","e2e","context","state-management","automation","playwright","cypress","webdriverio","bdd","scenario-state"],"author":{"name":"Umut Ay Bora"},"license":"MIT","_id":"@civitas-cerebrum/context-store@0.0.1","maintainers":[{"name":"umutayb","email":"umutaybora@gmail.com"}],"homepage":"https://github.com/Umutayb/js-context-store#readme","bugs":{"url":"https://github.com/Umutayb/js-context-store/issues"},"dist":{"shasum":"80ca493e21247c9e62732b18972824b1bb488452","tarball":"https://registry.npmjs.org/@civitas-cerebrum/context-store/-/context-store-0.0.1.tgz","fileCount":6,"integrity":"sha512-1UdUXOeLizwy7N7aSin1gVK3zLFW6WQdH63H+HWWP+0p6mDSL8h+YTWhQ6HQbUG1Mu2tt8pfsT8U7ygUKcSLxQ==","signatures":[{"sig":"MEUCICLfh1ITvdF963wMWtw2dw4UShO/ZjpFfn+waesK+96lAiEA/UAfmX5zG3/IUCnhgqssYeq6PbQrEgLuIIazRAjeBEo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@civitas-cerebrum%2fcontext-store@0.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":9775},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"48c532725a9b4f84b943c2e771c7eaa453638e0f","scripts":{"test":"vitest run","build":"npm run clean && tsc","clean":"rm -rf dist","prepublishOnly":"npm run build"},"_npmUser":{"name":"umutayb","email":"umutaybora@gmail.com"},"repository":{"url":"git+ssh://git@github.com/Umutayb/js-context-store.git","type":"git"},"_npmVersion":"11.9.0","description":"A lightweight, strongly-typed, and framework-agnostic utility for managing test state and contextual data across test steps.","directories":{},"_nodeVersion":"24.14.0","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.6.1","typescript":"^5.0.0","@types/node":"^20.0.0"},"_npmOperationalInternal":{"tmp":"tmp/context-store_0.0.1_1773417142663_0.2927489653417179","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@civitas-cerebrum/context-store","version":"0.0.2","description":"A lightweight, strongly-typed, and framework-agnostic utility for managing test state and contextual data across test steps.","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"clean":"rm -rf dist","build":"npm run clean && tsc","test":"vitest run","prepublishOnly":"npm run build"},"devDependencies":{"@types/node":"^20.0.0","typescript":"^5.0.0","vitest":"^1.6.1"},"keywords":["testing","e2e","context","state-management","automation","playwright","cypress","webdriverio","bdd","scenario-state"],"publishConfig":{"access":"public","provenance":true},"repository":{"type":"git","url":"git+ssh://git@github.com/Umutayb/js-context-store.git"},"author":{"name":"Umut Ay Bora"},"license":"MIT","gitHead":"422c0b99b037a60464386dc693f3ecceb0824693","_id":"@civitas-cerebrum/context-store@0.0.2","bugs":{"url":"https://github.com/Umutayb/js-context-store/issues"},"homepage":"https://github.com/Umutayb/js-context-store#readme","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-v5j/L1+ngS1hge5mmNtsIqby9c6+LPivlGn/VqDAzg06wAtNQ1uEy4bSTI4zyNovEh03MeNEzSNcz6Ob+2N40A==","shasum":"b5ac5489d049d4d12a869db1129de3e4e730fddf","tarball":"https://registry.npmjs.org/@civitas-cerebrum/context-store/-/context-store-0.0.2.tgz","fileCount":6,"unpackedSize":10078,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@civitas-cerebrum%2fcontext-store@0.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCBC8rExiY12Mrc4JcOA9wBwMYEmsbatO7Vzcx8QJ0Y9gIgRoDxfGthFph3fs5U829osXsu3+qAfsFGG/0BmHjXTTw="}]},"_npmUser":{"name":"umutayb","email":"umutaybora@gmail.com"},"directories":{},"maintainers":[{"name":"umutayb","email":"umutaybora@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/context-store_0.0.2_1773418157875_0.48451707586754167"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-13T15:52:22.604Z","modified":"2026-03-13T16:09:18.337Z","0.0.1":"2026-03-13T15:52:22.847Z","0.0.2":"2026-03-13T16:09:18.024Z"},"bugs":{"url":"https://github.com/Umutayb/js-context-store/issues"},"author":{"name":"Umut Ay Bora"},"license":"MIT","homepage":"https://github.com/Umutayb/js-context-store#readme","keywords":["testing","e2e","context","state-management","automation","playwright","cypress","webdriverio","bdd","scenario-state"],"repository":{"type":"git","url":"git+ssh://git@github.com/Umutayb/js-context-store.git"},"description":"A lightweight, strongly-typed, and framework-agnostic utility for managing test state and contextual data across test steps.","maintainers":[{"name":"umutayb","email":"umutaybora@gmail.com"}],"readme":"# @civitas-cerebrum/context-store\n\nA lightweight, strongly-typed, and framework-agnostic utility for managing test state and contextual data across test steps.\n\nWhen writing end-to-end (E2E) or integration tests, you often need to pass data generated in one step (like a dynamic ID, an extracted date, or an email address) to subsequent steps. `context-store` replaces messy plain JavaScript objects with a robust map-based API, providing safe type-casting, default values, and clean iteration.\n\n## Installation\n\n```bash\nnpm i @civitas-cerebrum/context-store\n```\n\n## Why use context-store?\n\n* **Type Safety:** Built-in TypeScript support ensures you know exactly what data you are retrieving.\n* **Safe Parsing:** Methods like `getBoolean` and `getNumber` gracefully handle missing or malformed data with reliable fallbacks.\n* **Framework Agnostic:** Works perfectly with Playwright, Cypress, WebdriverIO, Jest, Mocha, or Cucumber.\n* **Clean Iteration:** Easily loop through stored key-value pairs for bulk assertions.\n\n## Quick Start\n\n```typescript\nimport { ContextStore } from '@civitas-cerebrum/context-store';\n\n// Instantiate a new store for your test\nconst context = new ContextStore();\n\n// Store data during a step\ncontext.put('UserEmail', 'test@example.com');\ncontext.put('IsSubscribed', true);\ncontext.put('RetryCount', '3'); // Note: Stored as a string\n\n// Retrieve data safely in later steps\nconst email = context.get('UserEmail');\nconst isSubscribed = context.getBoolean('IsSubscribed');\nconst retries = context.getNumber('RetryCount', 0); // Safely parsed to a number!\n\nconsole.log(email); // 'test@example.com'\n\n```\n\n## API Reference\n\n| Method | Description | Example |\n| --- | --- | --- |\n| **`put(key, value)`** | Associates a value with a specific key. Ignores null/undefined inputs. | `context.put('id', 123);` |\n| **`get<T>(key, default?)`** | Retrieves a value, optionally falling back to a default if the key is missing. | `context.get<string>('name', 'N/A');` |\n| **`getBoolean(key, default?)`** | Returns `true` if the stored value is a boolean true or the string `\"true\"`. | `context.getBoolean('isActive', false);` |\n| **`getNumber(key, default?)`** | Parses and returns the value as a number. Falls back to default if parsing fails. | `context.getNumber('price', 0);` |\n| **`has(key)`** | Returns `true` if the store contains the specified key. | `context.has('token');` |\n| **`merge(...sources)`** | Merges properties from records or other Maps into the current store. | `context.merge({ a: 1, b: 2 });` |\n| **`entries()`** | Returns an array of `[key, value]` pairs, perfect for loops and assertions. | `for (const [k, v] of context.entries())` |\n| **`items()`** | Returns a `Set` of all keys currently in the store. | `context.items();` |\n| **`remove(key)`** | Deletes a specific entry from the store. | `context.remove('temporaryId');` |\n| **`clear()`** | Wipes all data from the store. | `context.clear();` |\n\n## Advanced: Playwright Fixture Integration\n\nInstead of instantiating `ContextStore` manually inside every single test, you can inject it automatically using Playwright Fixtures.\n\n**1. Define the fixture (`fixtures.ts`):**\n\n```typescript\nimport { test as base } from '@playwright/test';\nimport { ContextStore } from '@civitas-cerebrum/context-store';\n\ntype MyFixtures = {\n  context: ContextStore;\n};\n\nexport const test = base.extend<MyFixtures>({\n  context: async ({}, use) => {\n    // Creates a fresh store for every test run\n    const store = new ContextStore();\n    await use(store);\n  },\n});\n```\n\n**2. Use it in your tests (`example.spec.ts`):**\n\n```typescript\nimport { test } from './fixtures';\n\ntest('My test using the context store', async ({ page, context }) => {\n  await test.step('Generate Data', async () => {\n    context.put('orderId', 'ORD-999');\n  });\n\n  await test.step('Verify Data', async () => {\n    const orderId = context.get('orderId');\n    // Proceed with assertions...\n  });\n});\n```\n\n## License\n\nMIT\n\n```","readmeFilename":"README.md"}