Repository navigation
Rewrite the test suite: Vitest, real netCDF fixtures, no built-in mocks - #72
Merged
Merged
Conversation
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tackling #65 and #31. Looks scarier than it actually is.
The old tests never touched the WASM module. Both Jest and Vitest set
NODE_ENV=test, and in that case the library switched to built-in mocks. So the 159 tests only ever tested the mock. This PR removes the mocks and replaces the suite with tests that run against the real WASM module and real netCDF files.Changes
tests/directory, split intounit/(no WASM needed) andwasm/(real reads and writes). The setup compiles the WASM once per test file, so the suite runs in under a second.tests/fixtures/generate.py. They cover all numeric types, strings, chars, enums, groups, the classic format, and every supported compression: zlib, zstd, bzip2 and Blosc. szip is included as a negative case.netcdf4.ts,group.tsandvariable.ts, along withsrc/test-setup.ts, which was being shipped indist/. There are no other changes to production code.TEST_DOCUMENTATION.mdwere dropped.tests/README.mdis new, and README and CONTRIBUTING are updated.typecheck,lintandformatchecknow includetests/.Known bugs
The new tests found several bugs. Each one is recorded as a
test.failstest, so CI stays green and the test turns red once the bug is fixed:nc_enddef),setAttrdoesn't write to the file. This is due that file writing is not really implemented._FillValuecan't be opened.isUnlimitedis alwaysfalse.getVariableInfodoesn't reject unknown names.file_formatignores the actual file format. (seefile_formatanddisk_formatreport the requested format, not the file's actual format #71)Testing
npm run build && npm test: 90 passed, 8 expected failures.src/, measured against real code instead of the mocks.