Switch to Vitest - #73
Merged
Merged
Conversation
* 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>
There was a problem hiding this comment.
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, addvitest.config.ts, deletejest.config.tsandbabel.config.js, and adjusttsconfig.json. - Refactor
tasmotaPlatform(extractcreateService, simplifydiscoveryTopicMapclassification, attachsetConfiguredNamelistener) andtasmotaSensorService(introducesetupService, simplify branches, fix nunjucks init). - Make
renameKeysrecursive so nested HA discoverydevicefields are translated; update binary sensor to share the contact/door/doorbell branch; tighten test config withfilterAllow.
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 on lines
+342
to
+345
| default: | ||
| this.log.warn('Warning: Unhandled Tasmota device type', tasmotaType); | ||
| return new tasmotaSensorService(this, accessory, uniq_id); | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
No description provided.