Initial commit with tests and deployment pipeline
Test and Deploy Website / test-and-deploy (push) Successful in 1m12s
Test and Deploy Website / test-and-deploy (push) Successful in 1m12s
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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));
|
||||
});
|
||||
Reference in New Issue
Block a user