Skip to content

Commit 12b1299

Browse files
authored
docs: document Segment fake usage (#31)
1 parent 435933c commit 12b1299

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,24 @@ disabled then the exception will be thrown.
258258
./vendor/bin/pest
259259
```
260260

261+
### Using `Segment::fake()` in tests
262+
263+
To prevent real HTTP requests when running your own test suite, call
264+
`Segment::fake()` before executing the code under test. This swaps the
265+
Segment service with a fake that records events and identity calls. You can
266+
then use assertion helpers to verify what was sent:
267+
268+
```php
269+
use SlashEquip\LaravelSegment\Facades\Segment;
270+
271+
Segment::fake();
272+
273+
// Code that should trigger Segment events
274+
275+
Segment::assertTracked('User Signed Up');
276+
Segment::assertIdentified();
277+
```
278+
261279
## Changelog
262280

263281
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

0 commit comments

Comments
 (0)