ionic-mocks-jest
Simple test doubles for Ionic using Jasmine Spy Objects and Jest support
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-jest
Examples
;; describe'MyClass',;
Pre-mocked return types
;; describe'MyComponent',;
Override ionic providers in TestingModule
TestBed.configureTestingModule;
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