blob: 378d72d5132065297fe555fe645e1ae3b2dbd1e1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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}`,
};
},
});
|