small things
This commit is contained in:
@@ -69,6 +69,37 @@ function cleanupTestFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
// robot.json gehört zur Betriebskonfiguration und darf durch Tests NICHT dauerhaft
|
||||
// gelöscht werden. Wir sichern den Inhalt vor der Suite und stellen ihn danach exakt
|
||||
// wieder her — inklusive aller Snapshot-Dateien, die schon vorher da waren.
|
||||
let _savedRobotJson = null; // null = Datei existierte nicht
|
||||
let _savedSnapshotFiles = {}; // filename → content (nur Dateien, die VOR den Tests da waren)
|
||||
|
||||
beforeAll(() => {
|
||||
fs.mkdirSync(DATA_DIR, { recursive: true });
|
||||
// robot.json sichern
|
||||
try { _savedRobotJson = fs.readFileSync(ROBOT_JSON, 'utf8'); } catch { _savedRobotJson = null; }
|
||||
// Snapshot-Dateien sichern (robot_YYYYMMDD_HHmmss.json)
|
||||
for (const f of fs.readdirSync(DATA_DIR)) {
|
||||
if (/^robot_\d{8}_\d{6}\.json$/.test(f)) {
|
||||
_savedSnapshotFiles[f] = fs.readFileSync(path.join(DATA_DIR, f), 'utf8');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
// Testdateien bereinigen
|
||||
cleanupTestFiles();
|
||||
// robot.json wiederherstellen
|
||||
if (_savedRobotJson !== null) {
|
||||
fs.writeFileSync(ROBOT_JSON, _savedRobotJson, 'utf8');
|
||||
}
|
||||
// Vor-Test-Snapshots wiederherstellen
|
||||
for (const [f, content] of Object.entries(_savedSnapshotFiles)) {
|
||||
fs.writeFileSync(path.join(DATA_DIR, f), content, 'utf8');
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fs.mkdirSync(DATA_DIR, { recursive: true });
|
||||
cleanupTestFiles();
|
||||
|
||||
Reference in New Issue
Block a user