
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ionic-mocks
Advanced tools
Simple Mocking of common Ionic 2 Dependencies
This project is still very early in development and there are several things to workout. However since this is only meant to be used in your tests it should be safe to pull into a project.
npm install --save-dev ionic-mocks
import {Events, AlertController} from 'ionic-angular';
import {EventsMock, AlertControllerMock} from 'ionic-mocks';
describe('IonicComponent', () => {
let events: Events;
let alertCtrl: AlertController;
let classUnderTest: MyClassUnderTest;
beforeEach(() => {
events = EventsMock.instance();
alertCtrl = AlertControllerMock.instance();
classUnderTest = new MyClassUnderTest(events, alertCtrl);
});
it('should subscribe to events', () => {
expect(events.subscribe).toHaveBeenCalled();
});
it('should call alert create', () => {
classUnderTest.showAlert();
expect(alertCtrl.create).toHaveBeenCalled();
});
});
import {Events, AlertController, Alert} from 'ionic-angular';
import {EventsMock, AlertControllerMock, AlertMock} from 'ionic-mocks';
describe('IonicComponent', () => {
let alert: Alert;
let events: Events;
let alertCtrl: AlertController;
let classUnderTest: MyClassUnderTest;
beforeEach(() => {
events = EventsMock.instance();
alert = AlertMock.instance():
alertCtrl = AlertControllerMock.instance(alert);
classUnderTest = new MyClassUnderTest(events, alertCtrl);
});
it('should call present on alert', (done) => {
classUnderTest.showAlert().then(() => {
expect(alert.present).toHaveBeenCalled();
done();
});
});
});
TestBed.configureTestingModule({
imports: [IonicModule, AnotherModule],
declarations: [MyComponent],
providers: [
{provide: ViewController, useFactory: () => ViewControllerMock.instance()}
]
});
FAQs
Stubbed and Pre-mocked Ionic2+ Objects
The npm package ionic-mocks receives a total of 339 weekly downloads. As such, ionic-mocks popularity was classified as not popular.
We found that ionic-mocks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.