summaryrefslogtreecommitdiff
path: root/packages/astro/test/astro-component-bundling.test.js
blob: 619f0af045d1f252e59852c4b0f9621b46cb6ff6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { loadFixture } from './test-utils.js';

describe('Component bundling', () => {
	let fixture;

	before(async () => {
		fixture = await loadFixture({ root: './fixtures/astro-component-bundling/' });
		await fixture.build();
	});

	it('should treeshake FooComponent', async () => {
		const astroChunkDir = await fixture.readdir('/_astro');
		const manyComponentsChunkName = astroChunkDir.find((chunk) =>
			chunk.startsWith('ManyComponents')
		);
		const manyComponentsChunkContent = await fixture.readFile(`/_astro/${manyComponentsChunkName}`);
		assert.equal(manyComponentsChunkContent.includes('FooComponent'), false);
	});
});