App Builder Testing Generate and run Jest tests for Adobe App Builder actions and React Spectrum UI components. Scaffolds unit tests, integration tests, component tests, and mock helpers for Adobe SDKs. Pattern Quick-Reference Pick the template or reference that matches the user's intent. Default to for generic test requests. | User wants | Reference | Template / Asset | | --- | --- | --- | | Unit test for an existing action | references/testing-patterns.md | assets/unit-test-template.js | | Integration test against deployed action | references/testing-patterns.md | assets/integration-test-te…

: '\u003crootDir>/test/__mocks__/@adobe/aio-sdk.js' }\n ```\n\n## Tests pass locally but fail in CI\n\n**Symptom:** `npm test` passes on your machine but fails in GitHub Actions / Jenkins.\n\n**Causes & fixes:**\n\n1. **Node version mismatch** — CI may use a different Node version. Pin it in your workflow: `node-version: '18'`. Run `node -v` locally to compare.\n2. **Missing devDependencies** — CI runs `npm ci`, which is stricter than `npm install`. Ensure all test deps are in `devDependencies`, not installed globally.\n3. **Environment variables missing** — Tests that read `process.env` values from a local `.env` file won't find them in CI. Pass them as secrets or mock `process.env` in tests:\n ```js\n beforeEach(() => { process.env.API_KEY = 'test-key'; });\n afterEach(() => { delete process.env.API_KEY; });\n ```\n\n## Component tests render blank — no Spectrum components visible\n\n**Symptom:** `render(\u003cMyComponent />)` produces an empty container. Queries return `null`.\n\n> **This is the #1 React Spectrum testing gotcha.**\n\n**Causes & fixes:**\n\n1. **Missing `\u003cProvider>` wrapper** — React Spectrum components render nothing without `\u003cProvider theme={defaultTheme}>`. Use the `renderWithSpectrum()` helper from `assets/component-test-template.js`:\n ```js\n const { renderWithSpectrum } = require('./helpers');\n const { screen } = renderWithSpectrum(\u003cMyComponent />);\n ```\n2. **Missing CSS transform** — Jest cannot process `.css` imports. Add to `jest.config.js`:\n ```js\n transform: { '\\\\.css

App Builder Testing Generate and run Jest tests for Adobe App Builder actions and React Spectrum UI components. Scaffolds unit tests, integration tests, component tests, and mock helpers for Adobe SDKs. Pattern Quick-Reference Pick the template or reference that matches the user's intent. Default to for generic test requests. | User wants | Reference | Template / Asset | | --- | --- | --- | | Unit test for an existing action | references/testing-patterns.md | assets/unit-test-template.js | | Integration test against deployed action | references/testing-patterns.md | assets/integration-test-te…

: 'jest-transform-stub' }\n ```\n Or use `moduleNameMapper: { '\\\\.css

App Builder Testing Generate and run Jest tests for Adobe App Builder actions and React Spectrum UI components. Scaffolds unit tests, integration tests, component tests, and mock helpers for Adobe SDKs. Pattern Quick-Reference Pick the template or reference that matches the user's intent. Default to for generic test requests. | User wants | Reference | Template / Asset | | --- | --- | --- | | Unit test for an existing action | references/testing-patterns.md | assets/unit-test-template.js | | Integration test against deployed action | references/testing-patterns.md | assets/integration-test-te…

: '\u003crootDir>/test/__mocks__/styleMock.js' }` with a file that exports `{}`.\n\n## Mock does not intercept SDK calls\n\n**Symptom:** Tests hit real SDKs, throw auth errors, or return unexpected data instead of mock values.\n\n**Causes & fixes:**\n\n1. **`jest.mock()` after import** — The mock declaration must appear before the `require()` of the module under test. Move it to the top of the file:\n ```js\n jest.mock('@adobe/aio-sdk'); // ← first\n const action = require('../index.js'); // ← second\n ```\n2. **Mock path mismatch** — The string in `jest.mock('...')` must exactly match the string in the action's `require('...')`. Check for `@adobe/aio-sdk` vs destructured sub-packages.\n3. **Mock not reset between tests** — Stale mock state bleeds across tests. Add:\n ```js\n beforeEach(() => jest.clearAllMocks());\n ```\n\n## `waitFor` times out in component tests\n\n**Symptom:** `TestingLibraryElementError: Timed out in waitFor` after 1 000 ms.\n\n**Causes & fixes:**\n\n1. **Async operation never resolves** — The mock for your API call is not returning a resolved promise. Fix:\n ```js\n fetchData.mockResolvedValue({ items: [{ id: 1, name: 'Test' }] });\n ```\n2. **State update not triggering re-render** — Ensure your component calls `setState` (or a state hook) after the async operation completes. If using `useEffect`, verify the dependency array.\n3. **Timeout too short** — For heavy components, increase the timeout:\n ```js\n await waitFor(() => expect(screen.getByText('Done')).toBeInTheDocument(), { timeout: 5000 });\n ```\n\n## Test coverage is low despite many tests\n\n**Symptom:** Jest coverage report shows \u003c 80 % on lines or branches even though tests pass.\n\n**Causes & fixes:**\n\n1. **Error and edge paths not tested** — Coverage counts executed lines. Add tests for 400 (bad input) and 500 (SDK failure) branches, not just the happy path.\n2. **`collectCoverageFrom` excludes files** — Check `jest.config.js`:\n ```js\n collectCoverageFrom: ['src/**/*.js', '!src/**/index.js']\n ```\n Make sure the glob includes the files you expect.\n3. **Mocked modules show 0 % coverage** — This is expected. `jest.mock()` replaces the real module, so its lines are never executed. Focus coverage on *your* code, not third-party SDKs.\n\n## Integration test fails with 401 against deployed action\n\n**Symptom:** `fetch('https://\u003cnamespace>.adobeio-static.net/...')` returns `{ statusCode: 401 }`.\n\n**Causes & fixes:**\n\n1. **IMS token expired** — Regenerate with `aio login`. Tokens are short-lived; refresh before each test session.\n2. **Missing `Authorization` header** — Actions with `require-adobe-auth: true` in `ext.config.yaml` need a Bearer token:\n ```js\n const resp = await fetch(actionUrl, {\n headers: { Authorization: `Bearer ${token}` }\n });\n ```\n3. **Wrong action URL** — Verify namespace and package name match `aio runtime namespace get`. The URL pattern is `https://\u003cnamespace>.adobeio-static.net/api/v1/web/\u003cpackage>/\u003caction>`.\n\n## `aio app test` runs but finds no tests\n\n**Symptom:** `Test Suites: 0 total` — Jest exits without running anything.\n\n**Causes & fixes:**\n\n1. **Test file naming** — Jest looks for `*.test.js` or `*.spec.js` by default. Rename files to match.\n2. **Test directory not in `roots`** — If your tests live outside the default path, add to `jest.config.js`:\n ```js\n roots: ['\u003crootDir>/test']\n ```\n3. **`testMatch` pattern excludes your files** — Check for overly restrictive patterns:\n ```js\n testMatch: ['**/test/**/*.test.js'] // make sure this matches your structure\n ```\n","content_type":"text/markdown; charset=utf-8","language":"markdown","size":5902,"content_sha256":"3e57bdee705456e2aa3b8436c791aef2b424adb767f13008019cbbc9cac5d60f"},{"filename":"references/mock-catalog.md","content":"# Mock Catalog — Adobe SDK Mocks for Jest\n\nReady-to-use `jest.mock()` setups for all common Adobe App Builder SDK dependencies. Copy the relevant mock block into your test file **before** `require()`-ing the action under test.\n\n## @adobe/aio-lib-state\n\nState SDK for ephemeral key-value storage.\n\n```javascript\nconst mockStateInstance = {\n get: jest.fn().mockResolvedValue({ value: 'stored-data', expiration: null }),\n put: jest.fn().mockResolvedValue('key'),\n delete: jest.fn().mockResolvedValue('key'),\n deleteAll: jest.fn().mockResolvedValue(true),\n list: jest.fn().mockResolvedValue({ keys: ['key1', 'key2'], cursor: null }),\n};\njest.mock('@adobe/aio-lib-state', () => ({\n init: jest.fn().mockResolvedValue(mockStateInstance),\n}));\n```\n\n**Common assertions:**\n- `expect(mockStateInstance.get).toHaveBeenCalledWith('expected-key')`\n- `expect(mockStateInstance.put).toHaveBeenCalledWith('key', 'value', { ttl: 3600 })`\n\n**Pitfalls:**\n- `get()` returns `{ value, expiration }`, not the raw value. Asserting against raw string fails.\n- `init()` requires no args in tests but needs credentials in production — always mock it.\n\n## @adobe/aio-lib-files\n\nFiles SDK for cloud file storage.\n\n```javascript\nconst mockFilesInstance = {\n read: jest.fn().mockResolvedValue(Buffer.from('file-content')),\n write: jest.fn().mockResolvedValue('file-path'),\n delete: jest.fn().mockResolvedValue(true),\n list: jest.fn().mockResolvedValue([{ name: 'file.txt', size: 100 }]),\n generatePresignURL: jest.fn().mockResolvedValue('https://storage.example.com/presigned'),\n copy: jest.fn().mockResolvedValue('dest-path'),\n};\njest.mock('@adobe/aio-lib-files', () => ({\n init: jest.fn().mockResolvedValue(mockFilesInstance),\n}));\n```\n\n**Common assertions:**\n- `expect(mockFilesInstance.write).toHaveBeenCalledWith('path/file.txt', expect.any(Buffer))`\n- `expect(mockFilesInstance.generatePresignURL).toHaveBeenCalledWith('path/file.txt', { expiryInSeconds: 600 })`\n\n**Pitfalls:**\n- `read()` returns a Buffer, not a string. Use `.toString()` in assertions if comparing text content.\n- `generatePresignURL` options include `expiryInSeconds` and `permissions` ('r' or 'rwd').\n\n## @adobe/aio-lib-events\n\nEvents SDK for publishing and consuming Adobe I/O Events.\n\n```javascript\nconst mockEventsInstance = {\n publishEvent: jest.fn().mockResolvedValue('OK'),\n getEventsFromJournal: jest.fn().mockResolvedValue({\n events: [{ event_id: 'evt-1', event: { key: 'value' } }],\n _page: { next: null },\n }),\n getEventsObservableFromJournal: jest.fn(),\n};\njest.mock('@adobe/aio-lib-events', () => ({\n init: jest.fn().mockResolvedValue(mockEventsInstance),\n}));\n```\n\n**Common assertions:**\n- `expect(mockEventsInstance.publishEvent).toHaveBeenCalledWith(expect.objectContaining({ data: expect.any(Object) }))`\n\n**Pitfalls:**\n- `init()` requires `orgId`, `apiKey`, `accessToken`, and `providerId` in production — all mocked away in tests.\n- Journal responses have `_page.next` for pagination — mock it as `null` for simple tests.\n\n## @adobe/aio-lib-db\n\nDatabase SDK for MongoDB-compatible document storage.\n\n```javascript\nconst mockCollection = {\n insertOne: jest.fn().mockResolvedValue({ insertedId: 'mock-id' }),\n findOne: jest.fn().mockResolvedValue({ _id: 'mock-id', name: 'doc' }),\n find: jest.fn().mockReturnValue({\n toArray: jest.fn().mockResolvedValue([{ _id: '1', name: 'doc1' }])\n }),\n updateOne: jest.fn().mockResolvedValue({ modifiedCount: 1 }),\n deleteOne: jest.fn().mockResolvedValue({ deletedCount: 1 }),\n aggregate: jest.fn().mockReturnValue({\n toArray: jest.fn().mockResolvedValue([])\n }),\n};\n\nconst mockDb = {\n collection: jest.fn().mockReturnValue(mockCollection),\n};\n\njest.mock('@adobe/aio-lib-db', () => ({\n init: jest.fn().mockResolvedValue(mockDb),\n}));\n```\n\n**Common assertions:**\n- `expect(mockCollection.findOne).toHaveBeenCalledWith({ _id: 'expected-id' })`\n- `expect(mockCollection.insertOne).toHaveBeenCalledWith(expect.objectContaining({ name: 'doc' }))`\n- `expect(mockCollection.find).toHaveBeenCalledWith(expect.objectContaining({ selector: expect.any(Object) }))`\n\n**Pitfalls:**\n- `find()` and `aggregate()` return cursors — call `.toArray()` to get results. Mock both the cursor and `toArray()`.\n- `collection()` must be called to get a collection handle before any CRUD operation.\n- `init()` requires credentials in production — always mock it in unit tests.\n\n## @adobe/aio-sdk (Combined Entry Point)\n\nThe combined SDK re-exports Core (Logger), State, Files, Events, and other libs.\n\n```javascript\njest.mock('@adobe/aio-sdk', () => ({\n Core: {\n Logger: jest.fn().mockReturnValue({\n info: jest.fn(),\n warn: jest.fn(),\n error: jest.fn(),\n debug: jest.fn(),\n }),\n },\n State: { init: jest.fn().mockResolvedValue({ get: jest.fn(), put: jest.fn() }) },\n Files: { init: jest.fn().mockResolvedValue({ read: jest.fn(), write: jest.fn() }) },\n Events: { init: jest.fn().mockResolvedValue({ publishEvent: jest.fn() }) },\n}));\n```\n\nUse this when the action imports from `@adobe/aio-sdk` directly instead of individual packages.\n\n## @adobe/aio-lib-core-logging (Logger)\n\nStandalone logger mock when not using the combined SDK.\n\n```javascript\njest.mock('@adobe/aio-lib-core-logging', () =>\n jest.fn().mockReturnValue({\n info: jest.fn(),\n warn: jest.fn(),\n error: jest.fn(),\n debug: jest.fn(),\n close: jest.fn(),\n })\n);\n```\n\n**Pitfalls:**\n- The module itself is a factory function (not an object with `init()`).\n- Logger is created with `require('@adobe/aio-lib-core-logging')('action-name', { level: 'info' })`.\n\n## node-fetch\n\nMock HTTP calls to external APIs.\n\n```javascript\njest.mock('node-fetch', () =>\n jest.fn().mockResolvedValue({\n ok: true,\n status: 200,\n json: jest.fn().mockResolvedValue({ data: 'response' }),\n text: jest.fn().mockResolvedValue('response-text'),\n headers: { get: jest.fn().mockReturnValue('application/json') },\n })\n);\n```\n\n**Common assertions:**\n- `expect(fetch).toHaveBeenCalledWith('https://api.example.com/path', expect.objectContaining({ method: 'GET' }))`\n\n**Pitfalls:**\n- Mock `ok` property — many actions check `response.ok` before parsing JSON.\n- For error testing, mock with `{ ok: false, status: 500, json: ... }`.\n\n## @adobe/exc-app (ExC Shell Context)\n\nShell SDK for Experience Cloud shell runtime context, IMS tokens, and navigation.\n\n```javascript\nconst mockRuntime = {\n ready: jest.fn(),\n done: jest.fn(),\n on: jest.fn(),\n imsToken: 'mock-ims-access-token',\n imsOrg: 'mock-ims-org-id@AdobeOrg',\n imsProfile: { name: 'Test User', email: '[email protected]' },\n locale: 'en-US',\n theme: 'light',\n};\njest.mock('@adobe/exc-app', () => ({\n register: jest.fn((cb) => { if (typeof cb === 'function') cb(mockRuntime); }),\n runtime: jest.fn(() => mockRuntime),\n}));\n```\n\n**Common assertions:**\n- `expect(mockRuntime.ready).toHaveBeenCalled()` — component called `runtime.ready()` after setup\n- `expect(mockRuntime.on).toHaveBeenCalledWith('configuration', expect.any(Function))` — component listens for config changes\n\n**Pitfalls:**\n- `register()` is called on app mount and expects a callback — the mock must invoke it synchronously or the component never initializes.\n- Components often destructure `imsToken` and `imsOrg` from runtime — ensure both are present in the mock.\n\nSee `assets/shell-mock-helper.js` for a full reusable mock with `resetMocks()`.\n\n## @adobe/uix-guest (AEM UIX Guest SDK)\n\nGuest SDK for AEM UI extensibility — used by extension components to connect to the AEM host.\n\n```javascript\nconst mockSharedContext = {\n aemHost: 'https://author-p12345-e67890.adobeaemcloud.com',\n imsOrg: 'mock-ims-org-id@AdobeOrg',\n imsToken: 'mock-ims-access-token',\n apiKey: 'mock-api-key',\n locale: 'en-US',\n theme: 'light',\n};\nconst mockGuestConnection = {\n sharedContext: {\n get: jest.fn((key) => mockSharedContext[key]),\n getAll: jest.fn(() => mockSharedContext),\n },\n host: {\n modal: { showUrl: jest.fn(), close: jest.fn() },\n toasts: { display: jest.fn() },\n },\n};\njest.mock('@adobe/uix-guest', () => ({\n register: jest.fn(() => Promise.resolve(mockGuestConnection)),\n attach: jest.fn(() => Promise.resolve(mockGuestConnection)),\n}));\n```\n\n**Common assertions:**\n- `expect(mockGuestConnection.sharedContext.get).toHaveBeenCalledWith('imsToken')` — component reads IMS token from shared context\n- `expect(mockGuestConnection.host.modal.showUrl).toHaveBeenCalledWith(expect.objectContaining({ src: expect.any(String) }))` — component opens a modal\n\n**Pitfalls:**\n- `register()` and `attach()` return Promises — component code must `await` them. The mock resolves immediately but async tests still need `waitFor()` or `findBy*`.\n- `sharedContext.get()` returns individual values by key; `sharedContext.getAll()` returns the full object. Mock both.\n- Extension components often use `attach()` for panels and `register()` for top-level extensions — mock the one your component uses.\n\nSee `assets/uix-guest-mock-helper.js` for a full reusable mock with `resetMocks()` and `getCapturedRegistration()`.\n","content_type":"text/markdown; charset=utf-8","language":"markdown","size":9085,"content_sha256":"073499822d89ba62fed81675355d87c0beb066f9f60dd1ba7b9c050d02a98c13"},{"filename":"references/testing-patterns.md","content":"# Testing Patterns for App Builder Actions\n\n## Unit Test Pattern\n\nMock all SDK dependencies, test the `main()` export with various parameter combinations, and assert the response shape `{ statusCode, body }`.\n\n### Structure\n\n```javascript\nconst action = require('\u003cpath-to-action>/index.js');\n\n// Mock all SDK dependencies BEFORE requiring the action\njest.mock('@adobe/aio-sdk', () => ({ /* see mock-catalog.md */ }));\n\ndescribe('\u003caction-name>', () => {\n beforeEach(() => jest.clearAllMocks());\n\n test('returns 200 with valid params', async () => {\n const params = {\n __ow_headers: { authorization: 'Bearer test-token' },\n LOG_LEVEL: 'info',\n // action-specific params\n };\n const result = await action.main(params);\n expect(result.statusCode).toBe(200);\n expect(result.body).toBeDefined();\n });\n\n test('returns 400 when required param missing', async () => {\n const result = await action.main({ __ow_headers: {} });\n expect(result.statusCode).toBe(400);\n expect(result.body.error).toBeDefined();\n });\n\n test('returns 500 on SDK failure', async () => {\n // Configure mock to throw\n const result = await action.main({ __ow_headers: {}, LOG_LEVEL: 'info' });\n expect(result.statusCode).toBe(500);\n });\n});\n```\n\n### Key Rules\n\n1. **Always mock before require** — `jest.mock()` is hoisted but mock factories run before module load.\n2. **Clear mocks in beforeEach** — Prevents state leaking between tests.\n3. **Test the three paths** — Success (200), bad input (400), internal error (500).\n4. **Assert response shape** — Every action returns `{ statusCode, body }`. Optionally `headers`.\n5. **Use CommonJS** — App Builder actions use `require()` / `module.exports`.\n\n## Integration Test Pattern\n\nDeploy the action to a Stage workspace, invoke it via CLI or HTTP, and assert the response matches the expected schema.\n\n### Structure\n\n```javascript\nconst { execSync } = require('child_process');\n\ndescribe('\u003caction-name> integration', () => {\n const ACTION_NAME = '\u003caction-name>';\n\n test('responds with expected schema when invoked', () => {\n const result = JSON.parse(\n execSync(`aio rt action invoke ${ACTION_NAME} --result -p key value`, {\n encoding: 'utf-8',\n })\n );\n expect(result.statusCode).toBe(200);\n expect(result.body).toHaveProperty('expectedField');\n });\n\n test('returns error for invalid input', () => {\n const result = JSON.parse(\n execSync(`aio rt action invoke ${ACTION_NAME} --result`, {\n encoding: 'utf-8',\n })\n );\n expect(result.statusCode).toBe(400);\n });\n});\n```\n\n### Key Rules\n\n1. **Requires deployed action** — Run `aio app deploy` to Stage before integration tests.\n2. **Use `--result` flag** — Returns only the action result, not activation metadata.\n3. **Test real SDK interactions** — State, Files, Events SDKs work against real services.\n4. **Separate from unit tests** — Place in `test/integration/` or use Jest `--testPathPattern`.\n5. **CI consideration** — Integration tests need workspace credentials; run in CI with secrets configured.\n\n## Contract Test Pattern\n\nRecord real Adobe API responses, replay them in tests to verify the action handles actual response shapes correctly.\n\n### Structure\n\n```javascript\nconst nock = require('nock');\nconst action = require('\u003cpath-to-action>/index.js');\n\n// Recorded response from real Adobe API\nconst RECORDED_RESPONSE = require('./fixtures/adobe-api-response.json');\n\ndescribe('\u003caction-name> contract', () => {\n beforeEach(() => jest.clearAllMocks());\n afterEach(() => nock.cleanAll());\n\n test('handles real API response shape', async () => {\n nock('https://platform.adobe.io')\n .get('/path/to/api')\n .reply(200, RECORDED_RESPONSE);\n\n const result = await action.main({ __ow_headers: {}, /* params */ });\n expect(result.statusCode).toBe(200);\n });\n});\n```\n\n### Key Rules\n\n1. **Record real responses** — Capture actual API responses as JSON fixtures.\n2. **Use nock or similar** — Intercept HTTP at the network level, not SDK level.\n3. **Update fixtures periodically** — API response shapes can change; re-record quarterly.\n4. **Test edge cases from real data** — Empty arrays, pagination tokens, error responses.\n\n## Error Scenario Testing\n\nAlways test these error conditions for every action:\n\n| Scenario | Setup | Expected |\n| --- | --- | --- |\n| Missing required params | Omit required fields from `params` | `{ statusCode: 400 }` |\n| Invalid auth | Empty or bad `__ow_headers.authorization` | `{ statusCode: 401 }` or `{ statusCode: 403 }` |\n| SDK init failure | Mock SDK `init()` to reject | `{ statusCode: 500 }` |\n| SDK operation failure | Mock SDK method (get/put/etc.) to reject | `{ statusCode: 500 }` |\n| Timeout simulation | Mock with `setTimeout` + jest.useFakeTimers | Action handles gracefully |\n| Malformed input | Send wrong types, empty strings, huge payloads | `{ statusCode: 400 }` |\n\n## Database Action Testing\n\nFor actions using `@adobe/aio-lib-db`:\n\n```javascript\nconst mockCollection = {\n insertOne: jest.fn().mockResolvedValue({ insertedId: 'mock-id' }),\n findOne: jest.fn().mockResolvedValue({ _id: 'mock-id', name: 'doc' }),\n find: jest.fn().mockReturnValue({\n toArray: jest.fn().mockResolvedValue([{ _id: '1', name: 'doc1' }])\n }),\n updateOne: jest.fn().mockResolvedValue({ modifiedCount: 1 }),\n deleteOne: jest.fn().mockResolvedValue({ deletedCount: 1 }),\n aggregate: jest.fn().mockReturnValue({\n toArray: jest.fn().mockResolvedValue([])\n }),\n};\n\nconst mockDb = {\n collection: jest.fn().mockReturnValue(mockCollection),\n};\n\njest.mock('@adobe/aio-lib-db', () => ({\n init: jest.fn().mockResolvedValue(mockDb),\n}));\n```\n\nTest pagination by mocking `find()` to return multiple pages using cursor-based iteration.\n","content_type":"text/markdown; charset=utf-8","language":"markdown","size":5784,"content_sha256":"91935bbf9bac87eb44cece10f18d71b32540f3bc415a17c9fe66c5f7ccbf7cba"}],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"App Builder Testing","type":"text"}]},{"type":"paragraph","content":[{"text":"Generate and run Jest tests for Adobe App Builder actions and React Spectrum UI components. Scaffolds unit tests, integration tests, component tests, and mock helpers for Adobe SDKs.","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Pattern Quick-Reference","type":"text"}]},{"type":"paragraph","content":[{"text":"Pick the template or reference that matches the user's intent. Default to ","type":"text"},{"text":"assets/unit-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" for generic test requests.","type":"text"}]},{"type":"table","attrs":{"layout":null},"content":[{"type":"tr","content":[{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"User wants","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Reference","type":"text"}]}]},{"type":"th","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Template / Asset","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Unit test for an existing action","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/testing-patterns.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/unit-test-template.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Integration test against deployed action","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/testing-patterns.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/integration-test-template.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Component test for React Spectrum UI","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/component-testing-patterns.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/component-test-template.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Mock ExC Shell context in tests","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/component-testing-patterns.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/shell-mock-helper.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Mock AEM extension context in tests","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/component-testing-patterns.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/uix-guest-mock-helper.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Mock State SDK in tests","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/mock-catalog.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/mock-state-sdk.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Mock Files SDK in tests","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/mock-catalog.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/mock-files-sdk.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Mock Events SDK in tests","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/mock-catalog.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/mock-events-sdk.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Mock Database SDK in tests","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/mock-catalog.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"assets/mock-database-sdk.js","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Full mock catalog (all SDKs)","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/mock-catalog.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"—","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Contract test for API interactions","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/testing-patterns.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"—","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Pre-deployment verification","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/checklist.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"—","type":"text"}]}]}]},{"type":"tr","content":[{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"Debug test failures","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"references/debugging.md","type":"text"}]}]},{"type":"td","attrs":{"colspan":1,"rowspan":1,"colwidth":null,"alignment":""},"content":[{"type":"paragraph","content":[{"text":"—","type":"text"}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Fast Path (for clear requests)","type":"text"}]},{"type":"paragraph","content":[{"text":"When the user's request maps unambiguously to a single pattern above — they name a specific test type, reference a template, or describe a use case that clearly matches one entry — skip straight to generation. Use the matched template and proceed directly.","type":"text"}]},{"type":"paragraph","content":[{"text":"Examples of fast-path triggers:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Write tests for my action\" → Read the action source, use ","type":"text"},{"text":"assets/unit-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", generate immediately","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Help me mock State SDK\" → Use ","type":"text"},{"text":"assets/mock-state-sdk.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", inject into test file","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Add integration tests\" → Use ","type":"text"},{"text":"assets/integration-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", configure for deployed action","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Run tests with coverage\" → Execute ","type":"text"},{"text":"npx jest --coverage","type":"text","marks":[{"type":"code_inline"}]},{"text":" or ","type":"text"},{"text":"aio app test","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Test my component/page/form/table\" → Read the component source, use ","type":"text"},{"text":"assets/component-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", wrap in Provider","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Mock shell context\" → Use ","type":"text"},{"text":"assets/shell-mock-helper.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", inject into test file","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Test my AEM extension component\" → Use ","type":"text"},{"text":"assets/uix-guest-mock-helper.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" + ","type":"text"},{"text":"assets/component-test-template.js","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"paragraph","content":[{"text":"If there is any ambiguity — multiple test types needed, project structure unclear, or the user hasn't specified enough — fall through to the full workflow below.","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Quick Reference","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Test directory:","type":"text","marks":[{"type":"strong"}]},{"text":" Place test files in ","type":"text"},{"text":"test/","type":"text","marks":[{"type":"code_inline"}]},{"text":" mirroring the action path, e.g., ","type":"text"},{"text":"test/actions/\u003caction-name>/index.test.js","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Jest configuration:","type":"text","marks":[{"type":"strong"}]},{"text":" App Builder projects use Jest by default. Config lives in ","type":"text"},{"text":"package.json","type":"text","marks":[{"type":"code_inline"}]},{"text":" or ","type":"text"},{"text":"jest.config.js","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Test command:","type":"text","marks":[{"type":"strong"}]},{"text":" ","type":"text"},{"text":"aio app test","type":"text","marks":[{"type":"code_inline"}]},{"text":" (wrapper) or ","type":"text"},{"text":"npx jest --coverage","type":"text","marks":[{"type":"code_inline"}]},{"text":" (direct).","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Mock pattern:","type":"text","marks":[{"type":"strong"}]},{"text":" Use ","type":"text"},{"text":"jest.mock()","type":"text","marks":[{"type":"code_inline"}]},{"text":" at the top of test files to mock Adobe SDK dependencies before importing the action.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Response shape:","type":"text","marks":[{"type":"strong"}]},{"text":" All actions return ","type":"text"},{"text":"{ statusCode, body }","type":"text","marks":[{"type":"code_inline"}]},{"text":" — assert both in every test.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Error paths:","type":"text","marks":[{"type":"strong"}]},{"text":" Always test 200 (success), 400 (bad input), and 500 (SDK failure) scenarios.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"CommonJS:","type":"text","marks":[{"type":"strong"}]},{"text":" Action test files use ","type":"text"},{"text":"require()","type":"text","marks":[{"type":"code_inline"}]},{"text":" and ","type":"text"},{"text":"module.exports","type":"text","marks":[{"type":"code_inline"}]},{"text":" (not ES imports).","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Component test directory:","type":"text","marks":[{"type":"strong"}]},{"text":" ","type":"text"},{"text":"test/web-src/components/\u003cComponentName>.test.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" (or ","type":"text"},{"text":"test/components/","type":"text","marks":[{"type":"code_inline"}]},{"text":").","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Provider wrapper:","type":"text","marks":[{"type":"strong"}]},{"text":" Always wrap in ","type":"text"},{"text":"\u003cProvider theme={defaultTheme}>","type":"text","marks":[{"type":"code_inline"}]},{"text":" — Spectrum renders nothing without it.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"ARIA selectors:","type":"text","marks":[{"type":"strong"}]},{"text":" Use ","type":"text"},{"text":"getByRole()","type":"text","marks":[{"type":"code_inline"}]},{"text":", not CSS classes — see ","type":"text"},{"text":"references/component-testing-patterns.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" selector table.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Async testing:","type":"text","marks":[{"type":"strong"}]},{"text":" Use ","type":"text"},{"text":"findBy*","type":"text","marks":[{"type":"code_inline"}]},{"text":" for data that appears async, ","type":"text"},{"text":"queryBy*","type":"text","marks":[{"type":"code_inline"}]},{"text":" for absence, ","type":"text"},{"text":"waitFor","type":"text","marks":[{"type":"code_inline"}]},{"text":" for state changes.","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Full Workflow (for ambiguous or complex requests)","type":"text"}]},{"type":"ordered_list","attrs":{"order":1,"listStyle":"number"},"content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Scan project structure","type":"text","marks":[{"type":"strong"}]},{"text":" — Check for existing ","type":"text"},{"text":"test/","type":"text","marks":[{"type":"code_inline"}]},{"text":" directory, ","type":"text"},{"text":"jest.config.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", and test scripts in ","type":"text"},{"text":"package.json","type":"text","marks":[{"type":"code_inline"}]},{"text":". Scan both ","type":"text"},{"text":"src/","type":"text","marks":[{"type":"code_inline"}]},{"text":" for actions AND ","type":"text"},{"text":"web-src/","type":"text","marks":[{"type":"code_inline"}]},{"text":" for UI components.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Identify targets to test","type":"text","marks":[{"type":"strong"}]},{"text":" — Parse ","type":"text"},{"text":"ext.config.yaml","type":"text","marks":[{"type":"code_inline"}]},{"text":" (or ","type":"text"},{"text":"app.config.yaml","type":"text","marks":[{"type":"code_inline"}]},{"text":") for declared actions and their source paths. Check ","type":"text"},{"text":"web-src/src/components/","type":"text","marks":[{"type":"code_inline"}]},{"text":" for React components.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Determine test types needed","type":"text","marks":[{"type":"strong"}]},{"text":" — Unit tests for logic, integration tests for deployed actions, contract tests for API interactions.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"**For each action:**a. Read the action source to identify SDK dependencies (State, Files, Events, Logger, etc.).b. Generate unit test using ","type":"text"},{"text":"assets/unit-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" as the base.c. Inject appropriate mocks from ","type":"text"},{"text":"references/mock-catalog.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" based on detected dependencies.d. Add error scenario tests (missing params, auth failures, SDK errors).","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"**For each UI component:**a. Read the component source to identify dependencies (shell context, UIX guest, action calls).b. Generate component test using ","type":"text"},{"text":"assets/component-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" as the base.c. Wrap all renders in ","type":"text"},{"text":"\u003cProvider theme={defaultTheme}>","type":"text","marks":[{"type":"code_inline"}]},{"text":" — Spectrum renders nothing without it.d. Inject shell mock (","type":"text"},{"text":"assets/shell-mock-helper.js","type":"text","marks":[{"type":"code_inline"}]},{"text":") or UIX guest mock (","type":"text"},{"text":"assets/uix-guest-mock-helper.js","type":"text","marks":[{"type":"code_inline"}]},{"text":") as needed.e. Add loading, success, and error state tests for async data using ","type":"text"},{"text":"findBy*","type":"text","marks":[{"type":"code_inline"}]},{"text":" and ","type":"text"},{"text":"waitFor","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Run tests","type":"text","marks":[{"type":"strong"}]},{"text":" — Execute ","type":"text"},{"text":"aio app test","type":"text","marks":[{"type":"code_inline"}]},{"text":" or ","type":"text"},{"text":"npx jest --coverage","type":"text","marks":[{"type":"code_inline"}]},{"text":" and report results.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Validate","type":"text","marks":[{"type":"strong"}]},{"text":" — Check against ","type":"text"},{"text":"references/checklist.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" before marking done.","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Example User Prompts","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Write unit tests for my generic action\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Add integration tests for my deployed action\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"My action uses State SDK — help me mock it in tests\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Run tests and show me coverage\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Set up Jest for my App Builder project\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Test my action handles errors properly\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Write component tests for my data table page\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Test my AEM extension panel component\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Help me mock shell context in my tests\"","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"\"Add tests for my React Spectrum form\"","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Inputs To Request","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Current repository path and action file locations","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Which actions need tests (or test all declared actions)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Target test types: unit, integration, contract, or all","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Whether action is deployed (needed for integration tests)","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Deliverables","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Test files in ","type":"text"},{"text":"test/","type":"text","marks":[{"type":"code_inline"}]},{"text":" matching the action directory structure","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Component test files in ","type":"text"},{"text":"test/web-src/components/","type":"text","marks":[{"type":"code_inline"}]},{"text":" for UI components","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Mock helpers for detected Adobe SDK dependencies","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Shell or UIX Guest mock helpers when components depend on context SDKs","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Jest configuration if not already present (including jsdom environment for component tests)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Coverage report from test execution","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Quality Bar","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Every action test covers at minimum: success (200), bad input (400), and SDK failure (500) paths","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Mocks are isolated per test via ","type":"text"},{"text":"beforeEach(() => jest.clearAllMocks())","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"No real SDK calls in unit tests — all external dependencies are mocked","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Tests are deterministic and can run offline (no network dependencies in unit tests)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Coverage reporting is enabled (","type":"text"},{"text":"--coverage","type":"text","marks":[{"type":"code_inline"}]},{"text":" flag)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"All component tests wrap in ","type":"text"},{"text":"\u003cProvider theme={defaultTheme}>","type":"text","marks":[{"type":"code_inline"}]},{"text":" — Spectrum renders nothing without it","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"References","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"references/testing-patterns.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" for unit, integration, and contract test patterns with annotated examples.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"references/component-testing-patterns.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" for React Spectrum component testing with Provider wrapping, ARIA selectors, and async patterns.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"references/mock-catalog.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" for mock helpers covering all Adobe SDKs (State, Files, Events, Logger, Database, Shell, UIX Guest).","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"references/checklist.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" for pre-deployment test verification.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"assets/unit-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" for Jest unit test boilerplate (CommonJS).","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"assets/integration-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" for integration test against deployed actions.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"assets/component-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" for React Spectrum component test boilerplate with ","type":"text"},{"text":"renderWithSpectrum()","type":"text","marks":[{"type":"code_inline"}]},{"text":" helper.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"assets/shell-mock-helper.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" for ExC Shell context mock (","type":"text"},{"text":"@adobe/exc-app","type":"text","marks":[{"type":"code_inline"}]},{"text":").","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"assets/uix-guest-mock-helper.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" for AEM UIX Guest mock (","type":"text"},{"text":"@adobe/uix-guest","type":"text","marks":[{"type":"code_inline"}]},{"text":").","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"assets/mock-state-sdk.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"assets/mock-files-sdk.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"assets/mock-events-sdk.js","type":"text","marks":[{"type":"code_inline"}]},{"text":", and ","type":"text"},{"text":"assets/mock-database-sdk.js","type":"text","marks":[{"type":"code_inline"}]},{"text":" for ready-to-use SDK mock setups.","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Common Issues","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Tests fail with \"Cannot find module\":","type":"text","marks":[{"type":"strong"}]},{"text":" Ensure the action path in ","type":"text"},{"text":"require()","type":"text","marks":[{"type":"code_inline"}]},{"text":" matches the actual file location. App Builder actions are typically at ","type":"text"},{"text":"src/dx-excshell-1/actions/\u003cname>/index.js","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Mocks not working:","type":"text","marks":[{"type":"strong"}]},{"text":" ","type":"text"},{"text":"jest.mock()","type":"text","marks":[{"type":"code_inline"}]},{"text":" calls must appear before ","type":"text"},{"text":"require()","type":"text","marks":[{"type":"code_inline"}]},{"text":" of the module under test. Jest hoists mock declarations but order still matters for manual mocks.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"State/Files SDK tests fail:","type":"text","marks":[{"type":"strong"}]},{"text":" These SDKs require Runtime environment for real calls. Always mock them in unit tests. Use ","type":"text"},{"text":"aio app run","type":"text","marks":[{"type":"code_inline"}]},{"text":" (not ","type":"text"},{"text":"aio app dev","type":"text","marks":[{"type":"code_inline"}]},{"text":") for integration tests that need real SDK access.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Coverage too low:","type":"text","marks":[{"type":"strong"}]},{"text":" Add tests for error branches — missing params, invalid auth headers, SDK ","type":"text"},{"text":"init()","type":"text","marks":[{"type":"code_inline"}]},{"text":" failures, and timeout scenarios.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"aio app test","type":"text","marks":[{"type":"code_inline"}]},{"text":"** vs ","type":"text"},{"text":"npx jest","type":"text","marks":[{"type":"code_inline"}]},{"text":":** ","type":"text"},{"text":"aio app test","type":"text","marks":[{"type":"code_inline"}]},{"text":" is a thin wrapper around Jest. Use ","type":"text"},{"text":"npx jest --coverage","type":"text","marks":[{"type":"code_inline"}]},{"text":" directly for more control over flags and reporters.","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Spectrum components render blank in tests:","type":"text","marks":[{"type":"strong"}]},{"text":" Missing ","type":"text"},{"text":"\u003cProvider theme={defaultTheme}>","type":"text","marks":[{"type":"code_inline"}]},{"text":" wrapper. Use ","type":"text"},{"text":"renderWithSpectrum()","type":"text","marks":[{"type":"code_inline"}]},{"text":" helper from ","type":"text"},{"text":"assets/component-test-template.js","type":"text","marks":[{"type":"code_inline"}]},{"text":".","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"ARIA role queries return null:","type":"text","marks":[{"type":"strong"}]},{"text":" Spectrum components use ARIA roles, not CSS classes. See ","type":"text"},{"text":"references/component-testing-patterns.md","type":"text","marks":[{"type":"code_inline"}]},{"text":" section g for the role reference table.","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Chaining","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Chains FROM ","type":"text"},{"text":"appbuilder-action-scaffolder","type":"text","marks":[{"type":"code_inline"}]},{"text":" (test actions after implementation)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Chains FROM ","type":"text"},{"text":"appbuilder-ui-scaffolder","type":"text","marks":[{"type":"code_inline"}]},{"text":" (test UI components after scaffolding)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Chains TO ","type":"text"},{"text":"appbuilder-cicd-pipeline","type":"text","marks":[{"type":"code_inline"}]},{"text":" (automated test execution in CI)","type":"text"}]}]}]}]},"metadata":{"date":"2026-11-02","name":"appbuilder-testing","author":"@skillopedia","source":{"stars":319,"repo_name":"skills","origin_url":"https://github.com/adobe/skills/blob/HEAD/plugins/app-builder/skills/appbuilder-testing/SKILL.md","repo_owner":"adobe","body_sha256":"a03fdf57721e61df0f5abcfd88f85b01944ff0605a6a06cce888bc1d7995d2a6","cluster_key":"9f864bb04468cfc9b9a83ae495751bfeaf5a7f2478085e14ae26c578bc381a6a","clean_bundle":{"format":"clean-skill-bundle-v1","source":"adobe/skills/plugins/app-builder/skills/appbuilder-testing/SKILL.md","text_bytes":61016,"source_commit":"7a3600673cc0caffe1b97f56d3e7e26f72deaca5","skills_sh_rank":15489,"attachment_count":16,"text_attachments":16,"attachment_storage":"skill_attachments","binary_attachments":0},"cluster_size":1,"skill_md_path":"plugins/app-builder/skills/appbuilder-testing/SKILL.md","import_metadata":{"date":"2026-11-02","author":"@skillopedia","version":"v1","category":"testing-qa","category_label":"Testing"},"exact_dupes_collapsed_into_this":0},"license":"Apache-2.0","version":"v1","category":"testing-qa","metadata":{"category":"testing"},"import_tag":"skills-sh-top20k-2026-11","description":"Generate and run tests for Adobe App Builder actions and UI components. Scaffolds Jest unit tests, integration tests against deployed actions, contract tests for Adobe API interactions, and React component tests using Testing Library. Provides mock helpers for State, Files, Events SDKs, @adobe/aio-lib-* clients, ExC Shell context (@adobe/exc-app), and UIX Guest SDK (@adobe/uix-guest). Use this skill whenever the user mentions testing App Builder actions, writing unit tests for Runtime actions, creating integration tests, mocking Adobe SDKs, setting up test fixtures, running aio app test, or wants to verify action behavior before deployment. Also trigger when users mention Jest configuration for App Builder, test coverage, CI test setup, React component test, Testing Library, UI test, Provider wrapper, test my page, test my form, test my table, test my component, mock shell context, mock extension context, debug test failures, or fix Jest errors.","allowed-tools":"Bash(aio:*) Bash(npm:*) Bash(node:*) Bash(npx:*) Read Write Edit","compatibility":"Requires aio CLI, Node.js 18+, and Jest"}},"renderedAt":1793665930970}

App Builder Testing Generate and run Jest tests for Adobe App Builder actions and React Spectrum UI components. Scaffolds unit tests, integration tests, component tests, and mock helpers for Adobe SDKs. Pattern Quick-Reference Pick the template or reference that matches the user's intent. Default to for generic test requests. | User wants | Reference | Template / Asset | | --- | --- | --- | | Unit test for an existing action | references/testing-patterns.md | assets/unit-test-template.js | | Integration test against deployed action | references/testing-patterns.md | assets/integration-test-te…