Skip to content

Commit

Permalink
test: separate servers tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianCataldo committed Aug 5, 2024
1 parent afa3588 commit 803a2c3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 23 deletions.
3 changes: 2 additions & 1 deletion integration/manual-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pnpm tsx --test src/assets.test.ts
pnpm tsx --test src/routes-torture.test.ts
pnpm tsx --test src/server-express/dev-all-around.test.ts
pnpm tsx --test src/server-express/01-build.test.ts
pnpm tsx --test src/server-express/02-runs-after-build.test.ts
pnpm tsx --test src/server-express/02-runs-after-build-express.test.ts
pnpm tsx --test src/server-express/03-runs-after-build-hono.test.ts
pnpm tsx --test src/custom-elements.test.ts
pnpm tsx --test src/build-mode/project-core.test.ts
pnpm tsx --test --test-concurrency=1 src/polyfills.test.ts # aa
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { type ChildProcessWithoutNullStreams, spawn } from 'node:child_process';
import { after, it } from 'node:test';

import { writeActual } from '../config.js';
import { common } from './_common.js';

// eslint-disable-next-line prefer-const
let gracileProcessExpress: ChildProcessWithoutNullStreams | null = null;
// eslint-disable-next-line prefer-const
let gracileProcessHono: ChildProcessWithoutNullStreams | null = null;

function launch(file: string) {
export function launch(file: string, callback: () => Promise<unknown>) {
let gracileProcess: ChildProcessWithoutNullStreams | null = null;
return new Promise<ChildProcessWithoutNullStreams | null>(
(resolve, reject) => {
Expand Down Expand Up @@ -40,7 +31,7 @@ function launch(file: string) {

bootStrapped = true;

common('prod', writeActual)
callback()
.then(() => {
resolve(gracileProcess);
})
Expand All @@ -65,14 +56,3 @@ function launch(file: string) {
},
);
}
await it('runs and execute test suites with EXPRESS', async () => {
gracileProcessExpress = await launch('express.js');
});
await it('runs and execute test suites with HONO', async () => {
gracileProcessHono = await launch('hono.js');
});

after(() => {
if (gracileProcessExpress) gracileProcessExpress.kill();
if (gracileProcessHono) gracileProcessHono.kill();
});
19 changes: 19 additions & 0 deletions integration/src/server-express/02-runs-after-build-express.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
import { after, it } from 'node:test';

import { launch } from '../__utils__/launch-server.js';
import { writeActual } from '../config.js';
import { common } from './_common.js';

let gracileProcess: ChildProcessWithoutNullStreams | null = null;

it('runs and execute test suites with EXPRESS', async () => {
gracileProcess = await launch('express.js', async () => {
await common('prod', writeActual);
});
});

after(() => {
if (gracileProcess) gracileProcess.kill();
});
19 changes: 19 additions & 0 deletions integration/src/server-express/03-runs-after-build-hono.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
import { after, it } from 'node:test';

import { launch } from '../__utils__/launch-server.js';
import { writeActual } from '../config.js';
import { common } from './_common.js';

let gracileProcess: ChildProcessWithoutNullStreams | null = null;

it('runs and execute test suites with EXPRESS', async () => {
gracileProcess = await launch('hono.js', async () => {
await common('prod', writeActual);
});
});

after(() => {
if (gracileProcess) gracileProcess.kill();
});

0 comments on commit 803a2c3

Please sign in to comment.