1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-06 19:02:33 +01:00
server/util/tests/setupJest.js

24 lines
530 B
JavaScript
Raw Normal View History

2021-08-26 02:07:16 +02:00
const { performance } = require("perf_hooks");
2021-08-29 00:03:58 +02:00
const fs = require("fs");
const path = require("path");
// fs.unlinkSync(path.join(__dirname, "..", "database.db"));
2021-08-26 02:07:16 +02:00
global.expect.extend({
toBeFasterThan: async (func, target) => {
const start = performance.now();
var 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}`,
};
},
});