Helios’s test suite focuses onDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/V3RNE42/helios/llms.txt
Use this file to discover all available pages before exploring further.
computeRouteSections — the core solar routing algorithm — which is designed to be pure and dependency-injectable, making it straightforward to test without a browser or API keys.
Running the tests
Run the full test suite from the project root:vitest run (a single non-watch pass) and processes routeSolar.test.js. No browser, no live network requests, no build step required.
No environment variables or API keys are required to run the tests. The
getOffset dependency is injected as a mock — async () => 2 — so the timezone serverless function is never called.engines field of package.json:
What is tested
routeSolar.test.js contains two describe blocks.
computeRouteSections
Four focused unit tests exercise the algorithm across its main operating modes:
-
Daytime north-to-south trip — A Madrid → Málaga journey on 15 June 2026 (09:00–15:00 UTC, midsummer). Asserts that
night === false, that the returnedsectionsarray contains at least two dated entries, that the first entry’s timestamp equals the departure time, and that the last entry’s timestamp equals the arrival time. -
Fully nocturnal trip — An Oslo → Oslo trip on 15 January 2026 (20:00 UTC departure, 04:00 UTC arrival the following day). January nights in Oslo are long enough that the entire journey falls outside daylight. Asserts
night === trueand that at least two sections are returned without throwing. - Multi-day trip — A Madrid → Málaga journey spanning three days (15–18 June 2026). Asserts that the sections array has more than two entries and that every consecutive pair of timestamps is strictly increasing, confirming the algorithm marches forward through time correctly.
-
Convergence failure — Passes a degenerate
getDayInfostub that always returnsnew Date(0)for both sunrise and sunset, ensuring the inner convergence loop can never be satisfied. Asserts thatcomputeRouteSectionsthrows rather than hanging indefinitely (the function enforces a hard limit of 100 000 inner iterations before raising an error).
consistencia entre las dos implementaciones solares
One cross-implementation sanity check:
- Solar noon agreement — Calls both
getTimes(d, lat, lon).solarNoon(fromsuncalc.js) andgetDayInfo(d, lat, lon).transit(fromSunCalc_function.js) with the same date and Madrid coordinates, then asserts that the two values agree to within 5 minutes. This guards against drift between the two solar libraries that ship with Helios.
Test fixtures
Three coordinate constants are defined at the top ofrouteSolar.test.js and reused across tests:
| Constant | Coordinates | Purpose |
|---|---|---|
MADRID | { lat: 40.4168, lon: -3.7038 } | Origin for north → south daytime trips |
MALAGA | { lat: 36.7213, lon: -4.4214 } | Destination for Madrid-based trips |
OSLO | { lat: 59.9139, lon: 10.7522 } | High-latitude location for polar/nocturnal edge cases |
fakeOffset stub — async () => 2 — is declared once and passed as getOffset for every test. Because all tests use local: false, getOffset is never actually invoked by the algorithm; the stub exists only to satisfy the function signature.
Writing new tests
To add a test case:- Import
computeRouteSectionsfrom./routeSolar.js. - Import
sunCalcFactoryfrom./SunCalc_function.jsto obtain a realgetDayInfo. - Pass
async () => 0as agetOffsetstub for any test that does not exercise timezone-offset logic. Note that the existing suite usesasync () => 2— the value returned does not affect the algorithm whenlocal: false, so either constant works; using0in new tests avoids implying a specific UTC offset. - Set
local: trueand supply a real (or more elaborate) asyncgetOffsetstub only when you specifically need to test how the UI renders UTC-offset data.
What is not tested
The test suite covers only the pure algorithmic core. The following are not covered by automated tests:- Browser UI (
index_def.js) — the multi-step form, validation, and results rendering have no automated tests. - Serverless functions (
api/geocode.js,api/timezone.js) — the Nominatim/OpenCage geocoding pipeline and the ipgeolocation.io/TimeZoneDB timezone pipeline are untested. - Live API integration — no test makes a real network call to any geocoding or timezone service.