1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2024-11-28 18:11:17 +02:00
pocketbase/tools/types/untitled.js.erb
2022-10-30 10:28:14 +02:00

28 lines
750 B
Plaintext

const { exec } = require('node:child_process');
// you can use any other library for copying directories recursively
const fse = require('fs-extra');
let controller; // this will be used to terminate the PocketBase process
const srcTestDirPath = "./test_pb_data";
const tempTestDirPath = "./temp_test_pb_data";
beforeEach(() => {
// copy test_pb_date to a temp location
fse.copySync(srcTestDirPath, tempTestDirPath);
controller = new AbortController();
// start PocketBase with the test_pb_data
exec('./pocketbase serve --dir=' + tempTestDirPath, { signal: controller.signal});
});
afterEach(() => {
// stop the PocketBase process
controller.abort();
// clean up the temp test directory
fse.removeSync(tempTestDirPath);
});