split.test.js 786 B

123456789101112131415161718192021222324252627
  1. import { loadFixture } from './test-utils.js';
  2. import assert from 'node:assert/strict';
  3. import { before, describe, it } from 'node:test';
  4. describe('build: split', () => {
  5. /** @type {import('./test-utils').Fixture} */
  6. let fixture;
  7. before(async () => {
  8. fixture = await loadFixture({
  9. root: './fixtures/functionPerRoute/',
  10. output: 'server',
  11. });
  12. await fixture.build();
  13. });
  14. it('creates separate functions for each page', async () => {
  15. const files = await fixture.readdir('../.vercel/output/functions/');
  16. assert.equal(files.length, 3);
  17. });
  18. it('creates the route definitions in the config.json', async () => {
  19. const json = await fixture.readFile('../.vercel/output/config.json');
  20. const config = JSON.parse(json);
  21. assert.equal(config.routes.length, 5);
  22. });
  23. });