Testing with fakes
Assert side effects without hitting real mail, notification, or broadcast drivers.
Setup
typescript
import { TestCase } from '@pondoknusa/testing';
import { mailFake, notificationFake, broadcastFake } from '@pondoknusa/testing';
import type { MailFake } from '@pondoknusa/testing';
class FeatureTest extends TestCase {
private mail!: MailFake;
async setUp() {
await super.setUp();
this.mail = mailFake(this.app);
notificationFake(this.app);
broadcastFake(this.app);
}
}Assertions
typescript
import { Mail } from '@pondoknusa/core';
await Mail.to('[email protected]').send(new WelcomeMail(user));
expect(this.mail.messages).toHaveLength(1);
this.mail.assertSent((message) =>
message.to.some((to) => to.address === '[email protected]'),
);Notification and broadcast fakes follow the same pattern — see Testing for HTTP sugar (actingAs, withCsrf), database transactions, and snapshot helpers added in v0.15.