Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(core): add test coverage configuration #1594

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ tmp

# IDE
.idea
coverage
1 change: 1 addition & 0 deletions packages/core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ ponder-env.d.ts
generated/
.env.local
**/*.node
tsconfig.vitest-temp.json
10 changes: 6 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"!**/*.test.ts",
"!**/*.test-d.ts",
"!**/*.tsbuildinfo",
"!**/coverage/**/*",
"CHANGELOG.md"
],
"bin": {
Expand Down Expand Up @@ -82,9 +83,9 @@
"stacktrace-parser": "^0.1.10",
"superjson": "^2.2.2",
"terminal-size": "^4.0.0",
"vite": "5.0.7",
"vite-node": "1.0.2",
"vite-tsconfig-paths": "4.3.1"
"vite": "6.2.1",
"vite-node": "3.0.8",
"vite-tsconfig-paths": "5.1.4"
},
"devDependencies": {
"@pgsql/types": "16.0.0",
Expand All @@ -96,12 +97,13 @@
"@types/pg-copy-streams": "^1.2.5",
"@types/semver": "^7.5.8",
"@viem/anvil": "^0.0.6",
"@vitest/coverage-v8": "^3.0.8",
"@wagmi/cli": "^1.5.2",
"chokidar": "^4.0.3",
"execa": "^8.0.1",
"rimraf": "^5.0.5",
"tsx": "^4.19.2",
"vitest": "^1.0.2"
"vitest": "^3.0.8"
},
"engines": {
"node": ">=18.14"
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/build/configAndIndexingFunctions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ test("buildConfigAndIndexingFunctions() builds topics for event filter", async (
});

expect(sources).toHaveLength(1);
expect((sources[0]!.filter as LogFilter).topic0).toMatchObject(
expect((sources[0]!.filter as LogFilter).topic0).toEqual(
toEventSelector(event0),
);
expect((sources[0]!.filter as LogFilter).topic1).toMatchObject(bytes1);
expect((sources[0]!.filter as LogFilter).topic1).toEqual(bytes1);
});

test("buildConfigAndIndexingFunctions() builds topics for multiple event filters", async () => {
Expand Down Expand Up @@ -222,17 +222,17 @@ test("buildConfigAndIndexingFunctions() builds topics for multiple event filters
});

expect(sources).toHaveLength(2);
expect((sources[0]!.filter as LogFilter).topic0).toMatchObject(
expect((sources[0]!.filter as LogFilter).topic0).toEqual(
toEventSelector(event1Overloaded),
);
expect((sources[0]!.filter as LogFilter).topic1).toMatchObject([
bytes1,
bytes2,
]);
expect((sources[1]!.filter as LogFilter).topic0).toMatchObject(
expect((sources[1]!.filter as LogFilter).topic0).toEqual(
toEventSelector(event0),
);
expect((sources[1]!.filter as LogFilter).topic1).toMatchObject(bytes1);
expect((sources[1]!.filter as LogFilter).topic1).toEqual(bytes1);
});

test("buildConfigAndIndexingFunctions() overrides default values with network-specific values", async () => {
Expand Down Expand Up @@ -590,7 +590,7 @@ test("buildConfigAndIndexingFunctions() includeCallTraces with factory", async (
expect((sources[0]!.filter as TraceFilter).fromAddress).toBeUndefined();
expect(
((sources[0]!.filter as TraceFilter).toAddress as LogFactory).address,
).toMatchObject(address2);
).toEqual(address2);
expect((sources[0]!.filter as TraceFilter).functionSelector).toMatchObject([
toFunctionSelector(func0),
]);
Expand Down
8 changes: 3 additions & 5 deletions packages/core/src/build/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,13 @@ test("buildScheama() error with $onUpdateFn sql", () => {

test("buildScheama() error with foreign key", () => {
// @ts-ignore
const ref = () => schema.account.address;
const schema = {
account: onchainTable("account", (p) => ({
address: p.integer().primaryKey(),
balance: p
.bigint()
.notNull()
.references(() => schema.account.address),
balance: p.bigint().notNull().references(ref),
})),
};
} as any;

expect(() => buildSchema({ schema })).toThrowError();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/internal/telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ test("telemetry calls fetch with event body", async (context) => {

expect(fetchSpy).toHaveBeenCalledTimes(1);

const fetchUrl = fetchSpy.mock.calls[0][0];
const fetchUrl = fetchSpy.mock.calls[0]![0];
expect(fetchUrl).toBe(context.common.options.telemetryUrl);

const fetchBody = JSON.parse(fetchSpy.mock.calls[0][1].body);
const fetchBody = JSON.parse(fetchSpy.mock.calls[0]![1].body);
expect(fetchBody).toMatchObject({
distinctId: expect.any(String),
event: "lifecycle:heartbeat_send",
Expand Down
12 changes: 12 additions & 0 deletions packages/core/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,17 @@ export default defineConfig({
},
sequence: { hooks: "stack" },
testTimeout: os.platform() === "win32" ? 30_000 : 10_000,
coverage: {
enabled: true,
provider: "v8",
reporter: ["text", "json", "html"],
reportsDirectory: "coverage",
thresholds: {
statements: 0,
branches: 0,
functions: 0,
lines: 0,
},
},
},
});
Loading
Loading