summary refs log tree commit diff
path: root/tests/setupJest.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/setupJest.js')
-rw-r--r--tests/setupJest.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/setupJest.js b/tests/setupJest.js
new file mode 100644
index 00000000..378d72d5
--- /dev/null
+++ b/tests/setupJest.js
@@ -0,0 +1,23 @@
+const { performance } = require("perf_hooks");
+const fs = require("fs");
+const path = require("path");
+
+// fs.unlinkSync(path.join(__dirname, "..", "database.db"));
+
+global.expect.extend({
+	toBeFasterThan: async (func, target) => {
+		const start = performance.now();
+		let error;
+		try {
+			await func();
+		} catch (e) {
+			error = e.toString();
+		}
+		const time = performance.now() - start;
+
+		return {
+			pass: time < target && !error,
+			message: () => error || `${func.name} took ${time}ms of maximum ${target}`,
+		};
+	},
+});