summaryrefslogtreecommitdiff
path: root/packages/integrations/vercel/test/speed-insights.test.js
blob: 7cf2ae7781a5195862d87af4dc2b9e6cc8442b73 (plain) (blame)
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
43
44
45
46
import { loadFixture } from './test-utils.js';
import { expect } from 'chai';

describe('Vercel Speed Insights', () => {
	describe('output: server', () => {
		/** @type {import('./test-utils.js').Fixture} */
		let fixture;

		before(async () => {
			fixture = await loadFixture({
				root: './fixtures/with-speed-insights-enabled/output-as-server/',
				output: 'server',
			});
			await fixture.build();
		});

		it('ensures that Vercel Speed Insights is present in the bundle', async () => {
			const [page] = await fixture.readdir('../.vercel/output/static/_astro');

			const bundle = await fixture.readFile(`../.vercel/output/static/_astro/${page}`);

			expect(bundle).to.contain('https://vitals.vercel-analytics.com/v1/vitals');
		});
	});

	describe('output: static', () => {
		/** @type {import('./test-utils.js').Fixture} */
		let fixture;

		before(async () => {
			fixture = await loadFixture({
				root: './fixtures/with-speed-insights-enabled/output-as-static/',
				output: 'static',
			});
			await fixture.build();
		});

		it('ensures that Vercel Speed Insights is present in the bundle', async () => {
			const [page] = await fixture.readdir('../.vercel/output/static/_astro');

			const bundle = await fixture.readFile(`../.vercel/output/static/_astro/${page}`);

			expect(bundle).to.contain('https://vitals.vercel-analytics.com/v1/vitals');
		});
	});
});