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

Collection of Ionic Mocks for Use in Every Project

Aberta
#21 7 comentários 4 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
370
Forks
144
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.