Skip to content

test: add integration suite covering cross-module compositions#12

Merged
kelsos merged 1 commit intomainfrom
test/integration-suite
Apr 18, 2026
Merged

test: add integration suite covering cross-module compositions#12
kelsos merged 1 commit intomainfrom
test/integration-suite

Conversation

@kelsos
Copy link
Copy Markdown
Owner

@kelsos kelsos commented Apr 18, 2026

Summary

Populate `packages/plainfp/src/tests/` with the integration suite that the project scope originally planned. Unit + property tests already verify each primitive in isolation; this suite exercises realistic user-facing compositions end to end.

Scenarios

Six files, each stands alone as a readable example of a common usage pattern.

File What it exercises
`parse-validate-transform.int.test.ts` fromZod → Result.flatMap → Result.map → match — parse, business, and domain errors short-circuiting at the right layer
`batch-fetch.int.test.ts` Arrays.map → ResultAsync.fromPromise → ResultAsync.all, plus allWithConcurrency verifying the cap under staggered latencies
`retry-timeout-fetch.int.test.ts` realistic fetch client: fromPromise + retry + timeout + map + mapError. Recovery from transients, giving up after N, and timeout races
`option-result-interop.int.test.ts` lookup → toResult → validate → getOr, plus round-trip invariants (toOption ∘ toResult preserves some, discards the error on none)
`data-pipeline.int.test.ts` the README's headline Arrays.groupBy → Records.mapValues → Arrays.sumBy plus countBy, uniqueBy, and empty-input robustness
`tagged-errors.int.test.ts` Tagged.tag + hasTag composed with Result + mapError + match for exhaustive discriminated-error handling

Why integration tests

Unit tests structurally can't catch:

  • subtle cross-module type weirdness (e.g. Option↔Result interop with narrowing)
  • composition ordering bugs (does Result.mapError preserve tag discriminants?)
  • real-world usage patterns that look fine per-function but surprise in combination

Each scenario is taken straight from the README or the CONTRIBUTING examples, so these tests also serve as executable documentation.

Results

  • 276 total tests passing (was 249; +27 integration cases)
  • Typecheck clean
  • No runtime code changed — purely new test files
  • All test files use realistic domain shapes (users, orders, fetches) rather than foo/bar

Scope doc alignment

Original scope:

Tests colocated (`foo.ts` + `foo.test.ts`); top-level `src/tests/` only for cross-module integration.

`tests/` was created but never populated. This PR fills it.

Test plan

  • All required CI checks pass
  • Coverage report reflects exercised paths in ResultAsync, Option interop, and Records namespaces
  • No CodSpeed regression (these files run as tests, not benches)

Populate packages/plainfp/src/__tests__/ with cross-module integration
tests. Unit + property tests cover the primitives; these tests verify
that realistic user-facing compositions actually work end to end.

Six scenarios, each in its own *.int.test.ts file:

- parse-validate-transform — the canonical fromZod → Result.flatMap →
  Result.map → match pipeline, with parse, business, and domain errors
  short-circuiting at the right layer.
- batch-fetch — Arrays.map over ids into ResultAsync.fromPromise calls,
  collected by ResultAsync.all; plus allWithConcurrency with realistic
  staggered latencies to verify the concurrency cap holds.
- retry-timeout-fetch — a realistic fetch client composed from
  fromPromise + retry + timeout + map + mapError. Covers recovery from
  transient failures, giving up after N attempts, and timeout races.
- option-result-interop — the lookup → toResult → validate → getOr flow
  that lets Option and Result coexist cleanly. Round-trip semantics
  (toOption ∘ toResult preserves some values, discards errors on none)
  are locked in.
- data-pipeline — the README's headline Arrays.groupBy → Records.mapValues
  → Arrays.sumBy example, plus countBy-by-status, uniqueBy dedup, and
  empty-input robustness.
- tagged-errors — Tagged.tag + hasTag composed with Result + mapError +
  match for exhaustive discriminated error handling.

27 new test cases, 276 total passing. No runtime code touched.

These files live under src/__tests__/ as originally planned in the project
scope; individual unit tests continue to be colocated beside the module
they test.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.68%. Comparing base (5153437) to head (003916b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #12      +/-   ##
==========================================
+ Coverage   89.16%   91.68%   +2.51%     
==========================================
  Files          23       23              
  Lines         397      397              
  Branches       90       90              
==========================================
+ Hits          354      364      +10     
+ Misses         13       11       -2     
+ Partials       30       22       -8     
Flag Coverage Δ
unittests 91.68% <ø> (+2.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 18, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks


Comparing test/integration-suite (003916b) with main (5153437)

Open in CodSpeed

@kelsos kelsos merged commit 003916b into main Apr 18, 2026
11 checks passed
@kelsos kelsos deleted the test/integration-suite branch April 18, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant