Begin Here

Adding the KOS Test Utilities Project

Introduction

In the early phases of development, before the backend services are available, it is useful to be able to develop KOS Models and UIs in isolation. This can be facilitated using the KOS Test Utilities which can enable you to mock WebSocket requests and responses without requiring the backend to be active.

The utilities will allow you to intercept requests destined for the KOS Web Socket transport and instead provide mocked responses back to the model framework.

Installing the test utils

Install the KOS Test Utilities as a dev dependency in your project

npm install -D @coca-cola/kos-test-utils@canary

Initializing a mock websocket handler

Create a new file in your project (src/mockHandlers.ts) initialize the mock websocket utility by calling the initHandlers function passing the list (currently empty) of request handlers.

The call to initHandlers can be wrapped in a check for an environment variable such as whether the application is running in DEV or PROD to determine if the handlers should be initialized.

import { initHandlers } from "@coca-cola/kos-test-utils";

const handlers = {};

initHandlers(handlers);

Import the mock handler

Before initializing the KOS Core (i.e. index.tsx) import the mock handlers to activate the test utilities.

import "./mockHandlers";

With this minimal configuration, your application should be able to get past the initialization phase, and you should see your content.

Post Initialization

Previous
Next
On this page
Java Development
Seamlessly transition from Legacy+ systems to Freestyle microdosing and advanced distributed dispense systems.
UI Development
Using KOS SDKs, integrating Consumer and Non-consumer facing UIs becomes seamless, giving you less hassle and more time to create.
Video Library
Meet some of our development team, as they lead you through the tools, features, and tips and tricks of various KOS tools.
Resources
Familiarize yourself with KOS terminology, our reference materials, and explore additional resources that complement your KOS journey.
Copyright © 2024 TCCC. All rights reserved.