Testing
This project treats the normalized abstraction as the product. Tests are designed to prove that MoTeC, Pi/Cosworth, and VBOX files all expose the same query API and units.
Run tests
pnpm install
pnpm testpnpm test runs:
- pure unit tests for channel resolution, unit transforms, matrix resampling, GPS, lap classification, and edge cases
- synthetic cross-format abstraction tests
- a public VBO real-fixture abstraction test
Fixture strategy
The public repo includes only shareable telemetry fixtures. Proprietary MoTeC and PDS files are intentionally not committed.
fixtures/vbo/25IT04_RdAm_PT2_Run01_RD.vboSynthetic tests cover cross-format MoTeC/PDS/VBO normalization semantics without requiring proprietary files. Fixture-dependent tests skip automatically when the corresponding file is not present.
The exhaustive fixture suite can be run locally when all large private fixtures are available:
pnpm test:fixturesWhat fixture abstraction tests assert
For every selected real file, src/__tests__/fixture-abstraction.test.ts checks:
- session parses successfully
format,id,sampleRate,totalDuration,totalDistance, andlapCountare coherent- required canonical channels exist:
timedistancetrackPositionspeedthrottle
- normalized units are correct:
- speed in
km/h - distance in
m - throttle in
ratio - GPS in decimal degrees
- pressure in
bar
- speed in
- required channels contain finite values
- time and distance are monotonic
- speed, throttle, track position, and GPS ranges are plausible
Session.channel()is the same data asChannelMatrix.row()Lap.channel()is a zero-copy subarray viewLapSample.get(name)matches typed getters- missing optional data returns
null
Synthetic abstraction tests
src/__tests__/abstraction.test.ts builds synthetic MoTeC-like, PDS-like, and VBO-like sessions with equivalent physical data but different raw names and units.
For example, the same speed trace may be represented as:
- MoTeC:
Corr Speed,m/s - PDS:
Speed,km/h - VBO:
Vehicle_Speed,mph
The test asserts all three produce the same canonical speed channel in km/h.
Adding a new channel
When adding a canonical channel:
- add aliases to
CHANNEL_PRIORITIESinsrc/channels.ts - add or reuse a unit transform
- add the canonical unit to
NORMALIZED_CHANNEL_UNITS - expose a typed getter on
LapSampleif it is common enough - update
ChannelAvailabilityif it belongs in a grouped flag - add synthetic tests for name resolution and unit normalization
- add fixture assertions if real files contain the channel
Adding a new fixture
Prefer small representative files. If a large file is necessary, keep only one or two per format/category.
Checklist:
- put file under
fixtures/<format>/ - update
.gitignoreallow-list only if it is public/shareable and should be committed - add it to
FIXTURE_CASESinsrc/__tests__/fixture-abstraction.test.ts - assert only format-appropriate requirements
- run
pnpm test
CI expectation
The default CI command should be:
pnpm install --frozen-lockfile
pnpm test
pnpm docs:build