speed-insights.test.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { loadFixture } from './test-utils.js';
  2. import assert from 'node:assert/strict';
  3. import { before, describe, it } from 'node:test';
  4. describe('Vercel Speed Insights', () => {
  5. describe('output: server', () => {
  6. /** @type {import('./test-utils.js').Fixture} */
  7. let fixture;
  8. before(async () => {
  9. fixture = await loadFixture({
  10. root: './fixtures/with-speed-insights-enabled/output-as-server/',
  11. output: 'server',
  12. });
  13. await fixture.build();
  14. });
  15. it('ensures that Vercel Speed Insights is present in the bundle', async () => {
  16. const [page] = await fixture.readdir('../.vercel/output/static/_astro');
  17. const bundle = await fixture.readFile(`../.vercel/output/static/_astro/${page}`);
  18. assert.match(bundle, /https:\/\/vitals.vercel-analytics.com\/v1\/vitals/);
  19. });
  20. });
  21. describe('output: static', () => {
  22. /** @type {import('./test-utils.js').Fixture} */
  23. let fixture;
  24. before(async () => {
  25. fixture = await loadFixture({
  26. root: './fixtures/with-speed-insights-enabled/output-as-static/',
  27. output: 'static',
  28. });
  29. await fixture.build();
  30. });
  31. it('ensures that Vercel Speed Insights is present in the bundle', async () => {
  32. const [page] = await fixture.readdir('../.vercel/output/static/_astro');
  33. const bundle = await fixture.readFile(`../.vercel/output/static/_astro/${page}`);
  34. assert.match(bundle, /https:\/\/vitals.vercel-analytics.com\/v1\/vitals/);
  35. });
  36. });
  37. });