Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add e2e to pipeline #600

Draft
wants to merge 22 commits into
base: canary
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: improve e2e
  • Loading branch information
aralroca committed Nov 14, 2024
commit 73ddff05dd2d75db830a7eed650b8e83f8098acf
234 changes: 213 additions & 21 deletions e2e/examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,215 @@ const engine: Record<string, any> = {
};
const timeout = 30000;
const examples = [
{ id: 'with-api-routes' },
{ id: 'with-elysia' },
{ id: 'with-external-web-component' },
{ id: 'with-i18n' },
{ id: 'with-middleware' },
{ id: 'with-pandacss' },
{ id: 'with-sqlite-with-server-action' },
{ id: 'with-streaming-list' },
{ id: 'with-suspense' },
{ id: 'with-tailwindcss' },
{ id: 'with-view-transitions' },
{
id: 'with-api-routes',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-elysia',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-external-web-component',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-i18n',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-middleware',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-pandacss',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-sqlite-with-server-action',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-streaming-list',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-suspense',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-tailwindcss',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
{
id: 'with-view-transitions',
tests: [
{
title: 'should load home page with status 200 and HTML content',
test: async (page: Page, origin: string) => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
},
},
],
},
];

describe.each(examples)('e2e example', (example) => {
Expand Down Expand Up @@ -56,17 +254,11 @@ describe.each(examples)('e2e example', (example) => {
await page?.close?.();
});

it(`should load home page with status 200 and HTML content`, async () => {
const response = await page.goto(origin, {
waitUntil: 'load',
timeout,
for (const { title, test } of example.tests) {
it(title, async () => {
await test(page, origin);
});
expect(response).not.toBeNull();
expect(response!.status()).toBe(200);
expect(await response!.headerValue('content-type')).toContain(
'text/html',
);
});
}
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"release-adapter-vercel": "bun run --cwd packages/adapter-vercel build && npm publish --workspace=packages/adapter-vercel --access public",
"release-adapter-vercel:canary": "bun run --cwd packages/adapter-vercel build && npm publish --workspace=packages/adapter-vercel --tag next --access public",
"test": "bun test packages/*",
"test:e2e": "bun test --preload ./e2e/preload.ts ./e2e/examples.test.ts && bun run ./e2e/kill.ts",
"test:e2e": "bun test --preload ./e2e/preload.ts ./e2e/examples.test.ts; bun run ./e2e/kill.ts",
"test:node": "find packages -name '*.node-test.js' -exec node --test {} +",
"test:coverage": "bun run --cwd packages/brisa --coverage",
"tsc:check": "bun run --cwd packages/brisa tsc:check",
Expand Down