Add comprehensive Home Assistant WebSocket and API tests

- Created detailed test suite for Home Assistant WebSocket client
- Implemented tests for WebSocket connection, authentication, and error handling
- Added comprehensive test coverage for HassInstanceImpl API methods
- Mocked WebSocket and fetch to simulate various connection scenarios
- Covered authentication, state retrieval, service calls, and environment configuration
- Improved test infrastructure for Home Assistant integration
This commit is contained in:
jango-blockchained
2025-01-31 20:29:24 +01:00
parent 90cf0ca315
commit 59cbd2552b
6 changed files with 410 additions and 131 deletions

View File

@@ -6,15 +6,28 @@ module.exports = (request, options) => {
return path.resolve(__dirname, 'node_modules', request.replace('#', ''));
}
// Handle .js extensions for TypeScript files
if (request.endsWith('.js')) {
const tsRequest = request.replace(/\.js$/, '.ts');
try {
return options.defaultResolver(tsRequest, options);
} catch (e) {
// If the .ts file doesn't exist, continue with the original request
}
}
// Call the default resolver
return options.defaultResolver(request, {
...options,
// Force node to resolve modules as CommonJS
// Handle ESM modules
packageFilter: pkg => {
if (pkg.type === 'module') {
pkg.type = 'commonjs';
if (pkg.exports && pkg.exports.import) {
// Preserve ESM modules
if (pkg.type === 'module' && pkg.exports) {
// If there's a specific export for the current conditions, use that
if (pkg.exports.import) {
pkg.main = pkg.exports.import;
} else if (typeof pkg.exports === 'string') {
pkg.main = pkg.exports;
}
}
return pkg;