16.0.0 • Published 1 month ago

yunzhi v16.0.0

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

梦云智开发团队angular开源库。

名称基本功能适用场景
MockApiInterceptor对Http请求进行拦截,返回自定义API数据使用文件统一前后台API、开发组件时抛弃测试桩而用生产环境的服务、避免一些因测试生产数据格式返回不统一造成的问题
MockApiTestingInterceptor用于单元测试中对http请求拦截、手动控制数据返回时机适用于单元测试

更多帮助文档请点击github

安装

npm i @yunzhi/utils npm i @yunzhi/ng-mock-api npm i @yunzhi/ng-router-testing npm i @yunzhi/ng-theme-basic npm i @yunzhi/ng-common

使用文档请参考:MockApiInterceptor

开发步骤

创建新库ng g library my-lib

  1. 进入项目根路径
  2. npm install
  3. 'node mock-api.js' 或 node router-testing.jsnode common.jsnode theme.js
  4. 编写代码,并同步在project/sample中完成相关集成测试。

发布前测试

  1. 进入相关文件夹,执行npm link,比如:cd dist/mock-api && npm link
  2. 建立测试项目,执行npm link xxx,即相当于直接安装了xxx
  3. 进行相关测试
  4. 需要注意的是Angular中默认禁止了这种npm link xxx来直接链接本地库的操作,若要使用测试成功,则需要在angular.json添加如下配置:

in your angular app that depends on your local library, set projects.projectName.architect.build.options.preserveSymlinks with true in angular.json will prevent the angular cli from updating linked local library

projects.projectName.architect.build.options.preserveSymlinks: true

相关设置说明请参考: https://github.com/angular/angular/issues/35586

发布

build项目,比如ng build common.

登录:npm login

然后进入相关文件夹完成发布: cd dist/mock-api && npm publish --access=publiccd dist/router-testing && npm publish --access=public

测试开发中的注意点

mock-api(router-testing).js 监听的还不完美,可能在开发中有一些 BUG。

参考资源

在angular模块中建立子模块