Skip to content

Switch to Vitest - #73

Merged
NorthernMan54 merged 13 commits into
beta-0.2.4from
configuredName
May 28, 2026
Merged

NorthernMan54 merged 13 commits into
beta-0.2.4from
configuredName

Conversation

@NorthernMan54

Copy link
Copy Markdown
Owner

No description provided.

NorthernMan54 and others added 10 commits May 25, 2026 08:27
* Initial plan

* chore: initial plan for refactor and simplification

Agent-Logs-Url: https://github.com/NorthernMan54/homebridge-tasmota/sessions/c18913f1-ff53-4796-8e72-792c008ddd0b

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>

* refactor: simplify and modernize TasmotaService, platform, and sensor services

Agent-Logs-Url: https://github.com/NorthernMan54/homebridge-tasmota/sessions/c18913f1-ff53-4796-8e72-792c008ddd0b

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
…x, dead null check, dead constructor code + migrate tests to Vitest (#72)

* Initial plan

* fix: code review - fix renameKeys nested objects, MQTT wildcard regex, dead code cleanup

Agent-Logs-Url: https://github.com/NorthernMan54/homebridge-tasmota/sessions/15d8eeef-0f4b-4394-a83f-fff46ca4d9ef

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>

* test: migrate test suite from Jest to Vitest

Agent-Logs-Url: https://github.com/NorthernMan54/homebridge-tasmota/sessions/311eb7ec-cb6a-4c9f-ba63-94f8d65732fd

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Migrates the test framework from Jest to Vitest, deletes the Jest-only skipped tests, and rewrites the remaining tests/mocks to use Vitest APIs. Along the way it also refactors tasmotaPlatform, tasmotaSensorService, and tasmotaBinarySensorService (centralizing service creation, attaching a ConfiguredName set listener, deduplicating dev_cla branches, and recursively renaming nested keys in normalizeMessage).

Changes:

  • Replace Jest tooling/config with Vitest + SWC: update package.json, add vitest.config.ts, delete jest.config.ts and babel.config.js, and adjust tsconfig.json.
  • Refactor tasmotaPlatform (extract createService, simplify discoveryTopicMap classification, attach setConfiguredName listener) and tasmotaSensorService (introduce setupService, simplify branches, fix nunjucks init).
  • Make renameKeys recursive so nested HA discovery device fields are translated; update binary sensor to share the contact/door/doorbell branch; tighten test config with filterAllow.

Reviewed changes

Copilot reviewed 16 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
package.json Switches scripts and devDeps from Jest/ts-jest/babel to Vitest + SWC.
vitest.config.ts New Vitest config (globals, SWC plugin, serial file execution).
tsconfig.json Reworked compiler options; relaxes strict to false and changes types/excludes.
jest.config.ts / babel.config.js Removed Jest/Babel configuration.
src/utils.ts / src/utils.test.ts Make renameKeys recursive on nested objects and add tests for nested device key renaming.
src/TasmotaService.ts Move nunjucks.installJinjaCompat/configure to module init; minor getCurrent cleanups.
src/tasmotaPlatform.ts Extract createService, simplify discovery topic-type classification, attach setConfiguredName listener; remove dead override-injection block.
src/tasmotaSensorService.ts Introduce setupService helper, deduplicate dev_cla branches, refactor statusUpdate, add ConfiguredName guard for power sensors.
src/tasmotaBinarySensorService.ts Collapse doorbell/contact/door into a single branch with class-conditional fakegato.
src/mocks/Mqtt.ts Add sendMessage stub to mock.
src/mocks/mocks.ts Convert helpers to Vitest, export makeMockAPI and mockLog.
src/tasmotaPlatform.test.ts Port platform tests from Jest to Vitest.
src/TasmotaService.test.ts / src/tasmotaSensorService.test.ts Delete the previously skipped Jest test files.
test/hbConfig/config.json Add filterAllow: ["139827"] to discovery filter.
.gitignore Ignore vitest.config.js.map.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tasmotaSensorService.ts
Comment thread src/tasmotaPlatform.ts
Comment on lines +342 to +345
default:
this.log.warn('Warning: Unhandled Tasmota device type', tasmotaType);
return new tasmotaSensorService(this, accessory, uniq_id);
}
Comment thread src/tasmotaPlatform.test.ts Outdated
NorthernMan54 and others added 2 commits May 27, 2026 11:28
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@NorthernMan54
NorthernMan54 merged commit 9512ef7 into beta-0.2.4 May 28, 2026
3 of 6 checks passed
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.

3 participants