Test your application before preview
Generate backend tests, reproduce a failed assertion locally and inspect the hosted result in the project IDE.
Last updated 2026-11-25
What you'll achieve
- Generate and run native JavaScript backend tests with the CLI
- Reproduce a failing preview check and confirm the fix
- Inspect local reports and verified hosted results in the project IDE
Run your first two tests
With BlinkHost CLI 2.8.0 and Node.js 22.18 or newer installed, create a JavaScript backend module with its native tests. Run these commands from a directory where you want to create the example.
blinkhost create order-api --template html --module api:javascript --tests --no-install
cd order-api
blinkhost test . --json > blinkhost-test-report.json
Open tests/native/api/handler.test.mjs to see the two cases. The first checks the handler’s status, content type and response body with three different inputs. The second checks that the handler reports a request parsing error. In the JSON report, the api-native check identifies the runner and includes the individual test results.
The CLI also generates native tests for TypeScript, Python, Go and Rust backend modules. Select your module’s language at creation and install its toolchain locally. In an existing project, use blinkhost.tests.json to name the checks, choose runners and specify arguments. Add integration and browser checks for behavior that depends on a compiled module, a database or the browser.
Require a check before requesting preview
For this example, save the following as blinkhost.gates.json alongside blinkhost.yaml. In your own project, list the source files, built artifacts, dependencies, runtime settings, resource descriptions and fixtures that affect the result. Use relative file paths. Keep credentials out of these files.
{
"schema": "blinkhost.local-test-gates/v1",
"inputs": {
"source": ["_server_islands/api/index.js", "tests/native/api/handler.test.mjs"],
"artifacts": [],
"dependencies": ["_server_islands/api/package.json", "_server_islands/api/package-lock.json"],
"runtime": ["_server_islands/api/blinkhost.toml"],
"resources": [],
"fixtures": []
},
"stages": {"preview": ["api-native"]}
}
blinkhost test . --gate preview --json > blinkhost-test-report.json
A passing run exits with status zero. To try the failure path, change the example handler’s response status from 200 to 201 and repeat the command. It exits with a failure and writes the failed assertion to the report. Restore the status and rerun to confirm the fix. Run the command for each independently deployable project in a monorepo.
Inspect local and hosted results
Open Tests in the project IDE and choose Inspect local test results to load your JSON report. Use Local check to inspect to see its test names, durations and error details. Coverage appears when the runner supplies it. The file stays in your browser tab.
For an environment using required hosted checks, choose Saved build to inspect, select the exact build, and use Refresh tests. The server checks the isolated worker’s result before activating a protected upload. A failure, cancellation or expired result keeps the candidate private and the previous release available. A local report can help you reproduce the failure. Only a verified hosted result for the current release can satisfy its deployment rule.
Help improve this page
Sign in to send page-specific feedback. For account-specific help, email support@blinkhost.me.