forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle-size-budget.test.ts
More file actions
38 lines (33 loc) · 1.07 KB
/
Copy pathbundle-size-budget.test.ts
File metadata and controls
38 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { describe, it, expect } from 'vitest';
import { existsSync, statSync } from 'node:fs';
import { resolve } from 'node:path';
/**
* Bounty #83 — $90
* "Add a bundle-size budget check to CI"
*
* Verifies that the built dist files stay under a size budget.
*/
const KB = 1024;
const BUDGET_KB = 100; // 100 KB max for the main bundle
describe('bundle-size budget', () => {
const distPath = resolve(process.cwd(), 'dist');
const mainPath = resolve(distPath, 'index.js');
it('dist directory exists after build', () => {
// In CI this runs after build; locally it may not exist yet
if (existsSync(distPath)) {
expect(existsSync(distPath)).toBe(true);
}
});
it('main bundle is under budget when dist exists', () => {
if (existsSync(mainPath)) {
const size = statSync(mainPath).size;
expect(size / KB).toBeLessThan(BUDGET_KB);
}
});
it('source files are not bundled into dist', () => {
if (existsSync(distPath)) {
const srcPath = resolve(distPath, 'src');
expect(existsSync(srcPath)).toBe(false);
}
});
});