ionic-mocks
Simple test doubles for Ionic 2+ using Jasmine Spy Objects
This project is still very early in development and there are several things I'm sorting out. However since this is only meant to be used in your tests it should be safe to pull into a project.
Supported Types
- ActionSheet
- ActionSheetController
- Alert
- AlertController
- App
- Content
- Config
- Events
- Form
- Haptic
- InfiniteScroll
- ItemSliding
- KeyBoard - exported as IonKeyboard
- Loading
- LoadingController
- Menu
- MenuController
- Modal
- ModalController
- Platform
- Popover
- PopoverController
- NavController
- NavParams
- StatusBar
- Storage
- Tab
- Tabs
- Toast
- ToastController
- ViewController
Native Plugins
- 3DTouch
- File
- GoogleAnalyics
- Keyboard
- Network
- NFC
- Splashscreen
- StatusBar
- Vibration
Installation
npm install --save-dev ionic-mocks
Examples
;; describe'MyClass',;
Pre-mocked return types
;; describe'MyComponent',;
Override ionic providers in TestingModule
TestBed.configureTestingModule;
Contributing
This project has a long way to go and is full of opportunities to contribute. I am back in school and working so for the rest of the year expect my responsiveness on this project to be slow. If anyone is up to helping vet PRs please message me. sclarklasley@gmail.com
Contributors
Frequently Asked Questions:
TypeError: jit__object_Object_33 is not a function
error. What does that mean?
Q: I am receiving a Answer: This means you've done something wrong. Take a look at this example:
// DO NOT DO THIS// USING useClass INSTEAD OF useFactory IS INCORRECT
// DO NOT DO THIS// USING useFactory WITHOUT THE FAT ARROW SYNTAX IS INCORRECT
Make sure you are using the useFactory
property name and using the fat arrow function as the value:
// DO THIS