@aamini/config 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dist/internal-Dshd0hdM.mjs +22 -0
- package/dist/internal-Dshd0hdM.mjs.map +1 -0
- package/dist/test/browser.d.mts +3 -6
- package/dist/test/browser.mjs +14 -7
- package/dist/test/browser.mjs.map +1 -1
- package/dist/test/db.d.mts +3 -8
- package/dist/test/db.mjs +18 -9
- package/dist/test/db.mjs.map +1 -1
- package/dist/test/server.d.mts +3 -6
- package/dist/test/server.mjs +15 -7
- package/dist/test/server.mjs.map +1 -1
- package/dist/vite.shared.d.mts +369 -4
- package/dist/vite.shared.mjs +87 -17
- package/dist/vite.shared.mjs.map +1 -1
- package/package.json +6 -6
- package/test/browser.ts +19 -6
- package/test/db.ts +22 -16
- package/test/internal.ts +45 -0
- package/test/server.ts +21 -9
- package/vite.shared.ts +125 -12
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @aamini/config
|
|
2
|
+
|
|
3
|
+
Shared configuration and test fixtures for aamini apps.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **`createAppConfig(root)`** — full Vite+ app config with React, Tailwind,
|
|
8
|
+
SVGR, TanStack Start, Nitro
|
|
9
|
+
- **`baseConfigFor(import.meta.url)`** — one-liner for app `vite.config.ts`
|
|
10
|
+
- **Test fixtures** (`test/server`, `test/browser`, `test/db`) — Vitest fixtures
|
|
11
|
+
with auto-detected MSW handlers
|
|
12
|
+
- **`test/db`** — PostgreSQL testcontainer + drizzle + MSW integration fixture
|
|
13
|
+
- **Playwright config** — shared Playwright configuration
|
|
14
|
+
- **`msw.ts`** — re-exports to ensure singleton MSW instances
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// vite.config.ts
|
|
20
|
+
import { baseConfigFor } from '@aamini/config'
|
|
21
|
+
export default baseConfigFor(import.meta.url)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// app.test.ts
|
|
26
|
+
import { test } from '@aamini/config/test/server'
|
|
27
|
+
test('handles API', async ({ server }) => { ... })
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Handler files are auto-discovered from the consuming app's working directory:
|
|
31
|
+
`__mocks__/handlers.ts` → `__mocks__/handlers.js` → `src/mocks/handlers.ts` →
|
|
32
|
+
`src/mocks/handlers.js`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
//#region test/internal.ts
|
|
4
|
+
const HANDLER_LOCATIONS = [
|
|
5
|
+
"__mocks__/handlers.ts",
|
|
6
|
+
"__mocks__/handlers.js",
|
|
7
|
+
"src/mocks/handlers.ts",
|
|
8
|
+
"src/mocks/handlers.js"
|
|
9
|
+
];
|
|
10
|
+
function findHandlerPath() {
|
|
11
|
+
if (typeof process === "undefined") return "";
|
|
12
|
+
const cwd = process.cwd();
|
|
13
|
+
for (const location of HANDLER_LOCATIONS) {
|
|
14
|
+
const fullPath = resolve(cwd, location);
|
|
15
|
+
if (existsSync(fullPath)) return fullPath;
|
|
16
|
+
}
|
|
17
|
+
throw new Error(`No MSW handlers found. Expected one of:\n${HANDLER_LOCATIONS.map((l) => ` - ${resolve(cwd, l)}`).join("\n")}`);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { findHandlerPath as t };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=internal-Dshd0hdM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-Dshd0hdM.mjs","names":[],"sources":["../test/internal.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nexport const HANDLER_LOCATIONS = [\n\t'__mocks__/handlers.ts',\n\t'__mocks__/handlers.js',\n\t'src/mocks/handlers.ts',\n\t'src/mocks/handlers.js',\n]\n\nexport function findHandlerPath(): string {\n\tif (typeof process === 'undefined') {\n\t\treturn ''\n\t}\n\tconst cwd = process.cwd()\n\tfor (const location of HANDLER_LOCATIONS) {\n\t\tconst fullPath = resolve(cwd, location)\n\t\tif (existsSync(fullPath)) return fullPath\n\t}\n\tthrow new Error(\n\t\t`No MSW handlers found. Expected one of:\\n${HANDLER_LOCATIONS.map((l) => ` - ${resolve(cwd, l)}`).join('\\n')}`,\n\t)\n}\n\nexport function createProxy<T extends object>(getTarget: () => T): T {\n\tconst handlers: ProxyHandler<object> = {\n\t\tget(_, prop) {\n\t\t\treturn Reflect.get(getTarget(), prop, getTarget())\n\t\t},\n\t\tapply(target, thisArg, args) {\n\t\t\treturn Reflect.apply(getTarget() as any, thisArg, args)\n\t\t},\n\t\thas(_, prop) {\n\t\t\treturn prop in getTarget()\n\t\t},\n\t\townKeys() {\n\t\t\treturn Reflect.ownKeys(getTarget())\n\t\t},\n\t\tgetOwnPropertyDescriptor(_, prop) {\n\t\t\treturn Reflect.getOwnPropertyDescriptor(getTarget(), prop)\n\t\t},\n\t}\n\tconst proxyTarget = () => {}\n\treturn new Proxy(proxyTarget, handlers) as T\n}\n"],"mappings":";;;AAGA,MAAa,oBAAoB;CAChC;CACA;CACA;CACA;CACA;AAED,SAAgB,kBAA0B;CACzC,IAAI,OAAO,YAAY,aACtB,OAAO;CAER,MAAM,MAAM,QAAQ,KAAK;CACzB,KAAK,MAAM,YAAY,mBAAmB;EACzC,MAAM,WAAW,QAAQ,KAAK,SAAS;EACvC,IAAI,WAAW,SAAS,EAAE,OAAO;;CAElC,MAAM,IAAI,MACT,4CAA4C,kBAAkB,KAAK,MAAM,OAAO,QAAQ,KAAK,EAAE,GAAG,CAAC,KAAK,KAAK,GAC7G"}
|
package/dist/test/browser.d.mts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { SetupWorker } from "msw/browser";
|
|
2
|
-
import
|
|
2
|
+
import { TestAPI, afterEach, beforeEach, describe, expect, vi } from "vitest";
|
|
3
3
|
|
|
4
4
|
//#region test/browser.d.ts
|
|
5
5
|
interface MswBrowserFixture {
|
|
6
6
|
worker: SetupWorker;
|
|
7
7
|
_cleanup: void;
|
|
8
8
|
}
|
|
9
|
-
declare const test:
|
|
10
|
-
worker: SetupWorker;
|
|
11
|
-
_cleanup: void;
|
|
12
|
-
}>;
|
|
9
|
+
declare const test: TestAPI<MswBrowserFixture>;
|
|
13
10
|
//#endregion
|
|
14
|
-
export { MswBrowserFixture, test };
|
|
11
|
+
export { MswBrowserFixture, afterEach, beforeEach, describe, expect, test, vi };
|
|
15
12
|
//# sourceMappingURL=browser.d.mts.map
|
package/dist/test/browser.mjs
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { setupWorker } from "msw/browser";
|
|
2
|
-
import
|
|
3
|
-
import { test as test$1 } from "vitest";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, test as test$1, vi } from "vitest";
|
|
4
3
|
//#region test/browser.ts
|
|
5
|
-
|
|
4
|
+
let workerSingleton;
|
|
5
|
+
async function ensureWorker() {
|
|
6
|
+
if (!workerSingleton) {
|
|
7
|
+
const { default: handlers } = await import("@test/handlers");
|
|
8
|
+
workerSingleton = setupWorker(...handlers);
|
|
9
|
+
}
|
|
10
|
+
return workerSingleton;
|
|
11
|
+
}
|
|
6
12
|
const test = test$1.extend({
|
|
7
13
|
worker: [async ({}, use) => {
|
|
8
|
-
await
|
|
14
|
+
const worker = await ensureWorker();
|
|
15
|
+
await worker.start({
|
|
9
16
|
quiet: true,
|
|
10
17
|
onUnhandledRequest: "bypass"
|
|
11
18
|
});
|
|
12
|
-
await use(
|
|
13
|
-
|
|
19
|
+
await use(worker);
|
|
20
|
+
worker.stop();
|
|
14
21
|
}, {
|
|
15
22
|
auto: true,
|
|
16
23
|
scope: "worker"
|
|
@@ -21,6 +28,6 @@ const test = test$1.extend({
|
|
|
21
28
|
}, { auto: true }]
|
|
22
29
|
});
|
|
23
30
|
//#endregion
|
|
24
|
-
export { test };
|
|
31
|
+
export { afterEach, beforeEach, describe, expect, test, vi };
|
|
25
32
|
|
|
26
33
|
//# sourceMappingURL=browser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.mjs","names":["baseTest"],"sources":["../../test/browser.ts"],"sourcesContent":["// oxlint-disable typescript-eslint/triple-slash-reference\n/// <reference path=\"../virtual-modules.d.ts\" />\n// oxlint-disable no-empty-pattern\nimport
|
|
1
|
+
{"version":3,"file":"browser.mjs","names":["baseTest"],"sources":["../../test/browser.ts"],"sourcesContent":["// oxlint-disable typescript-eslint/triple-slash-reference\n/// <reference path=\"../virtual-modules.d.ts\" />\n// oxlint-disable no-empty-pattern\nimport { setupWorker, type SetupWorker } from 'msw/browser'\nimport { test as baseTest } from 'vitest'\nimport type { TestAPI } from 'vitest'\n\nexport interface MswBrowserFixture {\n\tworker: SetupWorker\n\t_cleanup: void\n}\n\nlet workerSingleton: SetupWorker | undefined\n\nasync function ensureWorker(): Promise<SetupWorker> {\n\tif (!workerSingleton) {\n\t\tconst { default: handlers } = await import('@test/handlers')\n\t\tworkerSingleton = setupWorker(...handlers)\n\t}\n\treturn workerSingleton\n}\n\nconst extended = baseTest.extend<MswBrowserFixture>({\n\tworker: [\n\t\tasync ({}, use) => {\n\t\t\tconst worker = await ensureWorker()\n\t\t\tawait worker.start({ quiet: true, onUnhandledRequest: 'bypass' })\n\t\t\tawait use(worker)\n\t\t\tworker.stop()\n\t\t},\n\t\t{ auto: true, scope: 'worker' },\n\t],\n\t_cleanup: [\n\t\tasync ({ worker }, use) => {\n\t\t\tawait use()\n\t\t\tworker.resetHandlers()\n\t\t},\n\t\t{ auto: true },\n\t],\n})\n\nexport { afterEach, beforeEach, describe, expect, vi } from 'vitest'\n\nexport const test = extended as TestAPI<MswBrowserFixture>\n"],"mappings":";;;AAYA,IAAI;AAEJ,eAAe,eAAqC;CACnD,IAAI,CAAC,iBAAiB;EACrB,MAAM,EAAE,SAAS,aAAa,MAAM,OAAO;EAC3C,kBAAkB,YAAY,GAAG,SAAS;;CAE3C,OAAO;;AAwBR,MAAa,OArBIA,OAAS,OAA0B;CACnD,QAAQ,CACP,OAAO,IAAI,QAAQ;EAClB,MAAM,SAAS,MAAM,cAAc;EACnC,MAAM,OAAO,MAAM;GAAE,OAAO;GAAM,oBAAoB;GAAU,CAAC;EACjE,MAAM,IAAI,OAAO;EACjB,OAAO,MAAM;IAEd;EAAE,MAAM;EAAM,OAAO;EAAU,CAC/B;CACD,UAAU,CACT,OAAO,EAAE,UAAU,QAAQ;EAC1B,MAAM,KAAK;EACX,OAAO,eAAe;IAEvB,EAAE,MAAM,MAAM,CACd;CACD,CAImB"}
|
package/dist/test/db.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Database } from "./database.mjs";
|
|
2
|
-
import
|
|
2
|
+
import { TestAPI, afterEach, beforeEach, describe, expect, vi } from "vitest";
|
|
3
3
|
import { SetupServer } from "msw/node";
|
|
4
4
|
|
|
5
5
|
//#region test/db.d.ts
|
|
@@ -9,13 +9,8 @@ interface DbFixture {
|
|
|
9
9
|
db: Database;
|
|
10
10
|
seedFunction: (db: Database) => Promise<void>;
|
|
11
11
|
}
|
|
12
|
-
declare const test:
|
|
13
|
-
server: SetupServer;
|
|
14
|
-
_cleanup: void;
|
|
15
|
-
db: Database;
|
|
16
|
-
seedFunction: (db: Database) => Promise<void>;
|
|
17
|
-
}>;
|
|
12
|
+
declare const test: TestAPI<DbFixture>;
|
|
18
13
|
declare function initDb(seedFunction: (db: Database) => Promise<void>): void;
|
|
19
14
|
//#endregion
|
|
20
|
-
export { DbFixture, initDb, test };
|
|
15
|
+
export { DbFixture, afterEach, beforeEach, describe, expect, initDb, test, vi };
|
|
21
16
|
//# sourceMappingURL=db.d.mts.map
|
package/dist/test/db.mjs
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { seedDatabase } from "./database.mjs";
|
|
2
|
+
import { t as findHandlerPath } from "../internal-Dshd0hdM.mjs";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
|
-
import
|
|
4
|
-
import { test as test$1 } from "vitest";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, test as test$1, vi } from "vitest";
|
|
5
5
|
import { setupServer } from "msw/node";
|
|
6
6
|
//#region test/db.ts
|
|
7
7
|
const DEFAULT_SCHEMA_PATH = "src/db/tables.ts";
|
|
8
8
|
const DEFAULT_MIGRATIONS_PATH = "src/db/migrations";
|
|
9
9
|
const DEFAULT_IMAGE = "postgres:17";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
let mswServer;
|
|
11
|
+
async function ensureMswServer() {
|
|
12
|
+
if (!mswServer) {
|
|
13
|
+
const { default: handlers } = await import(findHandlerPath());
|
|
14
|
+
mswServer = setupServer(...handlers);
|
|
15
|
+
}
|
|
16
|
+
return mswServer;
|
|
17
|
+
}
|
|
18
|
+
let extended = test$1.extend({
|
|
12
19
|
server: [async ({}, use) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
const server = await ensureMswServer();
|
|
21
|
+
server.listen({ onUnhandledRequest: "bypass" });
|
|
22
|
+
await use(server);
|
|
23
|
+
server.close();
|
|
16
24
|
}, {
|
|
17
25
|
auto: true,
|
|
18
26
|
scope: "worker"
|
|
@@ -44,10 +52,11 @@ const test = test$1.extend({
|
|
|
44
52
|
}
|
|
45
53
|
}, { scope: "file" }]
|
|
46
54
|
});
|
|
55
|
+
const test = extended;
|
|
47
56
|
function initDb(seedFunction) {
|
|
48
|
-
|
|
57
|
+
extended = extended.override({ seedFunction: [async ({}, use) => use(seedFunction), { scope: "file" }] });
|
|
49
58
|
}
|
|
50
59
|
//#endregion
|
|
51
|
-
export { initDb, test };
|
|
60
|
+
export { afterEach, beforeEach, describe, expect, initDb, test, vi };
|
|
52
61
|
|
|
53
62
|
//# sourceMappingURL=db.mjs.map
|
package/dist/test/db.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.mjs","names":["baseTest"],"sources":["../../test/db.ts"],"sourcesContent":["// oxlint-disable
|
|
1
|
+
{"version":3,"file":"db.mjs","names":["baseTest"],"sources":["../../test/db.ts"],"sourcesContent":["// oxlint-disable no-empty-pattern\nimport { setupServer, SetupServer } from 'msw/node'\nimport { resolve } from 'node:path'\nimport { test as baseTest } from 'vitest'\nimport type { TestAPI } from 'vitest'\nimport type { Database } from './database'\nimport { seedDatabase } from './database'\nimport { findHandlerPath } from './internal'\n\nconst DEFAULT_SCHEMA_PATH = 'src/db/tables.ts'\nconst DEFAULT_MIGRATIONS_PATH = 'src/db/migrations'\nconst DEFAULT_IMAGE = 'postgres:17'\n\nexport interface DbFixture {\n\tserver: SetupServer\n\t_cleanup: void\n\tdb: Database\n\tseedFunction: (db: Database) => Promise<void>\n}\n\nlet mswServer: SetupServer | undefined\n\nasync function ensureMswServer(): Promise<SetupServer> {\n\tif (!mswServer) {\n\t\tconst { default: handlers } = await import(findHandlerPath())\n\t\tmswServer = setupServer(...handlers)\n\t}\n\treturn mswServer\n}\n\nlet extended = baseTest.extend<DbFixture>({\n\tserver: [\n\t\tasync ({}, use) => {\n\t\t\tconst server = await ensureMswServer()\n\t\t\tserver.listen({ onUnhandledRequest: 'bypass' })\n\t\t\tawait use(server)\n\t\t\tserver.close()\n\t\t},\n\t\t{ auto: true, scope: 'worker' },\n\t],\n\t_cleanup: [\n\t\tasync ({ server }, use) => {\n\t\t\tawait use()\n\t\t\tserver.resetHandlers()\n\t\t},\n\t\t{ auto: true },\n\t],\n\tseedFunction: [async ({}, use) => use(async () => {}), { scope: 'file' }],\n\tdb: [\n\t\tasync ({ seedFunction }: Pick<DbFixture, 'seedFunction'>, use) => {\n\t\t\tconst { PostgreSqlContainer } = await import('@testcontainers/postgresql')\n\t\t\tconst { drizzle } = await import('drizzle-orm/node-postgres')\n\t\t\tconst { Wait } = await import('testcontainers')\n\t\t\tconst { Pool } = await import('pg')\n\n\t\t\tconst schemaPath = resolve(process.cwd(), DEFAULT_SCHEMA_PATH)\n\t\t\tconst migrationsFolder = resolve(process.cwd(), DEFAULT_MIGRATIONS_PATH)\n\n\t\t\tconst container = await new PostgreSqlContainer(DEFAULT_IMAGE)\n\t\t\t\t.withWaitStrategy(Wait.forHealthCheck())\n\t\t\t\t.start()\n\t\t\tconst db = drizzle({\n\t\t\t\tclient: new Pool({ connectionString: container.getConnectionUri() }),\n\t\t\t}) as Database\n\n\t\t\ttry {\n\t\t\t\tawait seedDatabase(db, { schemaPath, migrationsFolder, seedFunction })\n\t\t\t\tawait use(db)\n\t\t\t} finally {\n\t\t\t\tawait db.$client.end()\n\t\t\t\tawait container.stop()\n\t\t\t}\n\t\t},\n\t\t{ scope: 'file' },\n\t],\n})\n\nexport { afterEach, beforeEach, describe, expect, vi } from 'vitest'\n\nexport const test = extended as TestAPI<DbFixture>\n\nexport function initDb(seedFunction: (db: Database) => Promise<void>) {\n\textended = extended.override({\n\t\tseedFunction: [async ({}, use) => use(seedFunction), { scope: 'file' }],\n\t}) as typeof extended\n}\n"],"mappings":";;;;;;AASA,MAAM,sBAAsB;AAC5B,MAAM,0BAA0B;AAChC,MAAM,gBAAgB;AAStB,IAAI;AAEJ,eAAe,kBAAwC;CACtD,IAAI,CAAC,WAAW;EACf,MAAM,EAAE,SAAS,aAAa,MAAM,OAAO,iBAAiB;EAC5D,YAAY,YAAY,GAAG,SAAS;;CAErC,OAAO;;AAGR,IAAI,WAAWA,OAAS,OAAkB;CACzC,QAAQ,CACP,OAAO,IAAI,QAAQ;EAClB,MAAM,SAAS,MAAM,iBAAiB;EACtC,OAAO,OAAO,EAAE,oBAAoB,UAAU,CAAC;EAC/C,MAAM,IAAI,OAAO;EACjB,OAAO,OAAO;IAEf;EAAE,MAAM;EAAM,OAAO;EAAU,CAC/B;CACD,UAAU,CACT,OAAO,EAAE,UAAU,QAAQ;EAC1B,MAAM,KAAK;EACX,OAAO,eAAe;IAEvB,EAAE,MAAM,MAAM,CACd;CACD,cAAc,CAAC,OAAO,IAAI,QAAQ,IAAI,YAAY,GAAG,EAAE,EAAE,OAAO,QAAQ,CAAC;CACzE,IAAI,CACH,OAAO,EAAE,gBAAiD,QAAQ;EACjE,MAAM,EAAE,wBAAwB,MAAM,OAAO;EAC7C,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,MAAM,EAAE,SAAS,MAAM,OAAO;EAC9B,MAAM,EAAE,SAAS,MAAM,OAAO;EAE9B,MAAM,aAAa,QAAQ,QAAQ,KAAK,EAAE,oBAAoB;EAC9D,MAAM,mBAAmB,QAAQ,QAAQ,KAAK,EAAE,wBAAwB;EAExE,MAAM,YAAY,MAAM,IAAI,oBAAoB,cAAc,CAC5D,iBAAiB,KAAK,gBAAgB,CAAC,CACvC,OAAO;EACT,MAAM,KAAK,QAAQ,EAClB,QAAQ,IAAI,KAAK,EAAE,kBAAkB,UAAU,kBAAkB,EAAE,CAAC,EACpE,CAAC;EAEF,IAAI;GACH,MAAM,aAAa,IAAI;IAAE;IAAY;IAAkB;IAAc,CAAC;GACtE,MAAM,IAAI,GAAG;YACJ;GACT,MAAM,GAAG,QAAQ,KAAK;GACtB,MAAM,UAAU,MAAM;;IAGxB,EAAE,OAAO,QAAQ,CACjB;CACD,CAAC;AAIF,MAAa,OAAO;AAEpB,SAAgB,OAAO,cAA+C;CACrE,WAAW,SAAS,SAAS,EAC5B,cAAc,CAAC,OAAO,IAAI,QAAQ,IAAI,aAAa,EAAE,EAAE,OAAO,QAAQ,CAAC,EACvE,CAAC"}
|
package/dist/test/server.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TestAPI, afterEach, beforeEach, describe, expect, vi } from "vitest";
|
|
2
2
|
import { SetupServer } from "msw/node";
|
|
3
3
|
|
|
4
4
|
//#region test/server.d.ts
|
|
@@ -6,10 +6,7 @@ interface MswServerFixture {
|
|
|
6
6
|
server: SetupServer;
|
|
7
7
|
_cleanup: void;
|
|
8
8
|
}
|
|
9
|
-
declare const test:
|
|
10
|
-
server: SetupServer;
|
|
11
|
-
_cleanup: void;
|
|
12
|
-
}>;
|
|
9
|
+
declare const test: TestAPI<MswServerFixture>;
|
|
13
10
|
//#endregion
|
|
14
|
-
export { MswServerFixture, test };
|
|
11
|
+
export { MswServerFixture, afterEach, beforeEach, describe, expect, test, vi };
|
|
15
12
|
//# sourceMappingURL=server.d.mts.map
|
package/dist/test/server.mjs
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { test as test$1 } from "vitest";
|
|
1
|
+
import { t as findHandlerPath } from "../internal-Dshd0hdM.mjs";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, test as test$1, vi } from "vitest";
|
|
3
3
|
import { setupServer } from "msw/node";
|
|
4
4
|
//#region test/server.ts
|
|
5
|
-
|
|
5
|
+
let mswServer;
|
|
6
|
+
async function ensureMswServer() {
|
|
7
|
+
if (!mswServer) {
|
|
8
|
+
const { default: handlers } = await import(findHandlerPath());
|
|
9
|
+
mswServer = setupServer(...handlers);
|
|
10
|
+
}
|
|
11
|
+
return mswServer;
|
|
12
|
+
}
|
|
6
13
|
const test = test$1.extend({
|
|
7
14
|
server: [async ({}, use) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
const server = await ensureMswServer();
|
|
16
|
+
server.listen({ onUnhandledRequest: "bypass" });
|
|
17
|
+
await use(server);
|
|
18
|
+
server.close();
|
|
11
19
|
}, {
|
|
12
20
|
auto: true,
|
|
13
21
|
scope: "worker"
|
|
@@ -18,6 +26,6 @@ const test = test$1.extend({
|
|
|
18
26
|
}, { auto: true }]
|
|
19
27
|
});
|
|
20
28
|
//#endregion
|
|
21
|
-
export { test };
|
|
29
|
+
export { afterEach, beforeEach, describe, expect, test, vi };
|
|
22
30
|
|
|
23
31
|
//# sourceMappingURL=server.mjs.map
|
package/dist/test/server.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":["baseTest"],"sources":["../../test/server.ts"],"sourcesContent":["// oxlint-disable
|
|
1
|
+
{"version":3,"file":"server.mjs","names":["baseTest"],"sources":["../../test/server.ts"],"sourcesContent":["// oxlint-disable no-empty-pattern\nimport { setupServer, type SetupServer } from 'msw/node'\nimport { test as baseTest } from 'vitest'\nimport type { TestAPI } from 'vitest'\nimport { findHandlerPath } from './internal'\n\nexport interface MswServerFixture {\n\tserver: SetupServer\n\t_cleanup: void\n}\n\nlet mswServer: SetupServer | undefined\n\nasync function ensureMswServer(): Promise<SetupServer> {\n\tif (!mswServer) {\n\t\tconst { default: handlers } = await import(findHandlerPath())\n\t\tmswServer = setupServer(...handlers)\n\t}\n\treturn mswServer\n}\n\nconst extended = baseTest.extend<MswServerFixture>({\n\tserver: [\n\t\tasync ({}, use) => {\n\t\t\tconst server = await ensureMswServer()\n\t\t\tserver.listen({ onUnhandledRequest: 'bypass' })\n\t\t\tawait use(server)\n\t\t\tserver.close()\n\t\t},\n\t\t{ auto: true, scope: 'worker' },\n\t],\n\t_cleanup: [\n\t\tasync ({ server }, use) => {\n\t\t\tawait use()\n\t\t\tserver.resetHandlers()\n\t\t},\n\t\t{ auto: true },\n\t],\n})\n\nexport { afterEach, beforeEach, describe, expect, vi } from 'vitest'\n\nexport const test = extended as TestAPI<MswServerFixture>\n"],"mappings":";;;;AAWA,IAAI;AAEJ,eAAe,kBAAwC;CACtD,IAAI,CAAC,WAAW;EACf,MAAM,EAAE,SAAS,aAAa,MAAM,OAAO,iBAAiB;EAC5D,YAAY,YAAY,GAAG,SAAS;;CAErC,OAAO;;AAwBR,MAAa,OArBIA,OAAS,OAAyB;CAClD,QAAQ,CACP,OAAO,IAAI,QAAQ;EAClB,MAAM,SAAS,MAAM,iBAAiB;EACtC,OAAO,OAAO,EAAE,oBAAoB,UAAU,CAAC;EAC/C,MAAM,IAAI,OAAO;EACjB,OAAO,OAAO;IAEf;EAAE,MAAM;EAAM,OAAO;EAAU,CAC/B;CACD,UAAU,CACT,OAAO,EAAE,UAAU,QAAQ;EAC1B,MAAM,KAAK;EACX,OAAO,eAAe;IAEvB,EAAE,MAAM,MAAM,CACd;CACD,CAImB"}
|
package/dist/vite.shared.d.mts
CHANGED
|
@@ -1,14 +1,379 @@
|
|
|
1
1
|
import { TestProjectConfiguration, TestProjectInlineConfiguration } from "vitest/config";
|
|
2
|
-
import * as _$_voidzero_dev_vite_plus_core0 from "@voidzero-dev/vite-plus-core";
|
|
3
2
|
|
|
4
3
|
//#region vite.shared.d.ts
|
|
5
4
|
interface ProjectOverrides {
|
|
6
5
|
server?: TestProjectConfiguration;
|
|
7
6
|
browser?: TestProjectConfiguration;
|
|
8
7
|
}
|
|
9
|
-
declare function createAppConfig(root: string, projectOverrides?: ProjectOverrides, overrides?: TestProjectInlineConfiguration):
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
declare function createAppConfig(root: string, projectOverrides?: ProjectOverrides, overrides?: TestProjectInlineConfiguration): {
|
|
9
|
+
fmt: {
|
|
10
|
+
singleQuote: boolean;
|
|
11
|
+
semi: boolean;
|
|
12
|
+
useTabs: boolean;
|
|
13
|
+
experimentalTailwindcss: {};
|
|
14
|
+
printWidth: number;
|
|
15
|
+
experimentalSortPackageJson: boolean;
|
|
16
|
+
proseWrap: string;
|
|
17
|
+
ignorePatterns: string[];
|
|
18
|
+
overrides: {
|
|
19
|
+
files: string[];
|
|
20
|
+
options: {
|
|
21
|
+
useTabs: boolean;
|
|
22
|
+
};
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
lint: {
|
|
26
|
+
plugins: string[];
|
|
27
|
+
categories: {};
|
|
28
|
+
options: {
|
|
29
|
+
typeAware: boolean;
|
|
30
|
+
typeCheck: boolean;
|
|
31
|
+
};
|
|
32
|
+
rules: {
|
|
33
|
+
'no-empty-pattern': string;
|
|
34
|
+
'no-console': (string | {
|
|
35
|
+
allow: string[];
|
|
36
|
+
})[];
|
|
37
|
+
};
|
|
38
|
+
settings: {
|
|
39
|
+
'jsx-a11y': {
|
|
40
|
+
components: {};
|
|
41
|
+
attributes: {};
|
|
42
|
+
};
|
|
43
|
+
react: {
|
|
44
|
+
formComponents: any[];
|
|
45
|
+
linkComponents: any[];
|
|
46
|
+
};
|
|
47
|
+
jsdoc: {
|
|
48
|
+
ignorePrivate: boolean;
|
|
49
|
+
ignoreInternal: boolean;
|
|
50
|
+
ignoreReplacesDocs: boolean;
|
|
51
|
+
overrideReplacesDocs: boolean;
|
|
52
|
+
augmentsExtendsReplacesDocs: boolean;
|
|
53
|
+
implementsReplacesDocs: boolean;
|
|
54
|
+
exemptDestructuredRootsFromChecks: boolean;
|
|
55
|
+
tagNamePreference: {};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
env: {
|
|
59
|
+
builtin: boolean;
|
|
60
|
+
};
|
|
61
|
+
globals: {};
|
|
62
|
+
ignorePatterns: string[];
|
|
63
|
+
overrides: ({
|
|
64
|
+
files: string[];
|
|
65
|
+
rules: {
|
|
66
|
+
'eslint/no-restricted-imports': (string | {
|
|
67
|
+
patterns: {
|
|
68
|
+
group: string[];
|
|
69
|
+
message: string;
|
|
70
|
+
}[];
|
|
71
|
+
})[];
|
|
72
|
+
'react/self-closing-comp'?: undefined;
|
|
73
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
74
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
75
|
+
'no-console'?: undefined;
|
|
76
|
+
};
|
|
77
|
+
plugins?: undefined;
|
|
78
|
+
} | {
|
|
79
|
+
files: string[];
|
|
80
|
+
rules: {
|
|
81
|
+
'eslint/no-restricted-imports': (string | {
|
|
82
|
+
paths: {
|
|
83
|
+
name: string;
|
|
84
|
+
message: string;
|
|
85
|
+
}[];
|
|
86
|
+
})[];
|
|
87
|
+
'react/self-closing-comp'?: undefined;
|
|
88
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
89
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
90
|
+
'no-console'?: undefined;
|
|
91
|
+
};
|
|
92
|
+
plugins?: undefined;
|
|
93
|
+
} | {
|
|
94
|
+
files: string[];
|
|
95
|
+
plugins: string[];
|
|
96
|
+
rules: {
|
|
97
|
+
'react/self-closing-comp': string;
|
|
98
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
99
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
100
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
101
|
+
'no-console'?: undefined;
|
|
102
|
+
};
|
|
103
|
+
} | {
|
|
104
|
+
files: string[];
|
|
105
|
+
plugins: string[];
|
|
106
|
+
rules: {
|
|
107
|
+
'@typescript-eslint/no-explicit-any': string;
|
|
108
|
+
'vitest/no-standalone-expect': (string | {
|
|
109
|
+
additionalTestBlockFunctions: string[];
|
|
110
|
+
})[];
|
|
111
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
112
|
+
'react/self-closing-comp'?: undefined;
|
|
113
|
+
'no-console'?: undefined;
|
|
114
|
+
};
|
|
115
|
+
} | {
|
|
116
|
+
files: string[];
|
|
117
|
+
rules: {
|
|
118
|
+
'no-console': string;
|
|
119
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
120
|
+
'react/self-closing-comp'?: undefined;
|
|
121
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
122
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
123
|
+
};
|
|
124
|
+
plugins?: undefined;
|
|
125
|
+
})[];
|
|
126
|
+
};
|
|
127
|
+
staged: {
|
|
128
|
+
'*.{js,ts,tsx}': string;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
declare function baseConfigFor(configUrl: string | URL): {
|
|
132
|
+
fmt: {
|
|
133
|
+
singleQuote: boolean;
|
|
134
|
+
semi: boolean;
|
|
135
|
+
useTabs: boolean;
|
|
136
|
+
experimentalTailwindcss: {};
|
|
137
|
+
printWidth: number;
|
|
138
|
+
experimentalSortPackageJson: boolean;
|
|
139
|
+
proseWrap: string;
|
|
140
|
+
ignorePatterns: string[];
|
|
141
|
+
overrides: {
|
|
142
|
+
files: string[];
|
|
143
|
+
options: {
|
|
144
|
+
useTabs: boolean;
|
|
145
|
+
};
|
|
146
|
+
}[];
|
|
147
|
+
};
|
|
148
|
+
lint: {
|
|
149
|
+
plugins: string[];
|
|
150
|
+
categories: {};
|
|
151
|
+
options: {
|
|
152
|
+
typeAware: boolean;
|
|
153
|
+
typeCheck: boolean;
|
|
154
|
+
};
|
|
155
|
+
rules: {
|
|
156
|
+
'no-empty-pattern': string;
|
|
157
|
+
'no-console': (string | {
|
|
158
|
+
allow: string[];
|
|
159
|
+
})[];
|
|
160
|
+
};
|
|
161
|
+
settings: {
|
|
162
|
+
'jsx-a11y': {
|
|
163
|
+
components: {};
|
|
164
|
+
attributes: {};
|
|
165
|
+
};
|
|
166
|
+
react: {
|
|
167
|
+
formComponents: any[];
|
|
168
|
+
linkComponents: any[];
|
|
169
|
+
};
|
|
170
|
+
jsdoc: {
|
|
171
|
+
ignorePrivate: boolean;
|
|
172
|
+
ignoreInternal: boolean;
|
|
173
|
+
ignoreReplacesDocs: boolean;
|
|
174
|
+
overrideReplacesDocs: boolean;
|
|
175
|
+
augmentsExtendsReplacesDocs: boolean;
|
|
176
|
+
implementsReplacesDocs: boolean;
|
|
177
|
+
exemptDestructuredRootsFromChecks: boolean;
|
|
178
|
+
tagNamePreference: {};
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
env: {
|
|
182
|
+
builtin: boolean;
|
|
183
|
+
};
|
|
184
|
+
globals: {};
|
|
185
|
+
ignorePatterns: string[];
|
|
186
|
+
overrides: ({
|
|
187
|
+
files: string[];
|
|
188
|
+
rules: {
|
|
189
|
+
'eslint/no-restricted-imports': (string | {
|
|
190
|
+
patterns: {
|
|
191
|
+
group: string[];
|
|
192
|
+
message: string;
|
|
193
|
+
}[];
|
|
194
|
+
})[];
|
|
195
|
+
'react/self-closing-comp'?: undefined;
|
|
196
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
197
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
198
|
+
'no-console'?: undefined;
|
|
199
|
+
};
|
|
200
|
+
plugins?: undefined;
|
|
201
|
+
} | {
|
|
202
|
+
files: string[];
|
|
203
|
+
rules: {
|
|
204
|
+
'eslint/no-restricted-imports': (string | {
|
|
205
|
+
paths: {
|
|
206
|
+
name: string;
|
|
207
|
+
message: string;
|
|
208
|
+
}[];
|
|
209
|
+
})[];
|
|
210
|
+
'react/self-closing-comp'?: undefined;
|
|
211
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
212
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
213
|
+
'no-console'?: undefined;
|
|
214
|
+
};
|
|
215
|
+
plugins?: undefined;
|
|
216
|
+
} | {
|
|
217
|
+
files: string[];
|
|
218
|
+
plugins: string[];
|
|
219
|
+
rules: {
|
|
220
|
+
'react/self-closing-comp': string;
|
|
221
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
222
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
223
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
224
|
+
'no-console'?: undefined;
|
|
225
|
+
};
|
|
226
|
+
} | {
|
|
227
|
+
files: string[];
|
|
228
|
+
plugins: string[];
|
|
229
|
+
rules: {
|
|
230
|
+
'@typescript-eslint/no-explicit-any': string;
|
|
231
|
+
'vitest/no-standalone-expect': (string | {
|
|
232
|
+
additionalTestBlockFunctions: string[];
|
|
233
|
+
})[];
|
|
234
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
235
|
+
'react/self-closing-comp'?: undefined;
|
|
236
|
+
'no-console'?: undefined;
|
|
237
|
+
};
|
|
238
|
+
} | {
|
|
239
|
+
files: string[];
|
|
240
|
+
rules: {
|
|
241
|
+
'no-console': string;
|
|
242
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
243
|
+
'react/self-closing-comp'?: undefined;
|
|
244
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
245
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
246
|
+
};
|
|
247
|
+
plugins?: undefined;
|
|
248
|
+
})[];
|
|
249
|
+
};
|
|
250
|
+
staged: {
|
|
251
|
+
'*.{js,ts,tsx}': string;
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
declare const workspaceConfig: {
|
|
255
|
+
fmt: {
|
|
256
|
+
singleQuote: boolean;
|
|
257
|
+
semi: boolean;
|
|
258
|
+
useTabs: boolean;
|
|
259
|
+
experimentalTailwindcss: {};
|
|
260
|
+
printWidth: number;
|
|
261
|
+
experimentalSortPackageJson: boolean;
|
|
262
|
+
proseWrap: string;
|
|
263
|
+
ignorePatterns: string[];
|
|
264
|
+
overrides: {
|
|
265
|
+
files: string[];
|
|
266
|
+
options: {
|
|
267
|
+
useTabs: boolean;
|
|
268
|
+
};
|
|
269
|
+
}[];
|
|
270
|
+
};
|
|
271
|
+
lint: {
|
|
272
|
+
plugins: string[];
|
|
273
|
+
categories: {};
|
|
274
|
+
options: {
|
|
275
|
+
typeAware: boolean;
|
|
276
|
+
typeCheck: boolean;
|
|
277
|
+
};
|
|
278
|
+
rules: {
|
|
279
|
+
'no-empty-pattern': string;
|
|
280
|
+
'no-console': (string | {
|
|
281
|
+
allow: string[];
|
|
282
|
+
})[];
|
|
283
|
+
};
|
|
284
|
+
settings: {
|
|
285
|
+
'jsx-a11y': {
|
|
286
|
+
components: {};
|
|
287
|
+
attributes: {};
|
|
288
|
+
};
|
|
289
|
+
react: {
|
|
290
|
+
formComponents: any[];
|
|
291
|
+
linkComponents: any[];
|
|
292
|
+
};
|
|
293
|
+
jsdoc: {
|
|
294
|
+
ignorePrivate: boolean;
|
|
295
|
+
ignoreInternal: boolean;
|
|
296
|
+
ignoreReplacesDocs: boolean;
|
|
297
|
+
overrideReplacesDocs: boolean;
|
|
298
|
+
augmentsExtendsReplacesDocs: boolean;
|
|
299
|
+
implementsReplacesDocs: boolean;
|
|
300
|
+
exemptDestructuredRootsFromChecks: boolean;
|
|
301
|
+
tagNamePreference: {};
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
env: {
|
|
305
|
+
builtin: boolean;
|
|
306
|
+
};
|
|
307
|
+
globals: {};
|
|
308
|
+
ignorePatterns: string[];
|
|
309
|
+
overrides: ({
|
|
310
|
+
files: string[];
|
|
311
|
+
rules: {
|
|
312
|
+
'eslint/no-restricted-imports': (string | {
|
|
313
|
+
patterns: {
|
|
314
|
+
group: string[];
|
|
315
|
+
message: string;
|
|
316
|
+
}[];
|
|
317
|
+
})[];
|
|
318
|
+
'react/self-closing-comp'?: undefined;
|
|
319
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
320
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
321
|
+
'no-console'?: undefined;
|
|
322
|
+
};
|
|
323
|
+
plugins?: undefined;
|
|
324
|
+
} | {
|
|
325
|
+
files: string[];
|
|
326
|
+
rules: {
|
|
327
|
+
'eslint/no-restricted-imports': (string | {
|
|
328
|
+
paths: {
|
|
329
|
+
name: string;
|
|
330
|
+
message: string;
|
|
331
|
+
}[];
|
|
332
|
+
})[];
|
|
333
|
+
'react/self-closing-comp'?: undefined;
|
|
334
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
335
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
336
|
+
'no-console'?: undefined;
|
|
337
|
+
};
|
|
338
|
+
plugins?: undefined;
|
|
339
|
+
} | {
|
|
340
|
+
files: string[];
|
|
341
|
+
plugins: string[];
|
|
342
|
+
rules: {
|
|
343
|
+
'react/self-closing-comp': string;
|
|
344
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
345
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
346
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
347
|
+
'no-console'?: undefined;
|
|
348
|
+
};
|
|
349
|
+
} | {
|
|
350
|
+
files: string[];
|
|
351
|
+
plugins: string[];
|
|
352
|
+
rules: {
|
|
353
|
+
'@typescript-eslint/no-explicit-any': string;
|
|
354
|
+
'vitest/no-standalone-expect': (string | {
|
|
355
|
+
additionalTestBlockFunctions: string[];
|
|
356
|
+
})[];
|
|
357
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
358
|
+
'react/self-closing-comp'?: undefined;
|
|
359
|
+
'no-console'?: undefined;
|
|
360
|
+
};
|
|
361
|
+
} | {
|
|
362
|
+
files: string[];
|
|
363
|
+
rules: {
|
|
364
|
+
'no-console': string;
|
|
365
|
+
'eslint/no-restricted-imports'?: undefined;
|
|
366
|
+
'react/self-closing-comp'?: undefined;
|
|
367
|
+
'@typescript-eslint/no-explicit-any'?: undefined;
|
|
368
|
+
'vitest/no-standalone-expect'?: undefined;
|
|
369
|
+
};
|
|
370
|
+
plugins?: undefined;
|
|
371
|
+
})[];
|
|
372
|
+
};
|
|
373
|
+
staged: {
|
|
374
|
+
'*.{js,ts,tsx}': string;
|
|
375
|
+
};
|
|
376
|
+
};
|
|
12
377
|
//#endregion
|
|
13
378
|
export { baseConfigFor, createAppConfig, workspaceConfig };
|
|
14
379
|
//# sourceMappingURL=vite.shared.d.mts.map
|