Skip to main content

Installation and Setup

The testing API is exported by @tantawowa/hosanna-tools; it is not a separate Playwright test project. A project needs Hosanna Tools, a compatible Vitest version, generated application sources, and the configuration that already lets hst run launch the application.

Prerequisites​

  • The Node.js version required by your Hosanna application. The current hosanna-samples engine range requires Node.js 24.17.0 or newer within Node 24.
  • npm 11 and the committed package-lock.json in hosanna-samples.
  • A runnable Hosanna browser emulator.
  • Any ignored build-config secret overlays required by the application.
  • Chromium installed for the Playwright version bundled with Hosanna Tools.

From a clean checkout, install exactly the locked dependencies:

npm ci

Integrate the framework dependency declared in the application:

npx hst sdk:install

These instructions require an application migrated to Hosanna UI 2 and Tools 5. Older sample checkouts still using source-selection scripts need the npm migration first, including review of application-specific scripts and local file dependencies. Tools 5 supports Vitest >=3.2.0 <5.

The browser suite needs no compiler or compiler key. npm installs the framework, and HST repairs the app's source links.

Install the owned Chromium browser in hosanna-samples with its checked-in script:

npm run test:ui:install

The script resolves the Playwright version from the project lockfile. On Linux CI workers, npx playwright install --with-deps chromium also installs supported operating-system packages.

integration/
__screenshots__/
browser-web/
fixture.ts
global-setup.ts
hosanna-test.config.ts
smoke/
launch.test.ts
support/
vitest.integration.config.ts

Generated output belongs in test-results/ and should be ignored. Approved baselines below integration/__screenshots__/ are source files and should be reviewed and committed.

Configure the Hosanna runtime​

The application configuration has three layers:

  1. normal Hosanna application/build configuration;
  2. HosannaTestConfig, which selects the launch target, ports, artifacts, and preconditions;
  3. HS_TEST_PLATFORM and HS_TEST_TARGET, which may select a platform/target for a run.

The test-only buildConfig overlay is merged last for a non-production launch. Use it for non-secret test flags such as remote debugging. The launcher rejects this overlay for prod; do not use it to bypass production configuration.

import { fileURLToPath } from 'node:url';
import { defineHosannaTestConfig } from '@tantawowa/hosanna-tools/testing';

const cwd = fileURLToPath(new URL('../', import.meta.url));

export default defineHosannaTestConfig({
cwd,
appName: 'hosanna-samples',
environment: 'dev',
artifactDirectory: 'test-results',
timeoutMs: 60_000,
buildConfig: {
remoteDebug: {
isEnabled: true,
isStartServerByDefault: true,
},
mcp: { isEnabled: true },
},
});

Use unique ports when another Hosanna runtime is likely to be running. The launcher checks the debugger, app, Vite, and browser ports before startup and fails with the occupied port list rather than silently attaching to another run.

Connect Vitest​

Global setup owns application launch and teardown. The worker fixture creates a scoped client for each test.

integration/global-setup.ts
import { createHosannaGlobalSetup } from '@tantawowa/hosanna-tools/testing/vitest';
import config from './hosanna-test.config';

export default createHosannaGlobalSetup(config);
integration/fixture.ts
import { createHosannaVitest } from '@tantawowa/hosanna-tools/testing/vitest/fixture';
import config from './hosanna-test.config';

export const { test, expect } = createHosannaVitest(config);
vitest.integration.config.ts
import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vitest/config';
import { createHosannaReporter } from '@tantawowa/hosanna-tools/testing/vitest/reporter';
import config from './integration/hosanna-test.config';

export default defineConfig({
root: fileURLToPath(new URL('./integration', import.meta.url)),
test: {
include: ['**/*.test.ts'],
globalSetup: ['./global-setup.ts'],
fileParallelism: false,
maxWorkers: 1,
reporters: ['default', createHosannaReporter(config)],
},
});

A single runtime is shared by the files in the run, so keep file parallelism disabled and use a named precondition to reset state before every test.

Environment variables​

The shared launcher understands these general selectors:

VariablePurpose
HS_TEST_PLATFORMbrowser for the simulator or roku for hardware
HS_TEST_TARGETweb for the simulator or device for Roku
HS_TEST_TIMEOUT_MSOverrides application launch timeout
HS_TEST_DEVICESelects a concrete configured test device or desktop preset
HS_TEST_ASSET_SERVER_BASE_URLSamples config override for the LAN-reachable server serving public/, including generated AppConfig assets
HS_TEST_STREAM_BASE_URLCredential-free HTTP(S) fixture root included in physical-TV package policy and test launch metadata
HS_TEST_STREAM_ORIGINOptional exact origin assertion; when set, it must equal the origin derived from HS_TEST_STREAM_BASE_URL
HS_TEST_HEADEDA project convention used by reference configs to set headless: false when 1
HS_TEST_VIDEOA project convention used by reference configs to disable video when 0
HS_UPDATE_SCREENSHOTSCreates or replaces visual baselines when 1
HOSANNA_TEST_VERBOSEStreams owned runtime/browser output when 1

Roku device runs also require the configured device IP and developer password variables. See Devices, Browsers, and Input Methods.

Serve assets for physical Roku​

Run these commands from the samples/ application root. First generate the AppConfig bundles and start an asset server in one terminal:

npm run assets:precompile
npx http-server public -a 0.0.0.0 -p 5181 --cors -c-1

Keep this server running during the device tests. Roku's AppConfig uses URLs under /asset-bundles/, including the glass-rendering PNG. Serving public/ puts those generated files at the expected URLs. The Roku launcher builds and installs the app; it does not start this HTTP server.

For tests that load fixture media, use a second terminal in the same samples/ directory:

npm run generate:test-streams
npm run serve:test-streams

The media server serves www/test-streams/ on port 5180. It does not serve the AppConfig assets. In a third terminal, run the device suite with separate asset and stream URLs. Replace the example addresses with the Roku's IP and the development machine's LAN address; both HTTP servers must be reachable by Roku:

HOSANNA_ROKU_DEVICE_IP=192.0.2.28 \
HOSANNA_ROKU_DEV_PASSWORD='<developer-password>' \
HS_TEST_DEBUG_HOST=192.0.2.20 \
HS_TEST_ASSET_SERVER_BASE_URL=http://192.0.2.20:5181 \
HS_TEST_STREAM_BASE_URL=http://192.0.2.20:5180 \
npm run test:ui:roku

Set the asset URL to the public/ server root, without an /asset-bundles suffix. Keep these local addresses out of committed configuration. Retain the report and captures as evidence for the tested Roku model.

First run​

Run the hosanna-samples Browser suite (the script keeps its legacy web suffix):

npm run test:ui:web

A successful run prints the absolute path to test-results/<testRunId>/report.html and updates test-results/latest.html. Open that file in a browser to confirm the runner, application handshake, and reporter all completed.

After the first run, the sample repository can open the latest report for you:

npm run test:ui:report

Next: Writing and Running Tests.

Maintainers with an authorized hosanna-samples checkout can compare integration/hosanna-test.config.ts, integration/global-setup.ts and vitest.integration.config.ts with their application configuration.

Talk to us