dynamische IP für die vorherige Tests

This commit is contained in:
ISA
2025-01-04 12:36:52 +01:00
parent d7978790e1
commit 764f7afea2
5 changed files with 92 additions and 33 deletions

View File

@@ -1,7 +1,21 @@
import axios from "axios";
import os from "os"; // Modul zum Ermitteln der IP-Adresse
// Basis-URL des Servers
const BASE_URL = "http://10.10.0.70:3000/api/gisStationsMeasurements";
// Dynamische Ermittlung der IP-Adresse des Rechners
function getLocalIPAddress() {
const interfaces = os.networkInterfaces();
for (const name of Object.keys(interfaces)) {
for (const iface of interfaces[name]) {
if (iface.family === "IPv4" && !iface.internal) {
return iface.address; // Rückgabe der IPv4-Adresse
}
}
}
return "localhost"; // Fallback zu localhost
}
// Basis-URL dynamisch erstellen
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisStationsMeasurements`;
describe("Echte API-Integrationstests für gisStationsMeasurements", () => {
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern