{"id":13625883,"url":"https://github.com/line/liff-mock","last_synced_at":"2025-04-16T10:33:36.927Z","repository":{"id":37885603,"uuid":"481429890","full_name":"line/liff-mock","owner":"line","description":"LIFF Mock is a LIFF Plugin that make testing your LIFF app easy.","archived":false,"fork":false,"pushed_at":"2023-10-02T01:12:52.000Z","size":221,"stargazers_count":35,"open_issues_count":0,"forks_count":6,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-08-02T22:21:01.815Z","etag":null,"topics":["liff","liff-plugin","liff-sdk","line","mock","test"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@line/liff-mock","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/line.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-04-14T01:42:27.000Z","updated_at":"2024-06-21T01:08:02.000Z","dependencies_parsed_at":"2023-10-02T02:37:26.912Z","dependency_job_id":null,"html_url":"https://github.com/line/liff-mock","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fliff-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fliff-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fliff-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fliff-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/line","download_url":"https://codeload.github.com/line/liff-mock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223708416,"owners_count":17189774,"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":["liff","liff-plugin","liff-sdk","line","mock","test"],"created_at":"2024-08-01T21:02:04.559Z","updated_at":"2024-11-08T15:30:42.651Z","avatar_url":"https://github.com/line.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# LIFF Mock\n\nLIFF Mock is a LIFF Plugin that make testing your LIFF app easy.\n\n**※ LIFF Plugin feature is available since LIFF SDK v2.19.0.**\n\n# Usage\n\n## NPM\n\n```sh\n$ npm install @line/liff-mock\n```\n\n```ts\nimport liff from '@line/liff';\nimport { LiffMockPlugin } from '@line/liff-mock';\n\nliff.use(new LiffMockPlugin());\n\nliff.init({\n  liffId: 'liff-xxxx',\n  mock: true, // enable mock mode\n});\n\nif (!liff.isInClient()) liff.login();\nconst profile = await liff.getProfile();\n// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }\nconsole.log(profile);\n```\n\n### With [Pluggable SDK](https://developers.line.biz/en/docs/liff/pluggable-sdk/)\n\nIf you use LIFF Mock with Pluggable SDK mode, you have to install `IsInClientModule` before the installation of `LiffMockPlugin` because LIFF Mock depends on `liff.isInClient` API.\n\n```ts\nimport liff from '@line/liff/core';\nimport IsInClientModule from \"@line/liff/is-in-client\";\nimport { LiffMockPlugin } from '@line/liff-mock';\n\nliff.use(new IsInClientModule());  // \u003c-- Please install IsInClientModule before LiffMockPlugin\nliff.use(new LiffMockPlugin());\n\nliff.init({\n  liffId: 'liff-xxxx',\n  mock: true, // enable mock mode\n});\n\nif (!liff.isInClient()) liff.login();\nconst profile = await liff.getProfile();\n// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }\nconsole.log(profile);\n```\n\n## CDN\n\nhttps://unpkg.com/@line/liff-mock@1.0.3/dist/umd/liff-mock.js\n\n```html\n\u003c!-- in \u003chead\u003e tag --\u003e\n\u003cscript src=\"https://unpkg.com/@line/liff-mock@1.0.3/dist/umd/liff-mock.js\"\u003e\u003c/script\u003e\n```\n\n```js\nconst liff = window.liff;\nconst liffMockPlugin = window.liffMock;\n\nliff.use(new LiffMockPlugin());\n\nliff.init({\n  liffId: 'liff-xxxx',\n  mock: true, // enable mock mode\n});\n\nif (!liff.isInClient()) liff.login();\nconst profile = await liff.getProfile();\n// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }\nconsole.log(profile);\n```\n\n# API\n\n## liff.$mock.set\n\nSet mock data\n\n```ts\ntype set = (\n  data: Partial\u003cMockData\u003e | ((prev: Partial\u003cMockData\u003e) =\u003e Partial\u003cMockData\u003e)\n) =\u003e void;\n```\n\n```js\nconst profile = await liff.getProfile();\n// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }\nconsole.log(profile);\n\nliff.$mock.set((p) =\u003e ({\n  ...p,\n  getProfile: { displayName: 'Cony', userId: '1111111' },\n}));\n\nconst profile = await liff.getProfile();\n// { displayName: 'Cony', userId: '1111111' }\nconsole.log(profile);\n```\n\n## liff.$mock.clear\n\nRestore default mock data\n\n```ts\ntype clear: () =\u003e void;\n```\n\n```js\n// liff.$mock.set(...)\nconst profile = await liff.getProfile();\n// { displayName: 'Cony', userId: '1111111' }\nconsole.log(profile);\n\nliff.$mock.clear();\n\nconst profile = await liff.getProfile();\n// { displayName: 'Brown', userId: '123456789', statusMessage: 'hello' }\nconsole.log(profile);\n```\n\n# Example\n\nSee [examples](./examples)\n\n# Contribution\n\n```sh\n$ nvm use\n$ npm ci\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fline%2Fliff-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fline%2Fliff-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fline%2Fliff-mock/lists"}