Skip to content

Various unit test fixes for unit:security#115

Merged
DavidCockerill merged 2 commits intoadd-unit-testsfrom
fix-test-unit-security
Jan 23, 2026
Merged

Various unit test fixes for unit:security#115
DavidCockerill merged 2 commits intoadd-unit-testsfrom
fix-test-unit-security

Conversation

@DavidCockerill
Copy link
Member

Security unit test fixes

Fixes: #77

@DavidCockerill DavidCockerill requested a review from a team as a code owner January 21, 2026 20:24
Copy link
Member

@kriszyp kriszyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you for the help with this!

"test:unit:apitests": "node ./dist/bin/harper.js stop && mocha 'unitTests/apiTests/**/*-test.mjs' --config unitTests/.mocharc.json --enable-source-maps",
"test:unit:logging": "mocha 'unitTests/utility/logging/*.js' --config unitTests/.mocharc.json --enable-source-maps",
"test:unit:security": "mocha 'unitTests/security/**/*.js' --config unitTests/.mocharc.json --enable-source-maps",
"test:unit:security": "node --expose-internals node_modules/.bin/_mocha 'unitTests/security/**/*.js' --config unitTests/.mocharc.json --enable-source-maps",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to add this so the jsLoader error checking unit tests would pass. Without it the error stacks don’t include filenames. I’m not entirely sure why this works, but it’s used the same way in harperdb.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an artifact from the PR that added this feature in harperdb : https://github.com/HarperFast/harperdb/pull/2515

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got curious about this and found that the additions to unitTests/.mocharc.json in 10fb9f9 preserve the ability to run these with just npm run test:unit unitTests/security. The expose-internals option doesn't seem to negatively impact the other tests and excluding the jsLoader/fixture modules make mocha's recursive test search much happier (because some of those are intentionally invalid).

Copy link
Member

@kriszyp kriszyp Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using node node_modules/.bin/_mocha instead of mocha? That's not necessary, right? (based on Ethan's commit, looks like we have another, cleaner way to pass in --expose-internals)
Obviously I've already approved this, just curious :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using node node_modules/.bin/_mocha instead of mocha? That's not necessary, right? (based on Ethan's commit, looks like we have another, cleaner way to pass in --expose-internals) Obviously I've already approved this, just curious :).

It does not seem to be necessary with my changes to .mocharc.json.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to do a broader cleanup of those test scripts in package.json in the main-branch-targeting PR I'll put together once this PR is merged. So IMO this is good to go as-is.

@DavidCockerill DavidCockerill merged commit ea7d5bb into add-unit-tests Jan 23, 2026
15 of 22 checks passed
@DavidCockerill DavidCockerill deleted the fix-test-unit-security branch January 23, 2026 20:33
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.

4 participants