Initial import of zappier-accounting-export from zapier monorepo
This commit is contained in:
commit
ec18b5fadf
7 changed files with 235 additions and 0 deletions
25
test/health.test.js
Normal file
25
test/health.test.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
test('accounting-export health', async () => {
|
||||
const port = 18013;
|
||||
const child = spawn(process.execPath, ['src/server.js'], {
|
||||
cwd: 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`);
|
||||
assert.equal((await r.json()).role, 'zappier-accounting-export');
|
||||
const home = await fetch(`http://127.0.0.1:${port}/`);
|
||||
assert.equal(home.status, 200);
|
||||
} finally {
|
||||
child.kill('SIGTERM');
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue