-
Notifications
You must be signed in to change notification settings - Fork 16
How to use testing APIs ? #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@MikaStark you’re right, testing api is relatively recent and not fully implemented yet. This will come in a future version and a doc will be published when the api is stabilized. Currently you can use following setup to interact with the tracker provided using TestBed.configureTestingModule({
providers: [
provideMatomoTesting(),
]
});
const tracker: MatomoTestingTracker = TestBed.inject(MatomoTestingTracker); It is a no-op tracker memoizing history if commands. You can retrieve history of commands using following methods: MatomoTestingTracker.getAllCommands(): unknown[][]; // Get all commands sent to Matomo
MatomoTestingTracker.getCommand(index: number): unknown[] | undefined; // Get a command by index
MatomoTestingTracker.reset(): void; // Reset commands history For getter methods, the api is not well defined. The default provided instance will always return empty values. TestBed.configureTestingModule({
providers: [
provideMatomoTesting(),
{
provide: MATOMO_TESTING_INSTANCE,
useValue: { /* whatever you want */ } satisfies MatomoInstance,
}
]
}); (A more convenient api will come later for this use case.)
|
## [7.0.1](v7.0.0...v7.0.1) (2025-01-15) ### Bug Fixes * export `MATOMO_TESTING_INSTANCE` token ([81abc32](81abc32)), closes [#108](#108)
Hi, thanks for the effort you've put into maintaining this package—it's much appreciated!
I've been trying to use
provideMatomoTesting
in my unit tests but found it difficult to understand how the testing APIs are designed to work. Specifically, I'm unclear about its behavior and capabilities:For example, the
MatomoTestingTracker
JSDoc states:However,
setMatomoInstance
is marked as deprecated and replaced byMATOMO_TESTING_INSTANCE
, which isn’t exported by the package—so it's inaccessible. Is this intentional?In short, could you consider adding a documentation page specifically about testing? It would be incredibly helpful to better understand how to use the testing APIs effectively.
Thanks!
The text was updated successfully, but these errors were encountered: