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

Collection of Ionic Mocks for Use in Every Project

Đang mở
#21 7 bình luận 4 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
370
Fork
144
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.