mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-12 08:54:00 +02:00
36 lines
971 B
JavaScript
36 lines
971 B
JavaScript
/* eslint-disable jest/require-top-level-describe */
|
|
|
|
const { afterEachCleanUp, afterAllCleanUp } = require('@joplin/lib/testing/test-utils.js');
|
|
const { shimInit } = require('@joplin/lib/shim-init-node.js');
|
|
const { mkdir, rm } = require('fs-extra');
|
|
const path = require('path');
|
|
const { tmpdir } = require('os');
|
|
const uuid = require('@joplin/lib/uuid').default;
|
|
const sqlite3 = require('sqlite3');
|
|
|
|
shimInit({ nodeSqlite: sqlite3 });
|
|
|
|
|
|
// react-native-fs's CachesDirectoryPath export doesn't work in a testing environment.
|
|
// Use a temporary folder instead.
|
|
const tempDirectoryPath = path.join(tmpdir(), `appmobile-test-${uuid.createNano()}`);
|
|
|
|
jest.doMock('react-native-fs', () => {
|
|
return {
|
|
CachesDirectoryPath: tempDirectoryPath,
|
|
};
|
|
});
|
|
|
|
beforeAll(async () => {
|
|
await mkdir(tempDirectoryPath);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await afterEachCleanUp();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await afterAllCleanUp();
|
|
await rm(tempDirectoryPath, { recursive: true });
|
|
});
|