Initial import of zappier-customer-service from zapier monorepo
This commit is contained in:
commit
3914b8443a
5 changed files with 131 additions and 0 deletions
24
test/health.test.js
Normal file
24
test/health.test.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import path from 'node:path';
|
||||
|
||||
const root = path.dirname(fileURLToPath(new URL('.', import.meta.url)));
|
||||
|
||||
test('customer-service health', async () => {
|
||||
const port = 18011;
|
||||
const child = spawn(process.execPath, ['src/server.js'], {
|
||||
cwd: path.join(root),
|
||||
env: { ...process.env, PORT: String(port) },
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
await new Promise((r) => setTimeout(r, 400));
|
||||
try {
|
||||
const r = await fetch(`http://127.0.0.1:${port}/health`);
|
||||
const body = await r.json();
|
||||
assert.equal(body.role, 'zappier-customer-service');
|
||||
} finally {
|
||||
child.kill('SIGTERM');
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue