{"id":18262850,"url":"https://github.com/midwayjs/egg-mock-util","last_synced_at":"2025-04-09T01:24:47.085Z","repository":{"id":38209607,"uuid":"410440471","full_name":"midwayjs/egg-mock-util","owner":"midwayjs","description":"mock egg app for midway component","archived":false,"fork":false,"pushed_at":"2023-02-15T03:54:49.000Z","size":8,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-04-25T15:44:34.977Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/midwayjs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-09-26T03:31:21.000Z","updated_at":"2022-06-09T03:18:14.000Z","dependencies_parsed_at":"2024-02-03T04:43:03.490Z","dependency_job_id":null,"html_url":"https://github.com/midwayjs/egg-mock-util","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"5ceae3eee3d4bc4a0c0617844c4077b7c9ed872f"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fegg-mock-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fegg-mock-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fegg-mock-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/midwayjs%2Fegg-mock-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/midwayjs","download_url":"https://codeload.github.com/midwayjs/egg-mock-util/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247954515,"owners_count":21024236,"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":"2024-11-05T11:09:04.607Z","updated_at":"2025-04-09T01:24:47.068Z","avatar_url":"https://github.com/midwayjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# egg mock util\n\n将 egg 插件变为 midway 组件的工具包，包含两个方法。\n\n使用方式如下，比如在 configuration 里，由于 egg 的目录是固定的，所以使用文件加载的形式直接执行即可。\n\n```ts\nimport { completeAssign, createMockApp } from '@midwayjs/mw-util';\n\nexport class AutConfiguration {\n  @App()\n  app;\n\n  async onReady() {\n    // 创建一个 egg 认识的模拟 app\n    const mockApp = createMockApp(this.app);\n    // 执行 egg 的 app.js 中的方法\n    require('@ali/egg-********/app')(mockApp);\n\n    // 执行 beforeStart 方法\n    await Promise.all(mockApp.getBeforeStartList());\n\n    // 可选：将 egg 赋到 app 上的对象拿到，比如赋给 midway 的 app\n    this.app.changefree = mockApp.changefree;\n\n    // 用于合并 egg 的 context 方法，这样就有 ctx.xxx 方法了\n    completeAssign(\n      this.app.context,\n      require('@ali/egg--********//app/extend/context')\n    );\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidwayjs%2Fegg-mock-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmidwayjs%2Fegg-mock-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidwayjs%2Fegg-mock-util/lists"}