Files
metapi/src/server/nativeModuleGuard.test.ts
T
cita 2a810facb8 feat: implement macOS notarization and ad-hoc signing in afterSign script
feat: add run-server script to manage server execution and compatibility checks

feat: create main application logic for desktop with window management, server handling, and auto-updater

test: add unit tests for desktop runtime helpers

feat: implement desktop server environment configuration and health check

test: add tests for server configuration and desktop routes

feat: add native module guard for better-sqlite3 compatibility

test: add tests for native module guard functionality

test: add comprehensive tests for account verification feedback handling

feat: implement account verification feedback helpers

chore: add TypeScript configuration for desktop builds
2026-03-06 16:24:41 +08:00

41 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
buildBetterSqliteRebuildCommand,
isNodeModuleVersionMismatch,
} from './nativeModuleGuard.js';
describe('nativeModuleGuard', () => {
it('detects better-sqlite3 ABI mismatch errors', () => {
const error = Object.assign(
new Error('NODE_MODULE_VERSION 133. This version of Node.js requires NODE_MODULE_VERSION 137.'),
{ code: 'ERR_DLOPEN_FAILED' },
);
expect(isNodeModuleVersionMismatch(error)).toBe(true);
});
it('ignores unrelated native module errors', () => {
const error = Object.assign(
new Error('Cannot find module'),
{ code: 'MODULE_NOT_FOUND' },
);
expect(isNodeModuleVersionMismatch(error)).toBe(false);
});
it('builds a rebuild command for the current npm client', () => {
const command = buildBetterSqliteRebuildCommand({
npmExecPath: '/tmp/npm-cli.js',
});
expect(command.command).toBe(process.execPath);
expect(command.args).toEqual([
'/tmp/npm-cli.js',
'rebuild',
'better-sqlite3',
'--no-audit',
'--fund=false',
]);
});
});