Skip to content

Commit ad24610

Browse files
committed
chore: add coverage reporting via coveralls
1 parent 13c730d commit ad24610

File tree

10 files changed

+363
-7
lines changed

10 files changed

+363
-7
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ jobs:
2121
- name: Build libs
2222
run: npm run build
2323
- name: Tests
24-
run: npm run test
24+
run: npm run test:coverage
25+
- name: Upload coverage results to Coveralls
26+
uses: coverallsapp/github-action@v2
27+
with:
28+
base-path: ./packages/mcp-server-supabase

package-lock.json

Lines changed: 192 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
],
55
"scripts": {
66
"build": "npm run build --workspace @supabase/mcp-utils --workspace @supabase/mcp-server-supabase",
7-
"test": "npm run test --workspace @supabase/mcp-utils --workspace @supabase/mcp-server-supabase"
7+
"test": "npm run test --workspace @supabase/mcp-utils --workspace @supabase/mcp-server-supabase",
8+
"test:coverage": "npm run test:coverage --workspace @supabase/mcp-server-supabase"
89
},
910
"devDependencies": {
1011
"supabase": "^2.1.1"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/coverage

packages/mcp-server-supabase/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"test": "vitest",
1414
"test:e2e": "vitest --project e2e",
1515
"test:unit": "vitest --project unit",
16+
"test:coverage": "vitest --coverage",
1617
"generate:management-api-types": "openapi-typescript https://api.supabase.com/api/v1-json -o ./src/management-api/types.ts"
1718
},
1819
"files": [
@@ -42,6 +43,7 @@
4243
"@total-typescript/tsconfig": "^1.0.4",
4344
"@types/common-tags": "^1.8.4",
4445
"@types/node": "^22.8.6",
46+
"@vitest/coverage-v8": "^2.1.9",
4547
"ai": "^4.3.4",
4648
"date-fns": "^4.1.0",
4749
"dotenv": "^16.5.0",
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2+
import { StreamTransport } from '@supabase/mcp-utils';
3+
import { describe, expect, test } from 'vitest';
4+
import {
5+
ACCESS_TOKEN,
6+
API_URL,
7+
MCP_CLIENT_NAME,
8+
MCP_CLIENT_VERSION,
9+
} from '../test/mocks.js';
10+
import { createSupabaseMcpServer } from './index.js';
11+
12+
type SetupOptions = {
13+
accessToken?: string;
14+
projectId?: string;
15+
readOnly?: boolean;
16+
};
17+
18+
async function setup(options: SetupOptions = {}) {
19+
const { accessToken = ACCESS_TOKEN, projectId, readOnly } = options;
20+
const clientTransport = new StreamTransport();
21+
const serverTransport = new StreamTransport();
22+
23+
clientTransport.readable.pipeTo(serverTransport.writable);
24+
serverTransport.readable.pipeTo(clientTransport.writable);
25+
26+
const client = new Client(
27+
{
28+
name: MCP_CLIENT_NAME,
29+
version: MCP_CLIENT_VERSION,
30+
},
31+
{
32+
capabilities: {},
33+
}
34+
);
35+
36+
const server = createSupabaseMcpServer({
37+
platform: {
38+
apiUrl: API_URL,
39+
accessToken,
40+
},
41+
projectId,
42+
readOnly,
43+
});
44+
45+
await server.connect(serverTransport);
46+
await client.connect(clientTransport);
47+
48+
return { client, clientTransport, server, serverTransport };
49+
}
50+
51+
describe('index', () => {
52+
test('index.ts exports a working server', async () => {
53+
const { client } = await setup();
54+
55+
const { tools } = await client.listTools();
56+
57+
expect(tools.length).toBeGreaterThan(0);
58+
});
59+
});

0 commit comments

Comments
 (0)