dynamische IP für die vorherige Tests
This commit is contained in:
@@ -1,8 +1,22 @@
|
||||
import axios from "axios";
|
||||
import os from "os";
|
||||
|
||||
// Basis-URL des Servers
|
||||
const BASE_URL = "http://10.10.0.70:3000/api/gisSystemStatic";
|
||||
// Dynamische IP-Adresse ermitteln
|
||||
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; // IPv4-Adresse zurückgeben
|
||||
}
|
||||
}
|
||||
}
|
||||
return "localhost"; // Fallback zu localhost
|
||||
}
|
||||
|
||||
// Dynamische Basis-URL
|
||||
const BASE_URL = `http://${getLocalIPAddress()}:3000/api/gisSystemStatic`;
|
||||
//http://localhost:3000/api/gisSystemStatic
|
||||
describe("Echte API-Integrationstests für gisSystemStatic", () => {
|
||||
// Test 1: Erfolgreiche Anfrage mit gültigen Parametern
|
||||
it("gibt JSON-Daten zurück, wenn gültige Parameter übergeben werden", async () => {
|
||||
@@ -14,8 +28,8 @@ describe("Echte API-Integrationstests für gisSystemStatic", () => {
|
||||
// Echte Anfrage an den Server senden
|
||||
const response = await axios.get(BASE_URL, { params });
|
||||
|
||||
// Debugging der Header
|
||||
console.log(response.headers);
|
||||
// Header sicher loggen
|
||||
console.log("Content-Type:", response.headers["content-type"]);
|
||||
|
||||
// Statuscode prüfen
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
Reference in New Issue
Block a user