Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/integrations/vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dev": "astro-scripts dev \"src/**/*.ts\"",
"build": "astro-scripts build \"src/**/*.ts\" && tsc -b",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"test": "astro-scripts test --timeout 60000 \"test/**/!(hosted).test.ts\"",
"test": "astro-scripts test --timeout 100000 \"test/**/!(hosted).test.ts\"",
"test:hosted": "astro-scripts test --timeout 30000 \"test/hosted/*.test.ts\""
},
"dependencies": {
Expand Down
16 changes: 10 additions & 6 deletions packages/integrations/vercel/test/edge-middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Vercel edge middleware', () => {
await build.build({});
});

it('an edge function is created', async () => {
it('an edge function is created', { timeout: 30000 }, async () => {
const contents = await build.readFile(
'../.vercel/output/functions/_middleware.func/.vc-config.json',
);
Expand All @@ -20,15 +20,15 @@ describe('Vercel edge middleware', () => {
assert.equal(contentsJSON.entrypoint, 'middleware.mjs');
});

it('deployment config points to the middleware edge function', async () => {
it('deployment config points to the middleware edge function', { timeout: 30000 }, async () => {
const { routes } = await getVercelConfig(build);
assert.equal(
routes.some((route) => route.dest === '_middleware'),
true,
);
});

it('edge sets Set-Cookie headers', async () => {
it('edge sets Set-Cookie headers', { timeout: 30000 }, async () => {
const entry = new URL(
'../.vercel/output/functions/_middleware.func/middleware.mjs',
build.config.outDir,
Expand All @@ -40,7 +40,7 @@ describe('Vercel edge middleware', () => {
assert.ok((await response.text()).length, 'Body is included');
});

it('edge middleware forwards HTTP method and body', async () => {
it('edge middleware forwards HTTP method and body', { timeout: 30000 }, async () => {
const entry = new URL(
'../.vercel/output/functions/_middleware.func/middleware.mjs',
build.config.outDir,
Expand Down Expand Up @@ -69,7 +69,9 @@ describe('Vercel edge middleware', () => {
});

// TODO: The path here seems to be inconsistent?
it.skip('with edge handle file, should successfully build the middleware', async () => {
it.skip('with edge handle file, should successfully build the middleware', {
timeout: 30000,
}, async () => {
const fixture = await loadFixture({
root: './fixtures/middleware-with-edge-file/',
});
Expand All @@ -84,7 +86,9 @@ describe('Vercel edge middleware', () => {
});

// TODO: The path here seems to be inconsistent?
it.skip('without edge handle file, should successfully build the middleware', async () => {
it.skip('without edge handle file, should successfully build the middleware', {
timeout: 30000,
}, async () => {
const fixture = await loadFixture({
root: './fixtures/middleware-without-edge-file/',
});
Expand Down
20 changes: 12 additions & 8 deletions packages/integrations/vercel/test/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ describe('Image', () => {
await fixture.build({});
});

it('build successful', async () => {
it('build successful', { timeout: 30000 }, async () => {
assert.ok(await fixture.readFile('../.vercel/output/static/index.html'));
});

it('has link to vercel in build with proper attributes', async () => {
it('has link to vercel in build with proper attributes', { timeout: 30000 }, async () => {
const html = await fixture.readFile('../.vercel/output/static/index.html');
const $ = cheerio.load(html);
const img = $('#basic-image img');
Expand All @@ -27,7 +27,9 @@ describe('Image', () => {
assert.equal(img.attr('width'), '225');
});

it('generates valid image sizes when requested width is larger than source image', async () => {
it('generates valid image sizes when requested width is larger than source image', {
timeout: 30000,
}, async () => {
const html = await fixture.readFile('../.vercel/output/static/index.html');
const $ = cheerio.load(html);
const img = $('#small-source img');
Expand All @@ -43,7 +45,9 @@ describe('Image', () => {
assert.equal(img.attr('width'), '225', 'uses requested width in img attribute');
});

it('generates valid densities-based srcset using only configured sizes', async () => {
it('generates valid densities-based srcset using only configured sizes', {
timeout: 30000,
}, async () => {
const html = await fixture.readFile('../.vercel/output/static/index.html');
const $ = cheerio.load(html);
const img = $('#densities-test img');
Expand Down Expand Up @@ -84,7 +88,7 @@ describe('Image', () => {
);
});

it('has proper vercel config', async () => {
it('has proper vercel config', { timeout: 30000 }, async () => {
const vercelConfig = JSON.parse(await fixture.readFile('../.vercel/output/config.json'));

assert.deepEqual(vercelConfig.images, {
Expand All @@ -110,7 +114,7 @@ describe('Image', () => {
await devServer.stop();
});

it('has link to local image in dev with proper attributes', async () => {
it('has link to local image in dev with proper attributes', { timeout: 30000 }, async () => {
const html = await fixture.fetch('/').then((res) => res.text());
const $ = cheerio.load(html);
const img = $('#basic-image img');
Expand All @@ -120,7 +124,7 @@ describe('Image', () => {
assert.equal(img.attr('width'), '225');
});

it('supports SVGs', async () => {
it('supports SVGs', { timeout: 30000 }, async () => {
const html = await fixture.fetch('/').then((res) => res.text());
const $ = cheerio.load(html);
const img = $('#svg img');
Expand All @@ -131,7 +135,7 @@ describe('Image', () => {
assert.equal(res.headers.get('content-type'), 'image/svg+xml');
});

it('generates valid srcset for responsive images', async () => {
it('generates valid srcset for responsive images', { timeout: 30000 }, async () => {
const html = await fixture.fetch('/').then((res) => res.text());
const $ = cheerio.load(html);
const img = $('#responsive img');
Expand Down
8 changes: 6 additions & 2 deletions packages/integrations/vercel/test/integration-assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { describe, it } from 'node:test';
import { loadFixture } from './test-utils.ts';

describe('Assets generated by integrations', () => {
it('moves static assets generated by integrations to the correct location: static output', async () => {
it('moves static assets generated by integrations to the correct location: static output', {
timeout: 30000,
}, async () => {
const fixture = await loadFixture({
root: './fixtures/integration-assets/',
});
Expand All @@ -12,7 +14,9 @@ describe('Assets generated by integrations', () => {
assert(sitemap.includes('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'));
});

it('moves static assets generated by integrations to the correct location: server output', async () => {
it('moves static assets generated by integrations to the correct location: server output', {
timeout: 30000,
}, async () => {
const fixture = await loadFixture({
root: './fixtures/integration-assets/',
output: 'server',
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/vercel/test/isr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('ISR', () => {
await fixture.build({});
});

it('generates expected prerender config', async () => {
it('generates expected prerender config', { timeout: 30000 }, async () => {
const vcConfig = JSON.parse(
await fixture.readFile('../.vercel/output/functions/_isr.prerender-config.json'),
);
Expand All @@ -24,7 +24,7 @@ describe('ISR', () => {
});
});

it('generates expected routes', async () => {
it('generates expected routes', { timeout: 30000 }, async () => {
const deploymentConfig = JSON.parse(await fixture.readFile('../.vercel/output/config.json'));
// the first two are /_astro/*, and filesystem routes
assert.deepEqual(deploymentConfig.routes.slice(2), [
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/vercel/test/max-duration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('maxDuration', () => {
await fixture.build({});
});

it('makes it to vercel function configuration', async () => {
it('makes it to vercel function configuration', { timeout: 30000 }, async () => {
const vcConfig = JSON.parse(
await fixture.readFile('../.vercel/output/functions/_render.func/.vc-config.json'),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Vercel serverless path override security', () => {
await fixture.build({});
});

it('ignores untrusted x_astro_path query param on _render', async () => {
it('ignores untrusted x_astro_path query param on _render', { timeout: 30000 }, async () => {
const renderFunction = await loadFunctionModule(fixture, '_render');
const response = await renderFunction.default.fetch(
new Request('https://example.com/api/public?x_astro_path=/api/private'),
Expand All @@ -35,7 +35,7 @@ describe('Vercel serverless path override security', () => {
assert.equal(body.id, 'public');
});

it('ignores untrusted x-astro-path header on _render', async () => {
it('ignores untrusted x-astro-path header on _render', { timeout: 30000 }, async () => {
const renderFunction = await loadFunctionModule(fixture, '_render');
const response = await renderFunction.default.fetch(
new Request('https://example.com/api/public', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('prerendered error pages routing', () => {
await fixture.build({});
});

it('falls back to 404.html', async () => {
it('falls back to 404.html', { timeout: 30000 }, async () => {
const deploymentConfig = await getVercelConfig(fixture);
assert.deepEqual(
deploymentConfig.routes.find((r) => r.status === 404),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Redirects Serverless', () => {
await fixture.build({});
});

it('does not create .html files', async () => {
it('does not create .html files', { timeout: 30000 }, async () => {
let hasErrored = false;
try {
await fixture.readFile('../.vercel/output/static/other/index.html');
Expand Down
8 changes: 4 additions & 4 deletions packages/integrations/vercel/test/redirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Redirects', () => {
await fixture.build({});
});

it('define static routes', async () => {
it('define static routes', { timeout: 30000 }, async () => {
const config = await getVercelConfig(fixture);
const oneRoute = config.routes.find((r) => r.src === '^/one$')!;
assert.equal(oneRoute.headers['Location'], '/');
Expand All @@ -46,7 +46,7 @@ describe('Redirects', () => {
assert.equal(fourRoute.status, 302);
});

it('define redirects for static files', async () => {
it('define redirects for static files', { timeout: 30000 }, async () => {
const config = await getVercelConfig(fixture);

const staticRoute = config.routes.find((r) => r.src === '^/Basic/http-2-0\\.html$')!;
Expand All @@ -55,7 +55,7 @@ describe('Redirects', () => {
assert.equal(staticRoute.status, 301);
});

it('defines dynamic routes', async () => {
it('defines dynamic routes', { timeout: 30000 }, async () => {
const config = await getVercelConfig(fixture);

const blogRoute = config.routes.find((r) => r.src.startsWith('^/blog'))!;
Expand All @@ -64,7 +64,7 @@ describe('Redirects', () => {
assert.equal(blogRoute.status, 301);
});

it('throws an error for invalid redirects', async () => {
it('throws an error for invalid redirects', { timeout: 30000 }, async () => {
const fails = await loadFixture({
root: './fixtures/redirects/',
redirects: {
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/vercel/test/server-islands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Server Islands', () => {
await fixture.build({});
});

it('server islands route is in the config', async () => {
it('server islands route is in the config', { timeout: 30000 }, async () => {
const config = await getVercelConfig(fixture);
let found = null;
for (const route of config.routes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ describe('Serverless prerender', () => {
await fixture.build({});
});

it('build successful', async () => {
it('build successful', { timeout: 30000 }, async () => {
assert.ok(await fixture.readFile('../.vercel/output/static/index.html'));
});

it('outDir is tree-shaken if not needed', async () => {
it('outDir is tree-shaken if not needed', { timeout: 30000 }, async () => {
const [file] = await fixture.glob(
'../.vercel/output/functions/_render.func/packages/vercel/test/fixtures/serverless-prerender/.vercel/output/_functions/pages/_image.astro.mjs',
);
Expand All @@ -29,7 +29,7 @@ describe('Serverless prerender', () => {
});

// TODO: The path here seems to be inconsistent?
it.skip('includeFiles work', async () => {
it.skip('includeFiles work', { timeout: 30000 }, async () => {
assert.ok(
await fixture.readFile(
'../.vercel/output/functions/render.func/packages/vercel/test/fixtures/serverless-prerender/dist/middleware.mjs',
Expand All @@ -49,7 +49,7 @@ describe('Serverless hybrid rendering', () => {
await fixture.build({});
});

it('build successful', async () => {
it('build successful', { timeout: 30000 }, async () => {
assert.ok(await fixture.readFile('../.vercel/output/static/index.html'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('Serverless with dynamic routes', () => {
await fixture.build({});
});

it('build successful', async () => {
it('build successful', { timeout: 30000 }, async () => {
assert.ok(await fixture.readFile('../.vercel/output/static/index.html'));
assert.ok(await fixture.readFile('../.vercel/output/functions/_render.func/.vc-config.json'));
});
Expand Down
8 changes: 4 additions & 4 deletions packages/integrations/vercel/test/static-assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ describe('Static Assets', () => {
}

describe('static adapter', () => {
it('has cache control', async () => {
it('has cache control', { timeout: 30000 }, async () => {
const { default: vercel } = await import('@astrojs/vercel');
await build({
adapter: vercel(),
});
await checkValidCacheControl();
});

it('has cache control other assets', async () => {
it('has cache control other assets', { timeout: 30000 }, async () => {
const { default: vercel } = await import('@astrojs/vercel');
const assets = '_foo';
await build({
Expand All @@ -66,7 +66,7 @@ describe('Static Assets', () => {
});

describe('serverless adapter', () => {
it('has cache control', async () => {
it('has cache control', { timeout: 30000 }, async () => {
const { default: vercel } = await import('@astrojs/vercel');
await build({
output: 'server',
Expand All @@ -75,7 +75,7 @@ describe('Static Assets', () => {
await checkValidCacheControl();
});

it('has cache control other assets', async () => {
it('has cache control other assets', { timeout: 30000 }, async () => {
const { default: vercel } = await import('@astrojs/vercel');
const assets = '_foo';
await build({
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/vercel/test/static-headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Static headers', () => {
await fixture.build({});
});

it('CSP headers are added when CSP is enabled', async () => {
it('CSP headers are added when CSP is enabled', { timeout: 30000 }, async () => {
const config = await getVercelConfig(fixture);
const routes = config.routes;

Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/vercel/test/static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('static routing', () => {
await fixture.build({});
});

it('falls back to 404.html', async () => {
it('falls back to 404.html', { timeout: 30000 }, async () => {
const deploymentConfig = JSON.parse(await fixture.readFile('../.vercel/output/config.json'));
// change the index if necessary
assert.deepEqual(deploymentConfig.routes[2], {
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/vercel/test/streaming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('streaming', () => {
await fixture.build({});
});

it('makes it to vercel function configuration', async () => {
it('makes it to vercel function configuration', { timeout: 30000 }, async () => {
const vcConfig = JSON.parse(
await fixture.readFile('../.vercel/output/functions/_render.func/.vc-config.json'),
);
Expand Down
4 changes: 3 additions & 1 deletion packages/integrations/vercel/test/web-analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ describe('Vercel Web Analytics', () => {
await fixture.build({});
});

it('ensures that Vercel Web Analytics is present in the header', async () => {
it('ensures that Vercel Web Analytics is present in the header', {
timeout: 30000,
}, async () => {
const pageOne = await fixture.readFile('../.vercel/output/static/one/index.html');
const pageTwo = await fixture.readFile('../.vercel/output/static/two/index.html');

Expand Down
Loading