/
node-helper.js
38 lines (30 loc) · 966 Bytes
/
node-helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
import Vips from '../../lib/node-es6/vips.mjs';
import { tmpdir } from 'os';
import { expect } from 'chai';
globalThis.expect = expect;
export async function mochaGlobalSetup () {
const options = {
// Uncomment to disable dynamic modules
// dynamicLibraries: [],
preRun: (module) => {
module.setAutoDeleteLater(true);
module.setDelayFunction(fn => {
globalThis.cleanup = fn;
});
// Handy for debugging
// module.ENV.VIPS_INFO = '1';
// module.ENV.VIPS_LEAK = '1';
// Hide warning messages
module.ENV.VIPS_WARNING = '0';
// libvips stores temporary files by default in `/tmp`;
// set the TMPDIR env variable to override this directory
module.ENV.TMPDIR = tmpdir();
}
};
globalThis.vips = await Vips(options);
}
export function mochaGlobalTeardown () {
// We are done, shutdown libvips and the runtime of Emscripten
globalThis.vips.shutdown();
}