{"_id":"@commerce-klaus/sfcc-test-runtime","_rev":"3-eb449d8f3a5cdb31044c95fb36fdb8eb","name":"@commerce-klaus/sfcc-test-runtime","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.1":{"name":"@commerce-klaus/sfcc-test-runtime","version":"0.0.1","keywords":["commercecloud","mocking","salesforce","sfcc","testing"],"author":"Jens Simon <https://github.com/jenssimon>","license":"MIT","_id":"@commerce-klaus/sfcc-test-runtime@0.0.1","maintainers":[{"name":"jenssimon","email":"jens.simon80@googlemail.com"}],"homepage":"https://commerce-klaus.github.io/commerce-klaus/packages/sfcc-test-runtime/","bugs":{"url":"https://github.com/commerce-klaus/commerce-klaus/issues"},"dist":{"shasum":"f420abf0c5b8d3edd7c865383802604f57934d12","tarball":"https://registry.npmjs.org/@commerce-klaus/sfcc-test-runtime/-/sfcc-test-runtime-0.0.1.tgz","fileCount":7,"integrity":"sha512-uSgOUNc89R+4ttW+kb6UG7wcS01mNMKQkbkQ3wXYL1b3ml1aO/tqtpobFelWLdegWLFp6pNuYbB/4t5cu/E0jg==","signatures":[{"sig":"MEUCIQCSFStugkRaCaIX/uwFtrWXsLwOygfhKtNE+gwIjq4nrQIgMqVrt4PO52cXjLR/qGIcPKP+FVgZvfsr5XcD3WrGEaM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":89596},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"test":"vp test","build":"vp pack","check":"vp check"},"_npmUser":{"name":"jenssimon","email":"jens.simon80@googlemail.com"},"repository":{"url":"https://github.com/commerce-klaus/commerce-klaus","type":"git","directory":"packages/sfcc-test-runtime"},"description":"Framework-independent SFCC runtime modules and dependency mocking for local tests","directories":{},"_nodeVersion":"24.20.0","publishConfig":{"access":"public","registry":"https://registry.npmjs.org","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"latest","typescript":"npm:@typescript/typescript6@^6.0.2","@types/node":"^24"},"_npmOperationalInternal":{"tmp":"tmp/sfcc-test-runtime_0.0.1_1788438919803_0.4657781408383659","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@commerce-klaus/sfcc-test-runtime","version":"0.2.0","keywords":["commercecloud","mocking","salesforce","sfcc","testing"],"author":"Jens Simon <https://github.com/jenssimon>","license":"MIT","_id":"@commerce-klaus/sfcc-test-runtime@0.2.0","maintainers":[{"name":"jenssimon","email":"jens.simon80@googlemail.com"}],"homepage":"https://commerce-klaus.github.io/commerce-klaus/packages/sfcc-test-runtime/","bugs":{"url":"https://github.com/commerce-klaus/commerce-klaus/issues"},"dist":{"shasum":"fccc0846d7987d5780ec4f21e34fe7df4af44e33","tarball":"https://registry.npmjs.org/@commerce-klaus/sfcc-test-runtime/-/sfcc-test-runtime-0.2.0.tgz","fileCount":7,"integrity":"sha512-ItWQhDtvbw+BjgH64GuNjkHiGhasiE1/wgGoonKbkZb+iCT5pIj6ID0YTgFI05+/IL3jGyMW4s2nv3GV/R+K0Q==","signatures":[{"sig":"MEQCIFgQFFb06KmfTY84sDiiC466kXKu/FB8k8ko6AWQ67C7AiBpzNJRtr3+Hn+ezzWpSxCFpD0gJdlsImMea+7Aa/Jsvw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@commerce-klaus%2fsfcc-test-runtime@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":89596},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"test":"vp test","build":"vp pack","check":"vp check"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:d198a3a0-47d4-4e09-a562-e5693e1a66cd"}},"repository":{"url":"https://github.com/commerce-klaus/commerce-klaus","type":"git","directory":"packages/sfcc-test-runtime"},"description":"Framework-independent SFCC runtime modules and dependency mocking for local tests","directories":{},"_nodeVersion":"24.20.0","publishConfig":{"access":"public","registry":"https://registry.npmjs.org","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"latest","typescript":"npm:@typescript/typescript6@^6.0.2","@types/node":"^24"},"_npmOperationalInternal":{"tmp":"tmp/sfcc-test-runtime_0.2.0_1788510490343_0.2313280043174093","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"_id":"@commerce-klaus/sfcc-test-runtime@1.0.0","bugs":{"url":"https://github.com/commerce-klaus/commerce-klaus/issues"},"dist":{"shasum":"057d37e24fe9b8ace4cade9249100807136d9a85","tarball":"https://registry.npmjs.org/@commerce-klaus/sfcc-test-runtime/-/sfcc-test-runtime-1.0.0.tgz","fileCount":7,"integrity":"sha512-KSYq4x3b3UM9lgf2ZTyfvYeVRBGGl5Ic8h9GLhr24kxJvgeuIxUQvSL3Ktg8AzQlYIxhTjvlSHh9c1dnjAxaPA==","signatures":[{"sig":"MEQCIDUprTFlIYuru9d2mryH6+8yYd6Bw3cieaCuxNsMmRBTAiBDoQG91x5qwFT5RzdG7cGud6FZzpw5c4TlPvM88EfB/g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD13F64L4VqOzOG1cQ8eQ0AVH5DsZo2ltmjYuxp1XXKggIgIMB8vFGWB/ejkCyMMaKi5y1PKQyliBG1dfgIOTJWklw="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@commerce-klaus%2fsfcc-test-runtime@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":88709},"main":"./dist/index.cjs","name":"@commerce-klaus/sfcc-test-runtime","type":"module","types":"./dist/index.d.mts","author":"Jens Simon <https://github.com/jenssimon>","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./package.json":"./package.json"},"license":"MIT","scripts":{"test":"vp test","build":"vp pack","check":"vp check"},"version":"1.0.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:d198a3a0-47d4-4e09-a562-e5693e1a66cd"}},"homepage":"https://commerce-klaus.github.io/commerce-klaus/packages/sfcc-test-runtime/","keywords":["commercecloud","mocking","salesforce","sfcc","testing"],"repository":{"url":"https://github.com/commerce-klaus/commerce-klaus","type":"git","directory":"packages/sfcc-test-runtime"},"description":"Framework-independent SFCC runtime modules and dependency mocking for local tests","directories":{},"maintainers":[{"name":"jenssimon","email":"jens.simon80@googlemail.com"}],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vite-plus":"latest","typescript":"npm:@typescript/typescript6@^6.0.2","@types/node":"^24"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sfcc-test-runtime_1.0.0_1789727131337_0.5625413165783613"}}},"time":{"created":"2026-09-03T12:35:19.608Z","modified":"2026-09-18T10:25:31.844Z","0.0.1":"2026-09-03T12:35:19.938Z","0.2.0":"2026-09-04T08:28:10.497Z","1.0.0":"2026-09-18T10:25:31.418Z"},"bugs":{"url":"https://github.com/commerce-klaus/commerce-klaus/issues"},"author":"Jens Simon <https://github.com/jenssimon>","license":"MIT","homepage":"https://commerce-klaus.github.io/commerce-klaus/packages/sfcc-test-runtime/","keywords":["commercecloud","mocking","salesforce","sfcc","testing"],"repository":{"url":"https://github.com/commerce-klaus/commerce-klaus","type":"git","directory":"packages/sfcc-test-runtime"},"description":"Framework-independent SFCC runtime modules and dependency mocking for local tests","maintainers":[{"name":"jenssimon","email":"jens.simon80@googlemail.com"}],"readme":"[![NPM version][npm-image]][npm-url] [![Downloads][npm-downloads-image]][npm-url]\n\n# @commerce-klaus/sfcc-test-runtime\n\nFramework-independent SFCC runtime modules and dependency mocking for local tests.\n\n## Highlights\n\n- Replaces module identifiers globally or one exact resolved file\n- Installs and restores controlled SFCC globals\n- Provides focused `dw/system` and `dw/util` test implementations\n- Executes SFRA controllers, hooks, script-module job steps, and chunk jobs\n- Remains independent of Vite, Vitest, cartridge paths, and site-template files\n\n## Install\n\n```bash [pnpm]\npnpm add -D @commerce-klaus/sfcc-test-runtime\n```\n\n```bash [yarn]\nyarn add -D @commerce-klaus/sfcc-test-runtime\n```\n\n```bash [npm]\nnpm install -D @commerce-klaus/sfcc-test-runtime\n```\n\n```bash [Vite+]\nvp install -D @commerce-klaus/sfcc-test-runtime\n```\n\nMost Vitest projects should install `@commerce-klaus/vitest-sfcc` instead and use `@commerce-klaus/vitest-sfcc/runtime` for runtime-only APIs and types.\n\n## Usage\n\n```ts\nimport { createSfccTestRuntime } from \"@commerce-klaus/sfcc-test-runtime\"\n\nconst runtime = createSfccTestRuntime({\n  site: { id: \"RefArch\" },\n})\n\nruntime.mock(\"dw/system/Logger\", loggerMock)\nruntime.setGlobals({ request, session, customer })\n```\n\nThe initial runtime provides a module registry, hook execution, and focused\nimplementations of `dw/system/HookMgr`, `dw/system/Status`,\n`dw/system/Transaction`, `dw/system/Logger`, and `dw/system/Site`.\nUse `@commerce-klaus/vitest-sfcc` to connect the runtime to cartridge modules in Vitest.\n\n`runtime.mock(moduleId, implementation)` replaces a module specifier globally.\n`runtime.mockResolved(absolutePath, implementation)` targets one resolved file\nand takes precedence over a specifier mock.\n\nThe runtime installs the SFCC `empty()` global for nullish values, empty strings,\narrays, and SFCC collections through `isEmpty()`. `runtime.setGlobals({ request,\nsession, customer })` exposes additional controlled globals to cartridge code.\n`runtime.reset()` removes added globals, restores previous values, and reinstalls\nthe default `empty()` implementation.\n\nThe built-in `server` module registers SFRA `get` and `post` routes. Execute an\nexported controller with `runtime.controller(controller).run(routeName,\nrequest)` and inspect its render, JSON, redirect, and view-data response state.\nController inheritance supports `extend()`, `prepend()`, `append()`, and\n`replace()`. Raw responses expose status code, content type, and printed output.\nRedirect responses expose status, headers, cache period, and message logs, and\nstop the remaining middleware chain.\nMiddleware can stop by omitting `next()`. Calling `next(error)` rejects the route\nrun, while repeated `next()` calls fail with an explicit diagnostic.\n\nThe built-in `dw/system/Status` supports empty, single-item, and aggregated\nstatuses. `addItem()` selects the first error for property/getter access and\ncomputes the overall error state across all items. The built-in\n`dw/system/StatusItem` supports the SFCC setters, message parameters, and\ndetails using the same list and map APIs as job contexts.\n\nThe built-in `dw/util/ArrayList` accepts arrays, SFCC collections, iterators,\nand variadic values. It provides `add()`, `addAll()`, `push()`, `sort()`,\n`reverse()`, `clone()`, indexed access, iteration, and collection inspection.\n\nThe built-in `dw/util/HashMap` supports arbitrary key types, `put()`, `putAll()`,\nlookup, removal, clearing, independent clones, and live key, value, and entry\nviews.\n\nThe built-in `dw/util/StringUtils` supports numbered `format()` placeholders and\nUTF-8 `encodeBase64()`/`decodeBase64()` helpers. Locale, date, number, money, and\nresource formatting remain application-provided mocks.\n\nThe built-in `dw/util/Calendar` provides deterministic UTC construction, date\ncopies, common field reads and writes, date arithmetic, comparisons, leap-year\nchecks, and same-day checks. Parsing, rolling, clearing, and time zones remain\napplication-provided mocks.\n\nScript-module job steps can be executed with\n`runtime.jobStep(jobModule).run(functionName, parameters)`. The harness supplies\nSFCC-like job and step execution objects and keeps their mutable `context`\nacross runs. Configure job, step, and execution IDs through the harness options;\nproperties such as `stepTypeID` and `jobID` have matching platform getters. The\ncontext preserves property access while also providing common `dw.util.Map`\noperations such as `get()`, `put()`, `remove()`, `containsKey()`, and `size()`.\nIts `keySet()`, `values()`, and `entrySet()` methods return live, iterable\nSFCC-like collection views. They support both JavaScript iteration and SFCC's\n`iterator().hasNext()/next()` pattern. `iterator.asList()` consumes the\nremaining elements into an independent SFCC-like list.\nChunk modules run through `runChunk({ chunkSize, functions, parameters })`,\nwhich orchestrates step and chunk callbacks, filters null process results, and\npasses an SFCC-like list to `write`.\n\n## Documentation\n\nSee the [complete runtime and harness reference](https://commerce-klaus.github.io/commerce-klaus/packages/sfcc-test-runtime/).\n\n## License\n\nMIT\n\n[npm-url]: https://www.npmjs.com/package/@commerce-klaus/sfcc-test-runtime\n[npm-image]: https://badgen.net/npm/v/@commerce-klaus/sfcc-test-runtime\n[npm-downloads-image]: https://badgen.net/npm/dw/@commerce-klaus/sfcc-test-runtime\n","readmeFilename":""}