Skip to content

Commit d520e83

Browse files
authored
Merge pull request #73 from supabase-community/chore/coveralls
chore: add coverage reporting via coveralls
2 parents 13c730d + f7fb13b commit d520e83

File tree

11 files changed

+392
-29
lines changed

11 files changed

+392
-29
lines changed

.github/workflows/tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ jobs:
1919
- name: Install dependencies
2020
run: npm ci --ignore-scripts
2121
- name: Build libs
22-
run: npm run build
22+
run: |
23+
npm run build
24+
npm rebuild # To create bin links
2325
- name: Tests
24-
run: npm run test
26+
run: npm run test:coverage
27+
- name: Upload coverage results to Coveralls
28+
uses: coverallsapp/github-action@v2
29+
with:
30+
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"build": "tsup --clean",
1212
"prepublishOnly": "npm run build",
1313
"test": "vitest",
14-
"test:e2e": "vitest --project e2e",
1514
"test:unit": "vitest --project unit",
15+
"test:e2e": "vitest --project e2e",
16+
"test:integration": "vitest --project integration",
17+
"test:coverage": "vitest --coverage",
1618
"generate:management-api-types": "openapi-typescript https://api.supabase.com/api/v1-json -o ./src/management-api/types.ts"
1719
},
1820
"files": [
@@ -42,6 +44,7 @@
4244
"@total-typescript/tsconfig": "^1.0.4",
4345
"@types/common-tags": "^1.8.4",
4446
"@types/node": "^22.8.6",
47+
"@vitest/coverage-v8": "^2.1.9",
4548
"ai": "^4.3.4",
4649
"date-fns": "^4.1.0",
4750
"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)