mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
core: refactor test setup & use better-sqlite-multiple-cipher
This commit is contained in:
31
packages/core/__tests__/setup/global.setup.ts
Normal file
31
packages/core/__tests__/setup/global.setup.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { rmSync } from "fs";
|
||||
import path from "path";
|
||||
import { tmpdir } from "os";
|
||||
|
||||
export default async function () {
|
||||
return async () => {
|
||||
rmSync(path.join(tmpdir(), "notesnook-tests-tmp"), {
|
||||
force: true,
|
||||
recursive: true
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -22,7 +22,11 @@ import dotenv from "dotenv";
|
||||
import { DOMParser } from "linkedom";
|
||||
import WebSocket from "ws";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
globalThis.DOMParser = DOMParser;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
globalThis.WebSocket = WebSocket;
|
||||
require("abortcontroller-polyfill/dist/polyfill-patch-fetch");
|
||||
dotenv.config();
|
||||
10
packages/core/package-lock.json
generated
10
packages/core/package-lock.json
generated
@@ -44,7 +44,7 @@
|
||||
"@types/ws": "^8.5.5",
|
||||
"@vitest/coverage-v8": "^1.0.1",
|
||||
"abortcontroller-polyfill": "^1.7.3",
|
||||
"better-sqlite3": "^8.6.0",
|
||||
"better-sqlite3-multiple-ciphers": "^9.4.0",
|
||||
"bson-objectid": "^2.0.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"dotenv": "^16.0.1",
|
||||
@@ -2519,10 +2519,10 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/better-sqlite3": {
|
||||
"version": "8.7.0",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.7.0.tgz",
|
||||
"integrity": "sha512-99jZU4le+f3G6aIl6PmmV0cxUIWqKieHxsiF7G34CVFiE+/UabpYqkU0NJIkY/96mQKikHeBjtR27vFfs5JpEw==",
|
||||
"node_modules/better-sqlite3-multiple-ciphers": {
|
||||
"version": "9.4.0",
|
||||
"resolved": "https://registry.npmjs.org/better-sqlite3-multiple-ciphers/-/better-sqlite3-multiple-ciphers-9.4.0.tgz",
|
||||
"integrity": "sha512-uQoBdShnpCdAPUmCPuLSrHtfSHAxjIFQvLnMbXHsvbWkfBP3sPfnnIaUTz7KHYRqgWNLlcQfs+9F9uqvMqau6Q==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"@types/ws": "^8.5.5",
|
||||
"@vitest/coverage-v8": "^1.0.1",
|
||||
"abortcontroller-polyfill": "^1.7.3",
|
||||
"better-sqlite3": "^8.6.0",
|
||||
"better-sqlite3-multiple-ciphers": "^9.4.0",
|
||||
"bson-objectid": "^2.0.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"dotenv": "^16.0.1",
|
||||
|
||||
@@ -23,7 +23,8 @@ const IS_E2E = process.env.IS_E2E === "true";
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
setupFiles: ["./globals.setup.js"],
|
||||
globalSetup: ["./__tests__/setup/global.setup.ts"],
|
||||
setupFiles: ["./__tests__/setup/test.setup.ts"],
|
||||
coverage: {
|
||||
reporter: ["text", "html"],
|
||||
exclude: ["src/utils/templates/html/languages/*.js"],
|
||||
|
||||
Reference in New Issue
Block a user