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 摘要。