Testing with local mode and the Preview tool
Testing with local mode and the Preview tool
There are three places to test, from fastest to most realistic.
| Where | Needs | What it gives you |
|---|---|---|
| Local mode (your machine) | Nothing: a local web server | The SDK answers from an in-page mock. Instant feedback, works offline. |
Preview tool (/preview) |
Nothing: no account, no upload | Your game, served from any http(s) address such as localhost, runs inside the real portal frame with a live requirements checklist and an event log. |
| Build preview (developer console, game, Preview) | An uploaded, validated build | Your uploaded build inside the real portal frame, with ads switched on so every module can be exercised. Tracking, votes and reports are blocked, so testing never touches your numbers. |
Local mode#
Open your game from localhost, 127.0.0.1, [::1] or any *.localhost host, or add ?useLocalSdk=true to the URL on any other host. The SDK then runs an in-page mock instead of talking to the portal. Serve over HTTP; file:// pages are not treated as local.
What the mock does:
| Module | Local behaviour |
|---|---|
| Ads | A full-screen overlay labelled Local ad (midgame) or Local ad (rewarded) for 3 seconds, firing adStarted and adFinished. A midgame request less than three minutes after the previous ad (of either type) fails with adCooldown, as in the portal. |
| Banners | A dashed placeholder box of the chosen size appended to your container. |
| User | Two fake users, LocalUser1 and LocalUser2, twelve fake friends, and an unsigned test token. |
| Data | Saved in the browser's localStorage under the key zoko-sdk-data. |
| Game | Settings come from the query string. Invite links are your own URL with the parameters added. Room, loading and completion calls are accepted and do nothing visible. |
Local mode is for developing. It never fails an ad with unfilled or adsDisabled and never refuses banners, so always re-test in the Preview tool.
Query switches#
Add any of these to the page URL.
| Parameter | Values | Effect |
|---|---|---|
sdk_debug |
true |
Logs every SDK call and result to the console. Works in every environment. |
disableChat |
true |
SDK.game.settings.disableChat becomes true. |
muteAudio |
true |
SDK.game.settings.muteAudio becomes true. |
user_account_available |
false |
Simulates a host without accounts: no user, isUserAccountAvailable is false. |
user_response |
user1, user2, logged_out |
Who getUser() returns at start. |
show_auth_prompt_response |
user1, user2, user_cancelled |
What showAuthPrompt() does. |
link_account_response |
yes, no, logged_out |
What showAccountLinkPrompt() answers. |
token_response |
user1, user2, expired_token, logged_out |
Which user the token is for, or that it is already expired, or that it fails with userNotAuthenticated. |
qaTool |
true |
Sets SDK.isQaTool, so the game can show extra diagnostics. |
http://localhost:8080/?sdk_debug=true&user_response=logged_out&show_auth_prompt_response=user2The local token is unsigned (alg: none). Your server must reject it. If your backend accepts a local token, your verification is broken.
The Preview tool#
Open /preview, type the address of your game (for example http://localhost:8080/index.html) and press Load game. No account is needed and nothing is uploaded: the game loads straight from your address inside a sandboxed frame, and the event log stays in your tab.
The portal frame answers SDK calls with test data: ads are placeholder screens, there is no signed-in user, and cloud saves stay in your browser. Use it to:
- Play at every window size from the gameplay requirements with one-click Frame size presets.
- Watch every SDK call as it happens in the event log; filter it by method or text and export it as JSON to attach to a support request.
- Tick off the requirements checklist: SDK initialised,
loadingStop,gameplayStart,gameplayStop, a midgame ad, a rewarded ad, a banner, data module use andhappytime. Items turn green when your game makes the call. - Check time to the first
gameplayStart. The tool flags a start later than 20 seconds; trim your initial download if it does (see first frame fast). - Toggle Simulate settings (mute audio, disable chat) and confirm your game reacts.
If the Preview page is served over https, browsers block plain http games unless they run on localhost. Serve your game over https or from localhost. Addresses with a username or password, and pages on this site (other than the bundled demos), are refused.
The build preview in the console#
After you upload a build and it passes validation, Preview in the game's console runs that exact build in the real portal frame, with ads enabled and your game's own data, leaderboard and multiplayer settings applied. The checklist is grouped into Basic launch, Full launch and "for your settings" items, and it shows SDK ready and First gameplay timings. Play through the menus, a round, a pause and an ad break, then check that every item you need has ticked.
Checklist before you submit#
- No console errors on load or during the first minute of play.
-
gameplayStartis the first SDK event after the player acts, not at page load. - A failed ad never leaves the game paused or muted.
- The game works with the SDK
disabled(open it on a plain web server without?useLocalSdk=true). - Nothing depends on
localStoragesurviving; use the data module. - The first
gameplayStartarrives well within 20 seconds on a throttled connection.