{"id":27012027,"url":"https://github.com/salesforcecommercecloud/dw-api-mock","last_synced_at":"2025-04-04T11:47:35.709Z","repository":{"id":44908370,"uuid":"138773919","full_name":"SalesforceCommerceCloud/dw-api-mock","owner":"SalesforceCommerceCloud","description":"Mock version of DW API","archived":false,"fork":false,"pushed_at":"2024-09-16T06:40:46.000Z","size":540,"stargazers_count":23,"open_issues_count":5,"forks_count":9,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-09-16T07:59:29.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SalesforceCommerceCloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-26T17:54:23.000Z","updated_at":"2024-09-16T06:37:29.000Z","dependencies_parsed_at":"2024-09-16T07:59:06.104Z","dependency_job_id":"d916aa3d-947f-4459-bbb6-0384acf2c15c","html_url":"https://github.com/SalesforceCommerceCloud/dw-api-mock","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalesforceCommerceCloud%2Fdw-api-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalesforceCommerceCloud%2Fdw-api-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalesforceCommerceCloud%2Fdw-api-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SalesforceCommerceCloud%2Fdw-api-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SalesforceCommerceCloud","download_url":"https://codeload.github.com/SalesforceCommerceCloud/dw-api-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174402,"owners_count":20896074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-04T11:47:35.210Z","updated_at":"2025-04-04T11:47:35.700Z","avatar_url":"https://github.com/SalesforceCommerceCloud.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"DW MOCK API\n===========\n\n--------------------------\n\nIntroduction\n------------\nThis is a mock API or an API stub for the Demandware Script API, the main goal is to make unit testing easier so that not every single Class/Object needs to be stubbed out.\n\nExample usage\n-------------\n\nIt has been tested to work well in conjunction with mochajs as a testrunner and chai, sinon, sinon-chai and proxyquire as utility libs.\n\nA unit test would then look something like\n\n```\n#!javascript\n'use strict';\n\n// jscs:disable jsDoc\n\nvar describe   = require('mocha').describe;\nvar it         = require('mocha').it;\nvar chai       = require(\"chai\");\nvar sinon      = require(\"sinon\");\nvar sinonChai  = require(\"sinon-chai\");\nvar expect     = chai.expect;\nvar proxyquire = require('proxyquire').noCallThru();\n\nchai.use(sinonChai);\n\nrequire.extensions['.ds'] = require.extensions['.js'];\nrequire('dw-api-mock/demandware-globals');\n\n// add cartridges dir as module lookup location, the app-module-path package lets you do this nicely\nrequire('app-module-path').addPath(process.cwd() + '/cartridges');\n\ndescribe(\"Product Model\", function() {\n\n    it(\"should return a variation model\", function() {\n\t    var ProductModel = require('app_storefront_controller/cartridge/scripts/models/ProductModel');\n\t\t\n\t\tvar instance = new ProductModel(new dw.catalog.Product());\n\t\t\n\t\texpect(instance.getVariationModel()).to.exist.\n\t});\n});\n```\n\nAll the dependencies can be added to the root of your repository into a `package.json` file and the unit tests would be inside a test folder, so you would have\n\n* cartridges\n* site_import\n* test\n\nSample package.json\n\n```\n{\n  \"name\": \"my-repo\",\n  \"version\": \"1.0.0\",\n  \"description\": \"A repo description\",\n  \"main\": \"index.js\",\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"devDependencies\": {\n    \"app-module-path\": \"^1.0.4\",\n    \"chai\": \"^3.4.1\",\n    \"dw-api-mock\": \"git+ssh://github.com/SalesforceCommerceCloud/dw-api-mock.git\",\n    \"istanbul\": \"^0.4.1\",\n    \"mocha\": \"^2.3.4\",\n    \"proxyquire\": \"^1.7.3\",\n    \"sinon\": \"^1.17.2\",\n    \"sinon-chai\": \"^2.8.0\",\n    \"xunit-file\": \"0.0.7\"\n  },\n  \"scripts\": {\n    \"test\": \"mocha test/*\",\n    \"coverage\": \"istanbul cover ./node_modules/mocha/bin/_mocha\"\n  },\n  \"keywords\": [\n    \"myrepo\"\n  ],\n  \"author\": \"Your Name\",\n  \"license\": \"UNLICENSED\",\n  \"homepage\": \"www.yourhomepage.com\"\n}\n```\n\nNow you can simply run\n```\n#!bash\n$ npm install\n$ mocha test/*\n```\n\nLicense\n-------\nLicensed under the current NDA and licensing agreement in place with your organization. (This is explicitly not open source licensing.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalesforcecommercecloud%2Fdw-api-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalesforcecommercecloud%2Fdw-api-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalesforcecommercecloud%2Fdw-api-mock/lists"}