astro/packages/integrations/vercel/test/web-analtics.test.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

import { loadFixture } from './test-utils.js';
import { expect } from 'chai';
describe.only('Vercel Web Analytics', () => {
describe('output: server', () => {
/** @type {import('./test-utils.js').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
root: './fixtures/with-web-analytics-enabled/output-as-server/',
output: 'server',
});
await fixture.build();
});
it('ensures that Vercel Web Analytics 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('/_vercel/insights');
});
});
describe('output: static', () => {
/** @type {import('./test-utils.js').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
root: './fixtures/with-web-analytics-enabled/output-as-static/',
output: 'static',
});
await fixture.build();
});
it('ensures that Vercel Web Analytics 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('/_vercel/insights');
});
});
});