Skip to content

test: add perf core and Orama index unit tests#278

Merged
d-oit merged 1 commit into
mainfrom
test/perf-and-orama-coverage
Jun 5, 2026
Merged

test: add perf core and Orama index unit tests#278
d-oit merged 1 commit into
mainfrom
test/perf-and-orama-coverage

Conversation

@d-oit
Copy link
Copy Markdown
Owner

@d-oit d-oit commented Jun 5, 2026

Summary

Adds 23 new unit tests for performance monitoring and Orama search index modules.

Changes

  • perf-core.test.ts (NEW): 15 tests — mark/measure, entries, stats, categories, MAX_ENTRIES cap
  • orama-index.test.ts (NEW): 8 tests — map add/overwrite/eviction, clear, create index

Results

  • Full suite: 351/351 tests pass
  • Lint clean ✅

Co-authored-by: d-oit 6849456+d-oit@users.noreply.github.com

- perf-core.test.ts: 15 tests covering mark/measure, getEntries,
  getEntriesByName, getStats, getAllStats, getStatsByCategory (all
  10 category prefixes), clear, and MAX_ENTRIES cap
- orama-index.test.ts: 8 tests covering addToOramaMap (add, overwrite,
  eviction at 10000), clearOramaDb, createOramaIndex

Total suite: 351 tests across 30 files.

Co-authored-by: d-oit <6849456+d-oit@users.noreply.github.com>
@d-oit d-oit merged commit 8afa028 into main Jun 5, 2026
0 of 2 checks passed
@d-oit d-oit deleted the test/perf-and-orama-coverage branch June 5, 2026 16:05
@github-actions github-actions Bot added config tests Related to automated/manual tests labels Jun 5, 2026
@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented Jun 5, 2026

DeepSource Code Review

We reviewed changes in 09d9eab...d161672 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Jun 5, 2026 4:05p.m. Review ↗
Python Jun 5, 2026 4:05p.m. Review ↗
Shell Jun 5, 2026 4:05p.m. Review ↗
SQL Jun 5, 2026 4:05p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

perf.measure('stats-test', 's');
const stats = perf.getStats('stats-test');
expect(stats).not.toBeNull();
expect(stats!.name).toBe('stats-test');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

const stats = perf.getStats('stats-test');
expect(stats).not.toBeNull();
expect(stats!.name).toBe('stats-test');
expect(stats!.count).toBe(1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

expect(stats).not.toBeNull();
expect(stats!.name).toBe('stats-test');
expect(stats!.count).toBe(1);
expect(typeof stats!.avgMs).toBe('number');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

expect(stats!.name).toBe('stats-test');
expect(stats!.count).toBe(1);
expect(typeof stats!.avgMs).toBe('number');
expect(typeof stats!.minMs).toBe('number');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

expect(stats!.count).toBe(1);
expect(typeof stats!.avgMs).toBe('number');
expect(typeof stats!.minMs).toBe('number');
expect(typeof stats!.maxMs).toBe('number');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

expect(typeof stats!.avgMs).toBe('number');
expect(typeof stats!.minMs).toBe('number');
expect(typeof stats!.maxMs).toBe('number');
expect(typeof stats!.lastMs).toBe('number');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

expect(names).toContain('group-b');

const groupA = allStats.find(s => s.name === 'group-a');
expect(groupA!.count).toBe(2);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

for (const { name, expected } of testCases) {
const stats = byCategory.get(expected);
expect(stats, `Category '${expected}' should exist for '${name}'`).toBeDefined();
expect(stats!.some(s => s.name === name)).toBe(true);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forbidden non-null assertion


Using non-null assertions cancels out the benefits of strict null-checking, and introduces the possibility of runtime errors. Avoid non-null assertions unless absolutely necessary. If you still need to use one, write a skipcq comment to explain why it is safe.

@codacy-production
Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 48 complexity · 0 duplication

Metric Results
Complexity 48
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config tests Related to automated/manual tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants