MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / runBundleSmokeTest

Function runBundleSmokeTest

packages/vite/test/Vite.test.ts:8–83  ·  view source on GitHub ↗
(vite: ViteLike)

Source from the content-addressed store, hash-verified

6type ViteLike = typeof import('vite');
7
8async function runBundleSmokeTest(vite: ViteLike) {
9 const bundlerProject = './test-data/project';
10
11 const cwd = process.cwd();
12 process.chdir(bundlerProject);
13
14 try {
15 await fs.promises.rm(path.join(process.cwd(), 'dist'), { force: true, recursive: true });
16 await vite.build(
17 vite.defineConfig({
18 base: '/test-data/project/dist/',
19 plugins: [alphaTab()]
20 })
21 );
22 } catch (e) {
23 process.chdir(cwd);
24 throw e;
25 } finally {
26 process.chdir(cwd);
27 }
28
29 // ensure assets are copied
30 const files = [
31 path.join(bundlerProject, 'dist', 'font', 'Bravura.otf'),
32 path.join(bundlerProject, 'dist', 'font', 'Bravura.woff'),
33 path.join(bundlerProject, 'dist', 'font', 'Bravura.woff2'),
34 path.join(bundlerProject, 'dist', 'font', 'Bravura-OFL.txt'),
35
36 path.join(bundlerProject, 'dist', 'soundfont', 'LICENSE'),
37 path.join(bundlerProject, 'dist', 'soundfont', 'sonivox.sf2')
38 ];
39 for (const file of files) {
40 expect(fs.existsSync(file), `File '${file}' Missing`).toBe(true);
41 }
42
43 const dir = await fs.promises.readdir(path.join(bundlerProject, 'dist', 'assets'), { withFileTypes: true });
44
45 let appValidated = false;
46 let workletValidated = false;
47 let workerValidated = false;
48
49 for (const file of dir) {
50 if (file.isFile()) {
51 const text = await fs.promises.readFile(path.join(file.parentPath, file.name), 'utf8');
52
53 if (file.name.startsWith('index-')) {
54 // ensure new worker has worker import
55 expect(text.match(/new [^ ]+\.alphaTabWorker\(new [^ ]+\.alphaTabUrl/)).toBeTruthy();
56 // ensure worker bootstrapping script is references
57 expect(text).toContain('assets/alphaTab.worker-');
58 // ensure worklet bootstrapper script is references
59 expect(text).toContain('assets/alphaTab.worklet-');
60 // without custom chunking the app will bundle alphatab directly
61 expect(text).toContain('.at-surface');
62 // ensure __ALPHATAB_VITE__ got replaced
63 expect(text).not.toContain('__ALPHATAB_VITE__');
64 appValidated = true;
65 } else if (file.name.startsWith('alphaTab.worker-')) {

Callers 1

Vite.test.tsFile · 0.85

Calls 7

alphaTabFunction · 0.90
joinMethod · 0.45
buildMethod · 0.45
toBeMethod · 0.45
toBeTruthyMethod · 0.45
matchMethod · 0.45
toContainMethod · 0.45

Tested by

no test coverage detected