Skip to content

Commit 8a9eb9c

Browse files
committed
fix(packages/node): test with vitest instead of native node
1 parent 8cfa65c commit 8a9eb9c

File tree

4 files changed

+47
-66
lines changed

4 files changed

+47
-66
lines changed

packages/node/generate-platform-packages.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* node generate-platform-packages.js <version> <artifacts-dir> <output-dir>
1111
*
1212
* Example:
13-
* node generate-platform-packages.js 0.9.42 ./artifacts ./platform-packages
13+
* node generate-platform-packages.js 0.9.43 ./artifacts ./platform-packages
1414
*/
1515

1616
const fs = require('fs');
@@ -165,7 +165,7 @@ function main() {
165165

166166
if (args.length < 3) {
167167
console.error('Usage: node generate-platform-packages.js <version> <artifacts-dir> <output-dir>');
168-
console.error('Example: node generate-platform-packages.js 0.9.42 ./artifacts ./platform-packages');
168+
console.error('Example: node generate-platform-packages.js 0.9.43 ./artifacts ./platform-packages');
169169
process.exit(1);
170170
}
171171

@@ -181,7 +181,7 @@ function main() {
181181
// Validate version format
182182
if (!/^\d+\.\d+\.\d+$/.test(version)) {
183183
console.error(`Error: Invalid version format: ${version}`);
184-
console.error('Version must be in semver format (e.g., 0.9.42)');
184+
console.error('Version must be in semver format (e.g., 0.9.43)');
185185
process.exit(1);
186186
}
187187

packages/node/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sqliteai/sqlite-vector",
3-
"version": "0.9.42",
3+
"version": "0.9.43",
44
"description": "SQLite vector search extension for Node.js - Cross-platform vector embeddings and similarity search",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",
@@ -25,7 +25,7 @@
2525
"scripts": {
2626
"build": "tsup",
2727
"prepublishOnly": "npm run build",
28-
"test": "node --test dist/index.test.js",
28+
"test": "vitest",
2929
"typecheck": "tsc --noEmit",
3030
"generate-platforms": "node generate-platform-packages.js"
3131
},
@@ -55,17 +55,18 @@
5555
"node": ">=16.0.0"
5656
},
5757
"optionalDependencies": {
58-
"@sqliteai/sqlite-vector-darwin-arm64": "0.9.42",
59-
"@sqliteai/sqlite-vector-darwin-x86_64": "0.9.42",
60-
"@sqliteai/sqlite-vector-linux-arm64": "0.9.42",
61-
"@sqliteai/sqlite-vector-linux-arm64-musl": "0.9.42",
62-
"@sqliteai/sqlite-vector-linux-x86_64": "0.9.42",
63-
"@sqliteai/sqlite-vector-linux-x86_64-musl": "0.9.42",
64-
"@sqliteai/sqlite-vector-win32-x86_64": "0.9.42"
58+
"@sqliteai/sqlite-vector-darwin-arm64": "0.9.43",
59+
"@sqliteai/sqlite-vector-darwin-x86_64": "0.9.43",
60+
"@sqliteai/sqlite-vector-linux-arm64": "0.9.43",
61+
"@sqliteai/sqlite-vector-linux-arm64-musl": "0.9.43",
62+
"@sqliteai/sqlite-vector-linux-x86_64": "0.9.43",
63+
"@sqliteai/sqlite-vector-linux-x86_64-musl": "0.9.43",
64+
"@sqliteai/sqlite-vector-win32-x86_64": "0.9.43"
6565
},
6666
"devDependencies": {
6767
"@types/node": "^20.0.0",
6868
"tsup": "^8.0.0",
69-
"typescript": "^5.3.0"
69+
"typescript": "^5.3.0",
70+
"vitest": "^3.2.4"
7071
}
7172
}

packages/node/src/index.test.ts

Lines changed: 32 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { test, describe } from 'node:test';
2-
import assert from 'node:assert';
1+
import { describe, it, expect } from 'vitest';
32
import {
43
getCurrentPlatform,
54
getPlatformPackageName,
@@ -8,10 +7,10 @@ import {
87
getExtensionPath,
98
getExtensionInfo,
109
ExtensionNotFoundError
11-
} from './index.js';
10+
} from './index';
1211

1312
describe('Platform Detection', () => {
14-
test('getCurrentPlatform() returns a valid platform', () => {
13+
it('getCurrentPlatform() returns a valid platform', () => {
1514
const platform = getCurrentPlatform();
1615
const validPlatforms = [
1716
'darwin-arm64',
@@ -23,87 +22,68 @@ describe('Platform Detection', () => {
2322
'win32-x86_64',
2423
];
2524

26-
assert.ok(
27-
validPlatforms.includes(platform),
28-
`Platform ${platform} should be one of: ${validPlatforms.join(', ')}`
29-
);
25+
expect(validPlatforms).toContain(platform);
3026
});
3127

32-
test('getPlatformPackageName() returns correct package name format', () => {
28+
it('getPlatformPackageName() returns correct package name format', () => {
3329
const packageName = getPlatformPackageName();
3430

35-
assert.ok(
36-
packageName.startsWith('@sqliteai/sqlite-vector-'),
37-
'Package name should start with @sqliteai/sqlite-vector-'
38-
);
31+
expect(packageName.startsWith('@sqliteai/sqlite-vector-')).toBe(true);
3932

40-
assert.match(
41-
packageName,
42-
/^@sqliteai\/sqlite-vector-(darwin|linux|win32)-(arm64|x86_64)(-musl)?$/,
43-
'Package name should match expected format'
33+
expect(packageName).toMatch(
34+
/^@sqliteai\/sqlite-vector-(darwin|linux|win32)-(arm64|x86_64)(-musl)?$/
4435
);
4536
});
4637

47-
test('getBinaryName() returns correct extension', () => {
38+
it('getBinaryName() returns correct extension', () => {
4839
const binaryName = getBinaryName();
4940

50-
assert.match(
51-
binaryName,
52-
/^vector\.(dylib|so|dll)$/,
53-
'Binary name should be vector.dylib, vector.so, or vector.dll'
41+
expect(binaryName).toMatch(
42+
/^vector\.(dylib|so|dll)$/
5443
);
5544
});
5645

57-
test('isMusl() returns a boolean', () => {
58-
const result = isMusl();
59-
assert.strictEqual(typeof result, 'boolean');
46+
it('isMusl() returns a boolean', () => {
47+
expect(typeof isMusl()).toBe('boolean');
6048
});
6149
});
6250

6351
describe('Extension Path Resolution', () => {
64-
test('getExtensionPath() returns a string or throws', () => {
52+
it('getExtensionPath() returns a string or throws', () => {
6553
try {
6654
const path = getExtensionPath();
67-
assert.strictEqual(typeof path, 'string');
68-
assert.ok(path.length > 0, 'Path should not be empty');
55+
expect(typeof path).toBe('string');
56+
expect(path.length).toBeGreaterThan(0);
6957
} catch (error) {
70-
// If it throws, it should be ExtensionNotFoundError
71-
assert.ok(
72-
error instanceof ExtensionNotFoundError,
73-
'Should throw ExtensionNotFoundError if extension not found'
74-
);
58+
expect(error instanceof ExtensionNotFoundError).toBe(true);
7559
}
7660
});
7761

78-
test('getExtensionInfo() returns complete info object', () => {
62+
it('getExtensionInfo() returns complete info object', () => {
7963
try {
8064
const info = getExtensionInfo();
8165

82-
assert.ok(info.platform, 'Should have platform');
83-
assert.ok(info.packageName, 'Should have packageName');
84-
assert.ok(info.binaryName, 'Should have binaryName');
85-
assert.ok(info.path, 'Should have path');
66+
expect(info.platform).toBeTruthy();
67+
expect(info.packageName).toBeTruthy();
68+
expect(info.binaryName).toBeTruthy();
69+
expect(info.path).toBeTruthy();
8670

87-
assert.strictEqual(typeof info.platform, 'string');
88-
assert.strictEqual(typeof info.packageName, 'string');
89-
assert.strictEqual(typeof info.binaryName, 'string');
90-
assert.strictEqual(typeof info.path, 'string');
71+
expect(typeof info.platform).toBe('string');
72+
expect(typeof info.packageName).toBe('string');
73+
expect(typeof info.binaryName).toBe('string');
74+
expect(typeof info.path).toBe('string');
9175
} catch (error) {
92-
// If it throws, it should be ExtensionNotFoundError
93-
assert.ok(
94-
error instanceof ExtensionNotFoundError,
95-
'Should throw ExtensionNotFoundError if extension not found'
96-
);
76+
expect(error instanceof ExtensionNotFoundError).toBe(true);
9777
}
9878
});
9979
});
10080

10181
describe('Error Handling', () => {
102-
test('ExtensionNotFoundError has correct properties', () => {
82+
it('ExtensionNotFoundError has correct properties', () => {
10383
const error = new ExtensionNotFoundError('Test message');
10484

105-
assert.ok(error instanceof Error);
106-
assert.strictEqual(error.name, 'ExtensionNotFoundError');
107-
assert.strictEqual(error.message, 'Test message');
85+
expect(error instanceof Error).toBe(true);
86+
expect(error.name).toBe('ExtensionNotFoundError');
87+
expect(error.message).toBe('Test message');
10888
});
109-
});
89+
});

src/sqlite-vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
extern "C" {
2525
#endif
2626

27-
#define SQLITE_VECTOR_VERSION "0.9.42"
27+
#define SQLITE_VECTOR_VERSION "0.9.43"
2828

2929
SQLITE_VECTOR_API int sqlite3_vector_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
3030

0 commit comments

Comments
 (0)