Files
actual/jest.setup.js
Jed Fox be1c119799 Upgrade to ESM, update to latest dependencies (#128)
* Port to ESM

* + @types packages

* s/rmdir/rm/

* bump uuid

* Fix reading in eslintrc

* Add /build to eslintignore

* Update linting/types packages

* Stronger error checking

* - DOM globals

* update better-sqlite3

* Create .node-version

* Revert "update better-sqlite3"

This reverts commit 6b8003804fc09ade6c81324f591e5ad853517dfa.
2023-02-09 13:57:39 -05:00

18 lines
671 B
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import getAccountDb from './src/account-db.js';
import config from './src/load-config.js';
// Delete previous test database (force creation of a new one)
const dbPath = path.join(config.serverFiles, 'account.sqlite');
if (fs.existsSync(dbPath)) fs.unlinkSync(dbPath);
// Create path for test user files and delete previous files there
if (fs.existsSync(config.userFiles))
fs.rmSync(config.userFiles, { recursive: true });
fs.mkdirSync(config.userFiles);
// Insert a fake "valid-token" fixture that can be reused
const db = getAccountDb();
db.mutate('INSERT INTO sessions (token) VALUES (?)', ['valid-token']);