Skip to content

Add comprehensive unit testing suite #4

Description

@kalwalt

Problem

The project currently has no unit tests or automated testing suite to verify correctness, filter behaviors, or regression safety of OneEuroFilter.

Proposed Solution

We need to set up a modern, lightweight testing suite (e.g. using Vitest, Jest, or another library that supports TypeScript out-of-the-box).

The test suite should verify:

  • Initial state filtering: Verifying \initialized === false\ path returning a copy of the input.
  • Filtering correctness: Verifying math formulas and exponential smoothing outputs over multiple samples.
  • Dynamic resizing behaviors: Verifying safety when passing vectors of length 3, then resizing to 5.
  • Boundary conditions and safeguards:
    • Zero and negative delta time (\ e <= 0) to verify they don't propagate \NaN.
    • \Float32Array\ and \Float64Array\ type preservation.
  • Performance/Allocation: Verifying the zero-allocation path with the \out\ parameter works correctly.

CI Integration

Set up a GitHub Actions workflow to run the unit test suite automatically on every push to main and all incoming pull requests.

Build System Upgrade

Consider migrating the build/bundling system from Webpack to Vite (which uses Rollup for library builds) for a faster and unified development/build setup since we are using Vitest.

Task List

  • Select and configure a testing framework (e.g., Vitest)
  • Write basic unit tests for initialization and filter state copying
  • Write math/functional correctness unit tests
  • Write dynamic sizing tests
  • Write safeguard tests for zero/negative delta times
  • Set up GitHub Actions workflow (.github/workflows/ci.yml) to run tests automatically
  • Migrate build system from Webpack to Vite
  • Integrate tests into the NPM test script (
    npm run test)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions