WalkMe Player SDK
Abstract
A WalkMe Application runs in its own iframe
but consumes the services exposed in its container by the Player.
A WalkMe Application developer may use this @walkme/sdk
module to establish
transparently the link with the Player, and to invoke its services.

Installation
Add this dependency to your WalkMe Application:
npm i @walkme/sdk
Production Code
import walkme from '@walkme/sdk';
You must first initialize the SDK library:
await walkme.init();
and then you can use the services.
Testing
Because the WalkMe Application acts as a client for the Player SDK services,
the SDK client library requires many external parts to run, among others the
actual Runtime of the SDK, owned and operated by the Player context.
For testing purposes, you may instead use the Testkit provided by the library:
import { testkitFactory } from '@walkme/sdk/dist/testkit';
const testkit = testkitFactory();
SDK Testkit
The Testkit offers a builder pattern for you to prepare various
initial conditions for your test:
const {sdk} = testkit.withStorageItem( ... )
.withArticle( ... )
.with...
.build();
and then you can use the sdk
object normally:
await sdk.init();
// example:
const myContent = await sdk.content.getContent();
please note that this capabilities are still WIP, we'll keep on improving them over time
Example
you may find a demo project with runnable test(s) at https://gitlab.walkmernd.com/David.Susskind/player-sdk-testkit-demo
code.js
import walkme from '@walkme/sdk'
export const init = walkme.init
export const getContent = (options = {}) => walkme.content.getContent(options)
code.test.js
import {init, getContent} from './code'
import {testkitFactory} from '@walkme/sdk/dist/testkit'
describe('demo test', () => {
it('should get content from sdk', async () => {
const {sdk} = testkitFactory().build()
await init()
jest.spyOn(sdk.content, 'getContent')
await getContent({segmentation: true})
expect(sdk.content.getContent).toHaveBeenCalledWith({segmentation: true})
})
})