fix: add browser path loader for Node.js tests, update test:modal-utils script
This commit is contained in:
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "oikos",
|
||||
"version": "1.0.0",
|
||||
"version": "0.3.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "oikos",
|
||||
"version": "1.0.0",
|
||||
"version": "0.3.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bcrypt": "^5.1.1",
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
"test:calendar": "node --experimental-sqlite test-calendar.js",
|
||||
"test:ncb": "node --experimental-sqlite test-notes-contacts-budget.js",
|
||||
"test:ux-utils": "node test-ux-utils.js",
|
||||
"test:modal-utils": "node test-modal-utils.js",
|
||||
"test:modal-utils": "node --loader ./test-browser-loader.mjs test-modal-utils.js",
|
||||
"test": "node --experimental-sqlite test-db.js && node --experimental-sqlite test-dashboard.js && node --experimental-sqlite test-tasks.js && node --experimental-sqlite test-shopping.js && node --experimental-sqlite test-meals.js && node --experimental-sqlite test-calendar.js && node --experimental-sqlite test-notes-contacts-budget.js && npm run test:ux-utils && npm run test:modal-utils"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* test-browser-loader.mjs — Node.js Custom Loader für Tests
|
||||
* Zweck: Browser-absolute Pfade (/foo.js) auf Stubs umleiten, damit
|
||||
* Frontend-Module im Node-Test-Kontext importierbar sind.
|
||||
* Verwendung: node --loader ./test-browser-loader.mjs test-xxx.js
|
||||
* Dependencies: none
|
||||
*/
|
||||
|
||||
const STUBS = {
|
||||
'/i18n.js': `
|
||||
export const t = (key) => key;
|
||||
export const initI18n = async () => {};
|
||||
export const setLocale = async () => {};
|
||||
export const getLocale = () => 'de';
|
||||
export const getSupportedLocales = () => ['de', 'en'];
|
||||
export const formatDate = (d) => String(d);
|
||||
export const formatTime = (d) => String(d);
|
||||
`,
|
||||
};
|
||||
|
||||
export async function resolve(specifier, context, nextResolve) {
|
||||
if (STUBS[specifier]) {
|
||||
return {
|
||||
shortCircuit: true,
|
||||
url: `data:text/javascript,${encodeURIComponent(STUBS[specifier])}`,
|
||||
};
|
||||
}
|
||||
return nextResolve(specifier, context);
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
// /i18n.js wird durch test-browser-loader.mjs gemockt (--loader Flag)
|
||||
const { wireBlurValidation, btnSuccess, btnError } = await import('./public/components/modal.js');
|
||||
|
||||
const _origSetTimeout = setTimeout;
|
||||
|
||||
Reference in New Issue
Block a user