Testing

You can unit-test the different methods of your app locally. The example below shows how to unit test an action using the Jest test framework:

Copy
Copied
// You can unit test the different methods of you app locally. The example below shows how to unit test an action using the Jest test framework
const {createAppTester} = require("@chatlayer/app-platform");

const app = require("../index");

describe("actions", () => {
    test("create contact", async () => {
        const tester = createAppTester(app);
        const results = await tester("actions.create_contact.operation.perform", {
            authData: {
                api_key: "YOUR_API_KEY",
            },
            inputData: {
                name: "John Doe",
                email: "john.doe@example.com",
            },
        });
        expect(results.user.email).toBe("john.doe@example.com");
    });
});
We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.