It can be useful to have your Avo Codegen running as a part of your test suite.
To that end, Avo generated tracking libraries can be initialized with a noop
flag
that disables network requests and only run data validation.
Below is an example of initializing Avo in a jest test environment with JavaScript:
JavaScriptCopy123456789101112131415describe('Avo', () => {var Avo;beforeAll(() => {Avo = require('./Avo');Avo.initAvo({ env: 'dev', noop: true, strict: true });});test('signupStart() with email property is valid', () => {Avo.signupCompleted({ email: 'test@test.com' });});test('signupStart() without email property throws', () => {expect(() => {Avo.signupCompleted();}).toThrow();});});
The noop
flag is supported in JavaScript, TypeScript, Reason, Java, Objective-C, Swift and Python.
In the generated Avo file we provide wrapping interface/protocol with all the event methods.
KotlinCopy123456public interface Avo {fun feedbackGiven(path: String,feedback: String)}
SwiftCopy123456public protocol AvoProtocol {func feedbackGiven(path: String,feedback: String)}
We suggest to mock it in your tests and verify that desired method is called with particular parameters.