Files
website/tests/integration.test.js
antigravity f0b4f42cb1
Test and Deploy Website / test-and-deploy (push) Successful in 1m12s
Initial commit with tests and deployment pipeline
2026-06-15 14:00:40 +02:00

36 lines
1.1 KiB
JavaScript

const test = require('node:test');
const assert = require('node:assert');
const http = require('http');
const { spawn } = require('child_process');
test('Integration Tests: Local Static Server', async (t) => {
// Start server as a child process
const serverProcess = spawn('node', ['server.js']);
// Wait for server to start
await new Promise((resolve) => setTimeout(resolve, 1500));
await t.test('Server returns 200 OK for index.html', () => {
return new Promise((resolve, reject) => {
http.get('http://localhost:8080/', (res) => {
assert.strictEqual(res.statusCode, 200);
assert.match(res.headers['content-type'], /text\/html/);
resolve();
}).on('error', reject);
});
});
await t.test('Server returns 404 for non-existent routes', () => {
return new Promise((resolve, reject) => {
http.get('http://localhost:8080/non-existent-page.html', (res) => {
assert.strictEqual(res.statusCode, 404);
resolve();
}).on('error', reject);
});
});
// Stop server
serverProcess.kill();
await new Promise((resolve) => setTimeout(resolve, 500));
});