mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +00:00
chore: polyfill localStorage for node tests
This commit is contained in:
1 parent
dff1a3595d
commit
c4c0ec37a7
3 files changed
+11
-1
No files matched your search
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "bitvid",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build:css": "npx tailwindcss -c tailwind.config.cjs -i css/tailwind.source.css -o css/tailwind.generated.css --minify",
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
const rootDir = path.dirname(fileURLToPath(new URL("../package.json", import.meta.url)));
|
||||
const testsDir = path.join(rootDir, "tests");
|
||||
const testFiles = [];
|
||||
const setupImport = new URL("../tests/test-helpers/setup-localstorage.mjs", import.meta.url);
|
||||
|
||||
async function collectTests(dir) {
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
@@ -49,7 +50,7 @@ for (const testFile of testFiles) {
|
||||
console.log(`\n→ Running ${relativePath}`);
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
const child = spawn(process.execPath, [testFile], {
|
||||
const child = spawn(process.execPath, ["--import", setupImport.href, testFile], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
if (typeof globalThis.window === "undefined") {
|
||||
globalThis.window = {};
|
||||
}
|
||||
|
||||
if (typeof globalThis.localStorage === "undefined") {
|
||||
const store = new Map();
|
||||
globalThis.localStorage = {
|
||||
@@ -15,3 +19,7 @@ if (typeof globalThis.localStorage === "undefined") {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof globalThis.window.localStorage === "undefined") {
|
||||
globalThis.window.localStorage = globalThis.localStorage;
|
||||
}
|
||||
Reference in new issue
Block a user