Skip to content

Commit e3f44b7

Browse files
authored
Updated content, added Mocks section
1 parent 593eff5 commit e3f44b7

File tree

1 file changed

+43
-26
lines changed

1 file changed

+43
-26
lines changed

README.md

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,47 @@
44

55
Special thanks to all of the contributors. With the exception of the Ionic team's updates to the framework, this project is stable. If you have a suggestion, feel free to update code and make a pull request. Find a problem or bug, feel free to file a detailed issue.
66

7-
## UPDATES:
7+
## How to Configure Your Ionic Application for Testing
8+
9+
Read [this tutorial](https://leifwells.github.io/2017/08/27/testing-in-ionic-configure-existing-projects-for-testing/) for instructions on how to apply the testing configuration in this project to your own project.
10+
11+
## Mocking Classes for Ionic
12+
When a developer unit tests a component, the objective is to isolate that component as much as possible. In the case of an Ionic page, you may have Ionic components like `NavController`, `LoadingContoller`, or `Platform`. Adding these components means adding pieces of the Ionic framework to your test, thus not isolating the component. As part of this example, the file `test-config/mocks-ionic.ts` is provided for creating simple mocks for many of the classes in Ionic that you may need. You may use the classes from this file in test files inside the `TestBed.configureComponent()` method argument's `provider` array as seen in our [example unit test file](https://github.com/ionic-team/ionic-unit-testing-example/blob/master/src/app/app.component.spec.ts).
13+
14+
There are other mocking options that should be mentioned:
15+
**[ionic-mocks](https://github.com/stonelasley/ionic-mocks)**
16+
**[ionic-test-doubles](https://github.com/DomesticApp/ionic-test-doubles)**
17+
18+
Also worth mentioning is [ionic-native-mocks](https://github.com/chrisgriffith/ionic-native-mocks) which can be helpful when mocks for Ionic Native classes used in your project are needed.
19+
20+
Getting Started with this Project
21+
-----------
22+
23+
To get started, clone this repo, and run `npm install` in the root directory.
24+
25+
```sh
26+
git clone https://github.com/ionic-team/ionic-unit-test-example.git
27+
cd ionic-unit-testing-example
28+
npm install
29+
```
30+
Then, you should run `ionic serve` to make sure the project loads.
31+
32+
### Unit Tests
33+
34+
To run the tests, run `npm run test`.
35+
36+
See the example test in `src/app/app.component.spec.ts` for an example of a component test.
37+
38+
### End-To-End Tests (Browser-Only)
39+
40+
To serve the app, run `ionic serve`.
41+
42+
To run the end-to-end tests, run (while the app is being served) `npm run e2e`.
43+
44+
See the example end-to-end test in `e2e/app.e2e-spec.ts`.
45+
46+
UPDATES:
47+
==========
848
### **2017-08-26: Update to `ionic-angular` version 3.6.0**
949

1050
We updated the project to `ionic-angular` version `3.6.0`. Developers wishing to use this should also update Ionic CLI for a better experience. With today's update, this project is now at version `0.0.5`.
@@ -19,20 +59,16 @@ Thanks to [@datencia](https://github.com/datencia) for providing an update to ou
1959

2060
Thanks (again) to [@danielsogl](https://github.com/danielsogl/) for providing a code update to the project so that our code matches code created by using the `ionic start` command. Having this code properly match is important as it provides the best practice guidance for handling application start up.
2161

22-
## How to Configure Your Ionic Application for Testing
23-
24-
Read [this tutorial](https://leifwells.github.io/2017/08/27/testing-in-ionic-configure-existing-projects-for-testing/) for instructions on how to apply the testing configuration in this project to your own project.
25-
2662
## Looking for Version 2?
2763

2864
If you are using Ionic v2, please see our [ionic-v2-branch](https://github.com/ionic-team/ionic-unit-testing-example/tree/ionic-v2-branch).
2965

30-
3166
## Credits
3267

3368
This repository is based on the awesome [unit testing example](https://github.com/roblouie/unit-testing-demo) from [@roblouie](https://github.com/roblouie/) :thumbsup:
3469

35-
## Past Changes
70+
Past Updates
71+
==========
3672
#### *2017-05-28: Update to Version 3.3.0*
3773

3874
Thanks to [@danielsogl](https://github.com/danielsogl/) for getting us up-to-date with Ionic 3.3.0, Angular 4.1.2 and Ionic Native 3.10.2.
@@ -51,22 +87,3 @@ npm remove -g ionic
5187
npm install -g ionic
5288
```
5389
If you run `ionic -v` it should return `3.0.0` (or better, depending on what has been released.
54-
55-
## Getting Started
56-
-----------
57-
58-
To get started, clone this repo, and run `npm install` in the root directory.
59-
60-
### Unit Tests
61-
62-
To run the tests, run `npm test`.
63-
64-
See the example test in `src/app/app.component.spec.ts` for an example of a component test.
65-
66-
### End-To-End Tests (Browser-Only)
67-
68-
To serve the app, run `ionic serve`.
69-
70-
To run the end-to-end tests, run (while the app is being served) `npm run e2e`.
71-
72-
See the example end-to-end test in `e2e/app.e2e-spec.ts`.

0 commit comments

Comments
 (0)