forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser-build.test.ts
More file actions
42 lines (36 loc) · 1.55 KB
/
Copy pathbrowser-build.test.ts
File metadata and controls
42 lines (36 loc) · 1.55 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
39
40
41
42
import { describe, it, expect } from 'vitest';
import { existsSync, statSync } from 'node:fs';
import { resolve } from 'node:path';
/**
* Issue #87: Browser-target build and browser export condition.
* Verifies that the browser build configuration exists in tsup.config.ts
* and that package.json has a browser export condition.
*/
describe('Browser-target build (issue #87)', () => {
const distBrowserDir = resolve(process.cwd(), 'dist/browser');
it('package.json has browser export condition', () => {
const pkg = require('../package.json');
expect(pkg.exports['.']).toBeDefined();
expect(pkg.exports['.']['browser']).toBeDefined();
expect(pkg.exports['.']['browser']).toBe('./dist/browser/index.js');
});
it('package.json has build:browser script', () => {
const pkg = require('../package.json');
expect(pkg.scripts['build:browser']).toBeDefined();
});
it('tsup.config.ts exports browserConfig', async () => {
// The browser config should be importable from tsup.config.ts
const config = await import('../tsup.config.ts');
expect(config.browserConfig).toBeDefined();
});
it('browser build output exists after build:browser', () => {
// Skip if not built yet
if (!existsSync(distBrowserDir)) return;
expect(existsSync(resolve(distBrowserDir, 'index.js'))).toBe(true);
});
it('browser build targets es2022', async () => {
const config = await import('../tsup.config.ts');
// browserConfig is a tsup config — check it has browser platform
expect(config.browserConfig).toBeDefined();
});
});