NativeScript 测试钩子
NativeScript 插件,让您能够像 Angular 风格指南一样处理 Nativescript 测试
npm i --save nativescript-tests-hook
- 版本:0.0.1
- GitHub: https://github.com/JuanDelgadillo/nativescript-tests-hook
- NPM: https://npmjs.net.cn/package/nativescript-tests-hook
- 下载量
- 昨天: 0
- 上周: 0
- 上个月: 0
NativeScript 测试钩子
NativeScript 插件,让您能够像 Angular 风格指南一样处理 Nativescript 测试
NativeScript 默认配置为将所有测试放入 tests
文件夹,但随着应用大小和组件的增加,有时这可能会有些烦恼,因为将单元测试与实现放在一起更容易维护这些测试。当我们为 Angular 应用程序的 Web 版本进行开发时,我们根据 Angular 风格指南将测试文件放入相应的功能文件夹,并使用 .spec.ts
或 .spec.js
后缀。
示例
app
|-- myFeature
|- myFeature.component.html
|- myFeature.component.ts
|- myFeature.component.spec.ts
只需将 .spec.ts
或 .spec.js
文件放在实现旁边即可。在 tns 的 before-prepare 钩子时间,它会将所有测试从任何位置移动到 app
到 tests
文件夹。
安装
Npm
npm install nativescript-tests-hook --save-dev
配置
您需要注意的唯一一件事是在测试中导入文件依赖项时,您必须根据 Nativescript 的位置规则文档 将它们引用为从应用程序包加载文件,以保持它们在移动时的引用。
示例
import { MyFeatureComponent } from '~/myFeature/myFeature.component';
import { AppComponent } from '~/app.component';