ionic-team / ionic-team/ionic-unit-testing-example

Collection of Ionic Mocks for Use in Every Project

未关闭
#21 7 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
370
派生
144
PR 合并指标
30 天内没有已合并 PR

描述

**EDIT:** I just realized that the main place I've grabbed Ionic mock from was the [Clicker](https://github.com/lathonez/clicker) project. [`mocks.ts`](https://github.com/lathonez/clicker/blob/master/src/mocks.ts). Thanks to @lathonez for making this file available.

I created this issue to begin a discussion around mock objects in Ionic (and I'm not sure where else to have this discussion).

I've been doing a lot of unit testing lately for an Ionic 2 application. One of the things I've found to be very helpful is that there appear to be many mock objects available out there for use in Ionic unit testing. I've put together a few objects that I've needed in a current project into one file so that I can reference them. [Take a look.](https://gist.github.com/leifwells/c067172da00c79064844d9b142758d5c)

FYI:
1) While I have made adjustments to this code, it is not mine. I've found these objects sprinkled over Stack Overflow and else where.
2) These mocks are working for me, but Your Mileage May Vary.

**Here's my issue.** For this project, having reliable Ionic mocks is important. We should be unit testing our applications, not the Ionic Framework. There is no reason for each of us to be building their own set of Ionic mocks. As a community, we should be able to assemble these mocks.

_Shouldn't we be able to provide mocks for as many of the Ionic pieces that may be needed?_

_Shouldn't we be able to provide best practices as to where to place these mocks and how to use them?_

Re: Best practices: Currently, I have three files in my project:
- `src/testing/mock-ionic.ts`: Ionic mocks
- `src/testing/mock-app.ts`: mocks of object created in my project
- `src/testing/mock-data.ts`: mock data that I can use with my mock services

This is how I've organized my current project. Again, YMMV.

Let the discussion begin.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。