@hublo/sentinel 1.3.0 → 1.4.0-alpha.1

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.
Files changed (33) hide show
  1. package/README.md +2 -0
  2. package/dist/bin/sentinel.d.ts +0 -1
  3. package/dist/bin/sentinel.js +22 -8
  4. package/dist/chunk-2XLX6PFR.js +132 -0
  5. package/dist/chunk-3TDUIKVQ.js +178 -0
  6. package/dist/{chunk-676GBPMS.js → chunk-O3XCQGTJ.js} +2856 -550
  7. package/dist/chunk-PWV3BMDA.js +15 -0
  8. package/dist/chunk-WLFE5RUU.js +264 -0
  9. package/dist/index.js +2 -1
  10. package/dist/roles/build/nest/toolchain.d.ts +4 -36
  11. package/dist/roles/build/nest/toolchain.js +10 -178
  12. package/dist/roles/build/nest/toolchain.js.map +1 -0
  13. package/dist/roles/build/toolchain.js.map +1 -0
  14. package/dist/roles/test/nest/toolchain.d.ts +29 -0
  15. package/dist/roles/test/nest/toolchain.js +224 -0
  16. package/dist/roles/test/nest/toolchain.js.map +1 -0
  17. package/dist/roles/test/react/toolchain.d.ts +62 -0
  18. package/dist/roles/test/react/toolchain.js +22 -0
  19. package/dist/roles/test/react/toolchain.js.map +1 -0
  20. package/dist/roles/test/setup/mock-extended.d.ts +46 -0
  21. package/dist/roles/test/setup/mock-extended.js +65 -0
  22. package/dist/roles/test/setup/mock-extended.js.map +1 -0
  23. package/dist/roles/test/setup/msw-lifecycle.d.ts +16 -0
  24. package/dist/roles/test/setup/msw-lifecycle.js +12 -0
  25. package/dist/roles/test/setup/msw-lifecycle.js.map +1 -0
  26. package/dist/roles/test/setup/msw-server.d.ts +3 -0
  27. package/dist/roles/test/setup/msw-server.js +10 -0
  28. package/dist/roles/test/setup/msw-server.js.map +1 -0
  29. package/dist/roles/test/setup/nest.d.ts +2 -0
  30. package/dist/roles/test/setup/nest.js +211 -0
  31. package/dist/roles/test/setup/nest.js.map +1 -0
  32. package/dist/tsconfig-aliases-Ce6axdJ4.d.ts +36 -0
  33. package/package.json +24 -3
@@ -0,0 +1,211 @@
1
+ import {
2
+ clearDeepMocks,
3
+ resetDeepMocks
4
+ } from "../../../chunk-2XLX6PFR.js";
5
+ import {
6
+ findWorkspaceRoot
7
+ } from "../../../chunk-WLFE5RUU.js";
8
+
9
+ // src/roles/test/setup/nest.ts
10
+ import { expect, vi } from "vitest";
11
+
12
+ // src/roles/test/setup/constructor-semantics.ts
13
+ function constructable(value) {
14
+ return typeof value === "function" && Object.getOwnPropertyDescriptor(value, "prototype") !== void 0;
15
+ }
16
+ function asConstructable(implementation) {
17
+ if (constructable(implementation)) return implementation;
18
+ return function forwarded(...args) {
19
+ return implementation.apply(this, args);
20
+ };
21
+ }
22
+ function installJestConstructorSemantics(vi2) {
23
+ const patch = (mock) => {
24
+ const { mockImplementation, mockImplementationOnce } = mock;
25
+ mock.mockImplementation = function(implementation) {
26
+ return mockImplementation.call(this, asConstructable(implementation));
27
+ };
28
+ mock.mockImplementationOnce = function(implementation) {
29
+ return mockImplementationOnce.call(this, asConstructable(implementation));
30
+ };
31
+ return mock;
32
+ };
33
+ const { fn, spyOn } = vi2;
34
+ vi2.fn = function(implementation) {
35
+ return patch(fn.call(this, implementation && asConstructable(implementation)));
36
+ };
37
+ vi2.spyOn = function(target, key) {
38
+ return patch(spyOn.call(this, target, key));
39
+ };
40
+ }
41
+
42
+ // src/roles/test/setup/deep-mock-reset.ts
43
+ function installDeepMockReset(vi2) {
44
+ const { resetAllMocks, clearAllMocks } = vi2;
45
+ vi2.resetAllMocks = function extended() {
46
+ const answer = resetAllMocks.call(this);
47
+ resetDeepMocks();
48
+ return answer;
49
+ };
50
+ vi2.clearAllMocks = function extended() {
51
+ const answer = clearAllMocks.call(this);
52
+ clearDeepMocks();
53
+ return answer;
54
+ };
55
+ }
56
+
57
+ // src/roles/test/setup/error-equality.ts
58
+ function errorsCompareByMessage(left, right) {
59
+ if (left instanceof Error && right instanceof Error) return left.message === right.message;
60
+ return void 0;
61
+ }
62
+ function installJestErrorEquality(expect2) {
63
+ expect2.addEqualityTesters([errorsCompareByMessage]);
64
+ }
65
+
66
+ // src/roles/test/setup/fake-timers.ts
67
+ var FAKED_BY_DEFAULT = [
68
+ "setTimeout",
69
+ "clearTimeout",
70
+ "setInterval",
71
+ "clearInterval",
72
+ "setImmediate",
73
+ "clearImmediate",
74
+ "Date",
75
+ "performance",
76
+ "hrtime"
77
+ ];
78
+ function withoutJestOnlyOptions(options) {
79
+ const given = options;
80
+ if (given?.doNotFake === void 0) return options;
81
+ const { doNotFake, ...rest } = given;
82
+ const base = rest.toFake ?? [...FAKED_BY_DEFAULT];
83
+ return { ...rest, toFake: base.filter((timer) => !doNotFake.includes(timer)) };
84
+ }
85
+ function installJestFakeTimerOptions(vi2) {
86
+ const inherited = vi2.useFakeTimers.bind(vi2);
87
+ vi2.useFakeTimers = (options) => inherited(withoutJestOnlyOptions(options));
88
+ }
89
+
90
+ // src/roles/test/setup/jest-global.ts
91
+ function installJestGlobal(vi2) {
92
+ ;
93
+ globalThis.jest = vi2;
94
+ }
95
+
96
+ // src/roles/test/setup/mock-reset.ts
97
+ function isResettable(value) {
98
+ return typeof value === "function" && typeof value.mockReset === "function" && typeof value.mockImplementation === "function";
99
+ }
100
+ function resetLikeJest(mock) {
101
+ if (!isResettable(mock)) return mock;
102
+ const inherited = mock.mockReset.bind(mock);
103
+ mock.mockReset = () => {
104
+ inherited();
105
+ mock.mockImplementation(() => void 0);
106
+ return mock;
107
+ };
108
+ return mock;
109
+ }
110
+ function installJestMockReset(vi2) {
111
+ for (const name of ["fn", "spyOn"]) {
112
+ const factory = vi2[name].bind(vi2);
113
+ vi2[name] = ((...args) => resetLikeJest(factory(...args)));
114
+ }
115
+ }
116
+
117
+ // src/roles/test/setup/rejected-function.ts
118
+ import { chai } from "vitest";
119
+ function thrownByCalling(candidate) {
120
+ try {
121
+ candidate();
122
+ } catch (thrown) {
123
+ return thrown;
124
+ }
125
+ return candidate;
126
+ }
127
+ function installJestRejectedFunction() {
128
+ const { Assertion, util } = chai;
129
+ for (const name of ["toThrow", "toThrowError"]) {
130
+ const original = Assertion.prototype[name];
131
+ if (typeof original !== "function") continue;
132
+ Assertion.prototype[name] = function patched(...args) {
133
+ const reason = this._obj;
134
+ const rejected = util.flag(this, "promise") === "rejects";
135
+ if (rejected && typeof reason === "function" && !(reason instanceof Error)) {
136
+ this._obj = thrownByCalling(reason);
137
+ }
138
+ return original.apply(this, args);
139
+ };
140
+ }
141
+ }
142
+
143
+ // src/roles/test/setup/workspace.ts
144
+ import { createRequire } from "module";
145
+ import { join } from "path";
146
+ function isMissingModule(error) {
147
+ return error?.code === "ERR_MODULE_NOT_FOUND";
148
+ }
149
+ async function optional(specifier, use) {
150
+ try {
151
+ use(await import(
152
+ /* @vite-ignore */
153
+ specifier
154
+ ));
155
+ } catch (error) {
156
+ if (!isMissingModule(error)) throw error;
157
+ }
158
+ }
159
+ function fromModule(specifier) {
160
+ try {
161
+ const require2 = createRequire(join(process.cwd(), "noop.cjs"));
162
+ return require2(specifier);
163
+ } catch {
164
+ return void 0;
165
+ }
166
+ }
167
+ async function loadEnvironment() {
168
+ await optional("dotenv-flow", (module) => {
169
+ const flow = module;
170
+ const config = flow.config ?? flow.default?.config;
171
+ const workspaceRoot = findWorkspaceRoot(process.cwd());
172
+ config?.({
173
+ silent: true,
174
+ purge_dotenv: true,
175
+ ...workspaceRoot === void 0 ? {} : { path: workspaceRoot }
176
+ });
177
+ });
178
+ }
179
+ async function pinLuxonZone() {
180
+ let pinned = false;
181
+ await optional("luxon", (module) => {
182
+ const settings = module.Settings;
183
+ if (settings === void 0) return;
184
+ settings.defaultZone = "utc";
185
+ pinned = true;
186
+ });
187
+ if (pinned) return;
188
+ const own = fromModule("luxon");
189
+ if (own?.Settings !== void 0) {
190
+ own.Settings.defaultZone = "utc";
191
+ return;
192
+ }
193
+ process.stderr.write(
194
+ "sentinel (test): luxon was not found in this module, so the UTC default zone is NOT pinned. Dates will follow the machine zone, as they did not under jest.\n"
195
+ );
196
+ }
197
+ async function installWorkspaceSetup() {
198
+ await loadEnvironment();
199
+ await pinLuxonZone();
200
+ }
201
+
202
+ // src/roles/test/setup/nest.ts
203
+ installJestErrorEquality(expect);
204
+ installJestMockReset(vi);
205
+ installJestConstructorSemantics(vi);
206
+ installDeepMockReset(vi);
207
+ installJestFakeTimerOptions(vi);
208
+ installJestRejectedFunction();
209
+ installJestGlobal(vi);
210
+ await installWorkspaceSetup();
211
+ //# sourceMappingURL=nest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/roles/test/setup/nest.ts","../../../../src/roles/test/setup/constructor-semantics.ts","../../../../src/roles/test/setup/deep-mock-reset.ts","../../../../src/roles/test/setup/error-equality.ts","../../../../src/roles/test/setup/fake-timers.ts","../../../../src/roles/test/setup/jest-global.ts","../../../../src/roles/test/setup/mock-reset.ts","../../../../src/roles/test/setup/rejected-function.ts","../../../../src/roles/test/setup/workspace.ts"],"sourcesContent":["/**\n * The setup a migrated Nest suite runs before its tests, as ONE entry point.\n *\n * Referenced by name from a generated config (`setupFiles: ['@hublo/sentinel/test/setup/nest']`),\n * never by a relative path. Measured: Vitest resolves a bare package specifier there, so nothing\n * has to know where sentinel sits relative to the module.\n *\n * ## What it replaces, line for line\n *\n * The repo's root `jest.setup.after.env.js`, loaded by 99 of the 111 jest configs:\n *\n * require('dotenv-flow').config({ silent: true, purge_dotenv: true })\n * const { Settings } = require('luxon')\n * const { server } = require('./libs/nest/tests/src/msw/server')\n * jest.mock('dynamoose')\n * jest.mock('@opentelemetry/exporter-metrics-otlp-grpc')\n * beforeAll(() => server.listen({ onUnhandledRequest: 'error' }))\n * afterEach(() => { if (global.gc) global.gc() })\n * afterAll(() => server.close())\n * Settings.defaultZone = 'utc'\n *\n * Everything here is a transcription of that, not an improvement on it. Where the original made a\n * choice that looks questionable, the choice is carried across and reported, because a migration\n * that also changes behaviour cannot be verified against its own baseline.\n *\n * ONE line is not transcribed: `server.listen()` also runs when this file is evaluated, not only\n * inside `beforeAll`. The runners differ on when a module's exports can still be patched, so the\n * original placement silently disabled interception under Vitest and let tests reach the real\n * internet. `./msw.js` carries the measurement.\n *\n * ## Two halves, and why one of them is loaded defensively\n *\n * The msw lifecycle used to live here and now has its own file, `./msw-lifecycle.js`, added to a\n * module's `setupFiles` only when that module actually uses msw. Installing it everywhere patches\n * `http`/`https` and refuses unmatched requests for modules that never asked: measured on\n * `libs/nest/starter`, 11 of 11 became 10 of 11 with `TypeError: Invalid URL` in the interceptor,\n * on a test fetching the Fastify server the suite starts itself.\n *\n * `dotenv-flow` and luxon's zone react to the REPO, not to the runner: they would read the same\n * under jest, Vitest or `node:test`. So `./workspace.js` loads them only if they are installed and\n * skips them in silence otherwise. That defensiveness is not a precaution bolted on, it IS the\n * statement that these belong to whoever installed them. Elsewhere, sentinel installs and that half\n * does nothing.\n *\n * `dotenv-flow` cannot simply be dropped in favour of Vite's own `.env` handling, which was the\n * first thing checked. Measured on Vitest 4: it does read the cascade and sets `MODE=test`, but it\n * exposes only `VITE_`-prefixed values, and only on `import.meta.env`. `process.env` is left\n * untouched, and Nest code reads unprefixed `process.env`.\n *\n * ## What is NOT here\n *\n * The two `jest.mock` calls. A module mock is a per-suite decision that `vi.mock` must make in the\n * file that needs it; hoisting it into a shared setup is what makes a test pass for a reason nobody\n * can see. The migration reports them so the module relying on one declares it.\n *\n * And `Settings.defaultZone = 'utc'` is carried as luxon's own setting, never translated to\n * `process.env.TZ`. One configures luxon, the other the whole process, `Date` and `Intl` included.\n * Swapping them would change what the suite does while claiming to migrate it, and timezone is not\n * a detail: measured on `host-admin`, a machine's zone accounted for a large part of 345 local\n * failures that did not exist in CI.\n */\nimport { expect, vi } from 'vitest'\n\nimport { installJestConstructorSemantics } from './constructor-semantics.js'\nimport { installDeepMockReset } from './deep-mock-reset.js'\nimport { installJestErrorEquality } from './error-equality.js'\nimport { installJestFakeTimerOptions } from './fake-timers.js'\nimport { installJestGlobal } from './jest-global.js'\nimport { installJestMockReset } from './mock-reset.js'\nimport { installJestRejectedFunction } from './rejected-function.js'\nimport { installWorkspaceSetup } from './workspace.js'\n\ninstallJestErrorEquality(expect)\ninstallJestMockReset(vi)\ninstallJestConstructorSemantics(vi)\ninstallDeepMockReset(vi)\ninstallJestFakeTimerOptions(vi)\ninstallJestRejectedFunction()\ninstallJestGlobal(vi)\n\n/*\n * Awaited at the top level, so the environment is loaded before the first test file is imported.\n * Deferring it to a `beforeAll` would be too late: a module read at import time would already have\n * captured an unset variable.\n */\nawait installWorkspaceSetup()\n","/**\n * `new` on a mock, the way jest answered it.\n *\n * ## The divergence, measured on the same source under both runners\n *\n * jest vitest\n * mockImplementation(() => obj), then new the obj TypeError: not a constructor\n * mockImplementation(function(){}), new works works\n * mockReturnValue(obj), then new the obj TypeError, with an explanation\n *\n * jest calls the implementation as a PLAIN function when the mock is constructed and hands back\n * what it returned. Vitest applies real `new` semantics, and an arrow function has no [[Construct]]\n * slot, so it throws.\n *\n * The pattern this breaks is the ordinary way to stand in for a class: automock the module, then\n * say what `new` should give back.\n *\n * jest.mock('@hublo/cloud/event-scheduler-sdk')\n * ;(EventSchedulerSDK as jest.MockedClass<typeof EventSchedulerSDK>)\n * .mockImplementation(() => mockEventSchedulerSDK)\n *\n * Measured across the nest and cloud campaigns: 2 modules, 15 tests.\n * `apps/nest/microservices/client-management` (9, an SDK) and `apps/nest/microservices/hublo-pool`\n * (6, a mocked `Date`).\n *\n * ## Why this is safe to do for everybody, which is the part that matters\n *\n * It only changes a case that THROWS today. An implementation without a `prototype` cannot be\n * constructed at all under Vitest, so no suite anywhere can be relying on what it does: the only\n * behaviours available are \"throws\" and \"answers like jest\". Nothing that works today changes\n * shape, and a constructable implementation is passed through untouched.\n *\n * That bound is asserted by the tests, not just claimed here.\n *\n * ## What is NOT covered, and why it is left alone\n *\n * `mockReturnValue(obj)` followed by `new`. Vitest refuses it with a message naming the fix\n * (\"Cannot use `mockReturnValue` when called with `new`. Use `mockImplementation` instead\"). It is\n * loud, it is actionable, and answering it here would mean deciding that a return value and a\n * constructed instance are the same thing, which is a claim about the suite rather than about the\n * runner. No module in this repo hit it.\n */\n\n/** The mocking surface this touches. Vitest's own type is not needed to say it. */\ninterface MockLike {\n mockImplementation(implementation: (...args: unknown[]) => unknown): unknown\n mockImplementationOnce(implementation: (...args: unknown[]) => unknown): unknown\n}\n\ninterface ViLike {\n fn(implementation?: (...args: unknown[]) => unknown): MockLike\n spyOn(target: object, key: never): MockLike\n}\n\n/**\n * Can this function be used with `new`?\n *\n * Asked of the `prototype` property rather than of the source text: an arrow function, a shorthand\n * method and a bound function all lack it, and all three are exactly the cases that throw. A\n * class and a plain `function` have it.\n */\nfunction constructable(value: unknown): boolean {\n return (\n typeof value === 'function' && Object.getOwnPropertyDescriptor(value, 'prototype') !== undefined\n )\n}\n\n/**\n * The same implementation, reachable through `new`.\n *\n * A plain `function` that forwards the call and RETURNS the result. JavaScript's own `new` then\n * hands that object back, which is what jest did, so nothing here imitates jest by hand: it\n * restores the one property the arrow was missing and lets the language do the rest.\n */\nfunction asConstructable(\n implementation: (...args: unknown[]) => unknown,\n): (...args: unknown[]) => unknown {\n if (constructable(implementation)) return implementation\n\n return function forwarded(this: unknown, ...args: unknown[]): unknown {\n return implementation.apply(this, args)\n }\n}\n\n/**\n * Wrap `vi.fn` and `vi.spyOn` so every mock they produce accepts `new` the way jest's did.\n *\n * Wrapped at the factory, like `installJestMockReset`, because the behaviour belongs to every mock\n * a suite makes and a suite should not have to ask for it.\n */\nexport function installJestConstructorSemantics(vi: ViLike): void {\n const patch = (mock: MockLike): MockLike => {\n const { mockImplementation, mockImplementationOnce } = mock\n\n mock.mockImplementation = function (implementation) {\n return mockImplementation.call(this, asConstructable(implementation))\n }\n mock.mockImplementationOnce = function (implementation) {\n return mockImplementationOnce.call(this, asConstructable(implementation))\n }\n return mock\n }\n\n const { fn, spyOn } = vi\n\n vi.fn = function (implementation) {\n return patch(fn.call(this, implementation && asConstructable(implementation)))\n }\n vi.spyOn = function (target, key) {\n return patch(spyOn.call(this, target, key))\n }\n}\n","/**\n * `vi.resetAllMocks()` reaching the deep mocks, the way jest's registry did.\n *\n * ## The divergence, and why it is invisible\n *\n * jest built `jest-mock-extended`'s mocks with `jest.fn()`, so they sat in jest's own registry and\n * `jest.resetAllMocks()` cleared them with everything else. `vitest-mock-extended` builds them its\n * own way, so `vi.resetAllMocks()` walks past them and their call history survives into the next\n * test.\n *\n * Nothing announces it. The suite still runs, and an assertion fails several tests later with a\n * count that is off by exactly what its neighbour did.\n *\n * Measured on `apps/nest/microservices/activity`, whose suite does what jest expected:\n *\n * beforeEach(() => mocked.findEvents.mockResolvedValue([]))\n * afterEach(() => vi.resetAllMocks())\n *\n * Eleven tests asserting `toHaveBeenCalledTimes(0)` saw the call left by the one before them. Each\n * PASSES on its own and fails as soon as its neighbour runs first, which is the signature of\n * leakage rather than of a wrong assertion.\n *\n * ## What this installs, and what it leaves alone\n *\n * `resetAllMocks` and `clearAllMocks` do what they did, then extend to the deep mocks: `reset`\n * drops implementations as well as calls, `clear` drops only calls, which is the same distinction\n * the two names already carry.\n *\n * `restoreAllMocks` is NOT extended. It restores spies to their originals, and a deep mock has no\n * original to go back to: it was invented. Extending it would mean deciding what \"restore\" means\n * for something that never existed, which is a claim, not a translation.\n */\nimport { clearDeepMocks, resetDeepMocks } from './mock-extended.js'\n\n/** The part of `vi` this touches. Vitest's own type is not needed to say it. */\ninterface ViLike {\n resetAllMocks(): unknown\n clearAllMocks(): unknown\n}\n\nexport function installDeepMockReset(vi: ViLike): void {\n const { resetAllMocks, clearAllMocks } = vi\n\n vi.resetAllMocks = function extended(this: unknown): unknown {\n const answer = resetAllMocks.call(this)\n resetDeepMocks()\n return answer\n }\n\n vi.clearAllMocks = function extended(this: unknown): unknown {\n const answer = clearAllMocks.call(this)\n clearDeepMocks()\n return answer\n }\n}\n","/**\n * How two `Error` values compare, which the two runners disagree about.\n *\n * A suite that asserts on a thrown or captured error usually writes the error it expects by hand:\n *\n * expect(save).toHaveBeenCalledWith({ error: new AxiosError('Request failed with status code 500'), ... })\n *\n * Under jest that passes whatever else the real error carries. Under Vitest it fails, and the\n * report is 6600 lines of an axios error's `config`, `request` and `response`, which reads like a\n * broken test rather than a runner difference.\n *\n * ## What each runner actually does, measured on the same four cases\n *\n * | two errors | jest 29 | Vitest 4 |\n * | --------------------------------- | -------- | ----------- |\n * | same message, same type | equal | equal |\n * | same message, DIFFERENT types | equal | not equal |\n * | same message, extra properties | equal | not equal |\n * | different messages | not equal| not equal |\n *\n * jest compares errors by their MESSAGE and nothing else: a `TypeError` and a `RangeError` with the\n * same text are equal to it. Vitest compares the type and the own properties too.\n *\n * ## Why the looser rule is the one restored\n *\n * Because it is the one 3481 test files were written against. Tightening it here would turn green\n * tests red during a migration whose whole promise is that the suite means the same thing\n * afterwards, and a baseline gate cannot tell that kind of loss from a real one.\n *\n * The question is reported rather than settled: comparing the type as well would be a better rule,\n * and it may cost nothing on this corpus. That is a measurement to run and a change to make on its\n * own, once the suites no longer move. Measured need so far: `libs/cloud/shared`, whose last\n * missing test was exactly this.\n */\nimport type { expect as ExpectApi } from 'vitest'\n\n/**\n * Restore jest's rule: two errors are equal when their messages are.\n *\n * Returning `undefined` for anything else hands the pair back to the default comparison, which is\n * what an equality tester is expected to do for values it has no opinion about.\n */\nexport function errorsCompareByMessage(left: unknown, right: unknown): boolean | undefined {\n if (left instanceof Error && right instanceof Error) return left.message === right.message\n return undefined\n}\n\nexport function installJestErrorEquality(expect: typeof ExpectApi): void {\n expect.addEqualityTesters([errorsCompareByMessage])\n}\n","/**\n * `useFakeTimers({ doNotFake: [...] })`, which Vitest accepts and ignores.\n *\n * jest names what to LEAVE ALONE, Vitest names what to FAKE. The option Vitest does not know is\n * dropped in silence, so a suite that carefully kept `setTimeout` real gets it faked, and anything\n * awaiting a timer never resolves.\n *\n * Measured on both runners with the same source:\n *\n * useFakeTimers({ doNotFake: ['setTimeout'] }) jest: setTimeout real Vitest: setTimeout FAKED\n * useFakeTimers({ toFake: ['Date'] }) Vitest: setTimeout real\n *\n * Found on `libs/cloud/events-notifications`: 4 tests in one file died on `Test timed out in\n * 5000ms` with nothing else to show, because the code under test awaits a real timer. The repo has\n * 2 files using `doNotFake`, the other in `apps/nest/microservices/institution`.\n *\n * ## The translation, and what it inherits\n *\n * `doNotFake: [a, b]` becomes `toFake: <everything the runner fakes by default> minus [a, b]`. The\n * default set is Vitest's, measured rather than assumed, and NOT jest's, which is wider: jest also\n * fakes `nextTick`, `queueMicrotask` and the animation-frame pair. Subtracting from Vitest's own\n * default is what every other `useFakeTimers()` call in the corpus already gets, so this keeps one\n * behaviour for the whole migration instead of two.\n */\n\n/**\n * What `vi.useFakeTimers()` replaces when told nothing, measured on Vitest 4 by comparing each\n * global before and after the call.\n */\nconst FAKED_BY_DEFAULT = [\n 'setTimeout',\n 'clearTimeout',\n 'setInterval',\n 'clearInterval',\n 'setImmediate',\n 'clearImmediate',\n 'Date',\n 'performance',\n 'hrtime',\n] as const\n\n/** The options both runners take, plus the one only jest knows. */\ninterface TimerOptions {\n toFake?: string[]\n doNotFake?: string[]\n}\n\n/**\n * Turn \"leave these alone\" into \"fake those\", leaving anything else untouched.\n *\n * Exported for its own test: the translation is the whole rule, and asserting it directly says more\n * than asserting that a wrapper was installed.\n */\nexport function withoutJestOnlyOptions<T>(options: T): T {\n const given = options as TimerOptions | undefined\n if (given?.doNotFake === undefined) return options\n\n const { doNotFake, ...rest } = given\n const base = rest.toFake ?? [...FAKED_BY_DEFAULT]\n\n return { ...rest, toFake: base.filter((timer) => !doNotFake.includes(timer)) } as T\n}\n\n/**\n * The one function this touches, named by its shape rather than by Vitest's type.\n *\n * `Options` is the caller's own parameter type: the wrapper hands back exactly what it was given,\n * minus the option Vitest does not know, so it must not narrow what the runner accepts.\n */\ninterface FakeTimerApi<Options> {\n useFakeTimers: (options?: Options) => unknown\n}\n\n/** Wrap `vi.useFakeTimers` so a jest-shaped options object still means what it said. */\nexport function installJestFakeTimerOptions<Options>(vi: FakeTimerApi<Options>): void {\n const inherited = vi.useFakeTimers.bind(vi)\n vi.useFakeTimers = (options?: Options) => inherited(withoutJestOnlyOptions(options))\n}\n","/**\n * The `jest` global, kept alive for helpers that a migrating module is not allowed to edit.\n *\n * ## Why a module cannot solve this for itself\n *\n * The codemod rewrites a module's own test files. It does not rewrite files in OTHER projects, and\n * it must not: a shared helper is imported by modules still on jest, so migrating it would break\n * them, and leaving it breaks the migrated one. That is the constraint the whole per-module plan\n * rests on.\n *\n * But those helpers call the jest API at MODULE scope. `libs/front/tests/src/mocks/**` does\n * `jest.fn()` when it is imported, before any test runs, so a migrated module dies on\n * `ReferenceError: jest is not defined` the moment it imports one.\n *\n * Measured repo-wide, excluding documentation: **50 files use the jest API without being test\n * files**, in `jest.setup.js`, `*.mock.ts`, `*.test-helper.ts`, `*.test-wrapper.ts`. Three\n * independent hand migrations reached this same line without knowing about each other:\n * `libs/front/components` (8 shared helpers, 16 sites), `apps/nest/microservices/mission` and\n * `apps/nest/backends-for-frontends/admin`.\n *\n * ## It is `vi`, not a fake jest\n *\n * The global IS Vitest's `vi`, so anything Vitest does not have keeps failing loudly:\n * `jest.requireActual` and `jest.isolateModules` are still errors, and a module relying on them\n * still has to be migrated properly. Handing over a hand-written imitation would turn those into\n * silent wrong behaviour, which is the opposite of the point.\n *\n * ## ⚠️ What it does NOT cover, and this bound is measured\n *\n * `jest.mock()`. Vitest hoists mock registrations above the imports by scanning the source\n * STATICALLY, and that scan only recognises the receivers `vi` and `vitest` (`@vitest/mocker`,\n * `hoistMocksPlugin`). A `jest.mock()` left in place is therefore NOT hoisted: it runs after the\n * imports it was meant to intercept and does nothing at all, in silence. Measured on\n * `apps/front/front-legacy`, where 216 of 427 files call it.\n *\n * So this covers a helper that CALLS the jest API. It does not make an unmigrated test file work,\n * and the codemod's rename stays load-bearing rather than cosmetic.\n */\n\n/** The part of `vi` this installs. Vitest's own type is not needed to say it. */\ntype JestLike = object\n\n/**\n * Put `vi` on `globalThis` under the name `jest`.\n *\n * Assigned rather than defined with a getter: a helper may well write to it (`jest.fn = ...` in a\n * test double), and a getter-only property would throw where jest allowed it.\n */\nexport function installJestGlobal(vi: JestLike): void {\n ;(globalThis as Record<string, unknown>).jest = vi\n}\n","/**\n * What `mockReset()` leaves behind, which is where the two runners disagree most dangerously.\n *\n * jest REMOVES the implementation: a reset spy returns `undefined` and the real function is not\n * called. Vitest puts the ORIGINAL implementation back: a reset spy calls the real function again.\n *\n * Measured on both runners with the same source:\n *\n * after resetAllMocks() on a spy jest: undefined Vitest: the real function\n * after mockReset() on a spy jest: undefined Vitest: the real function\n * after mockReset() on fn(impl) jest: undefined Vitest: impl\n *\n * The shape this breaks is ordinary and common: a suite spies on a provider in `beforeAll` and\n * resets its mocks in `beforeEach`. Under jest the provider stayed neutralised for every test.\n * Under Vitest the first `beforeEach` hands the real provider back, and every test after it runs\n * the real code. Measured on `libs/cloud/events-notifications`, that meant real HTTP: 19 tests\n * failed on `captured a request without a matching request handler` for the hermes API and 23 more\n * timed out waiting on it. Nothing in any report named a reset.\n *\n * 240 files in this repo both spy and reset, in every family: 111 under `apps/nest`, 77 under\n * `libs/cloud`, 31 under `apps/front`.\n *\n * ## Why here and not in the 240 files\n *\n * Because a codemod would have to decide, per spy, whether the suite wanted the real function\n * back, and the answer is in the test's intent rather than in its text. The runner-level rule is\n * the one that was true for all 240 while they were written, so restoring it is the transcription\n * and rewriting them would be the guess.\n *\n * Vitest routes `vi.resetAllMocks()` through each mock's own `mockReset`, measured, so overriding\n * that method covers the bulk form as well as the direct one. `mockRestore` is untouched: it puts\n * the original back under both runners, which is what it is for.\n */\n\n/** The part of a mock this file touches. Vitest's own types are not needed to say it. */\ninterface ResettableMock {\n mockReset: () => unknown\n mockImplementation: (fn: (...args: unknown[]) => unknown) => unknown\n}\n\nfunction isResettable(value: unknown): value is ResettableMock {\n return (\n typeof value === 'function' &&\n typeof (value as Partial<ResettableMock>).mockReset === 'function' &&\n typeof (value as Partial<ResettableMock>).mockImplementation === 'function'\n )\n}\n\n/**\n * Make one mock forget its implementation on reset, as jest's did.\n *\n * The override is installed on the instance rather than on a prototype: mocks are functions with\n * their own properties, and there is no shared prototype to reach.\n */\nfunction resetLikeJest<T>(mock: T): T {\n if (!isResettable(mock)) return mock\n\n const inherited = mock.mockReset.bind(mock)\n mock.mockReset = () => {\n inherited()\n mock.mockImplementation(() => undefined)\n return mock\n }\n return mock\n}\n\n/** The two factories a suite gets its mocks from. */\ntype MockFactories = { fn: (...args: never[]) => unknown; spyOn: (...args: never[]) => unknown }\n\n/**\n * Wrap `vi.fn` and `vi.spyOn` so everything they hand out resets the way jest's did.\n *\n * Called with the `vi` a setup file imports, so nothing here reaches for a global.\n */\nexport function installJestMockReset(vi: MockFactories): void {\n for (const name of ['fn', 'spyOn'] as const) {\n const factory = vi[name].bind(vi) as (...args: never[]) => unknown\n vi[name] = ((...args: never[]) => resetLikeJest(factory(...args))) as MockFactories[typeof name]\n }\n}\n","/**\n * A rejected value that is a FUNCTION, which jest calls and Vitest does not.\n *\n * ## The divergence, measured rather than reasoned\n *\n * jest's `toThrow` decides what was thrown like this: under `.rejects` it uses the rejection\n * reason ONLY when that reason is an Error. Otherwise it falls through to the ordinary branch,\n * sees a function, and CALLS it, asserting on whatever that call throws.\n *\n * Probed on this repo under jest 29, with controls:\n *\n * reject(() => { throw new Error('some error') })\n * await expect(…).rejects.toThrow(new Error('some error')) -> passes\n * await expect(…).rejects.toThrow(new Error('other text')) -> fails\n * await expect(…).rejects.toThrow('other text') -> fails\n *\n * The two controls are what make the first line mean something: jest is not passing everything,\n * it really is comparing the message of the error the CALL produced.\n *\n * Vitest treats the rejection reason as the thrown value, so the assertion is made against a\n * function. A function has no `message`, and the failure reads\n * `Cannot read properties of undefined (reading 'indexOf')`, which names nothing near the cause.\n *\n * ## Where it shows, and what it is worth\n *\n * Measured across the nest campaign: 4 tests in 3 modules.\n * `apps/nest/microservices/worker` (1), `apps/nest/microservices/institution` (2) and\n * `apps/nest/microservices/mission` (1). All four write the same shape, a mock rejecting with a\n * thunk that throws, or a `throw <a function>`.\n *\n * ## What this changes, and what it cannot\n *\n * Only a case that CANNOT work today: under `.rejects`, a reason that is a function and not an\n * Error. Vitest has no useful behaviour there, so nothing that passes today changes shape. An\n * Error reason, a string, an object, a rejected value of any other kind, and every assertion\n * outside `.rejects` all reach Vitest's own matcher untouched.\n *\n * ⚠️ It is jest's behaviour, not a good one. A suite reaching it is asserting on a function it\n * never meant to hand over, and it passed by accident of the runner. Reproducing it is what keeps\n * the migration honest: the gate promises the suite means the same thing afterwards, and a test\n * that was green cannot be turned red by us and called a finding. The teams own the cleanup.\n */\nimport { chai } from 'vitest'\n\n/** The part of a chai assertion this touches. Chai's own types are not needed to say it. */\ninterface AssertionLike {\n _obj: unknown\n}\n\ntype Matcher = (this: AssertionLike, ...args: unknown[]) => unknown\n\n/**\n * What calling the function throws, or the function itself when it throws nothing.\n *\n * Returning it unchanged matters: a function that completes is not \"nothing was thrown\", and\n * handing Vitest the same value it had leaves the report exactly as it would have been.\n */\nfunction thrownByCalling(candidate: () => unknown): unknown {\n try {\n candidate()\n } catch (thrown) {\n return thrown\n }\n return candidate\n}\n\nexport function installJestRejectedFunction(): void {\n const { Assertion, util } = chai as unknown as {\n Assertion: { prototype: Record<string, unknown> }\n util: { flag(object: unknown, key: string): unknown }\n }\n\n for (const name of ['toThrow', 'toThrowError']) {\n const original = Assertion.prototype[name] as Matcher | undefined\n if (typeof original !== 'function') continue\n\n Assertion.prototype[name] = function patched(this: AssertionLike, ...args: unknown[]): unknown {\n const reason = this._obj\n const rejected = util.flag(this, 'promise') === 'rejects'\n\n if (rejected && typeof reason === 'function' && !(reason instanceof Error)) {\n this._obj = thrownByCalling(reason as () => unknown)\n }\n\n return original.apply(this, args)\n } as unknown as Matcher\n }\n}\n","/**\n * The rest of what a migrated suite needs before its tests, loaded DEFENSIVELY.\n *\n * ## Why this is in sentinel and not in the repo\n *\n * Because it is config, and an app must depend on its own config and nothing outside it. The first\n * version of the generated config referenced `'../../../../vitest.setup.mts'`, a relative path\n * climbing four levels to the workspace root — which is exactly the external link this whole\n * migration exists to remove. A module that reaches outside itself cannot move on its own.\n *\n * ## Why loading is conditional, and why that is the point rather than a precaution\n *\n * Unlike the msw lifecycle beside it, nothing here reacts to the RUNNER. `dotenv-flow` and luxon's\n * zone would behave identically under jest, Vitest or `node:test`; what they react to is the REPO,\n * which chose those two packages. So the conditional load is the statement of ownership: sentinel\n * offers the behaviour, and the repo that installed the package decides whether it happens.\n *\n * That is also what keeps sentinel installable elsewhere. Neither package can be a hard dependency,\n * so each is loaded only if present and skipped in silence if not. Elsewhere this file does nothing;\n * here both are present and the behaviour is the one the jest setup had.\n *\n * Silence is the right answer for an absent package and the wrong one for a broken package, so a\n * load that fails for any other reason is re-thrown rather than swallowed.\n */\nimport { createRequire } from 'node:module'\nimport { join } from 'node:path'\n\nimport { findWorkspaceRoot } from '../../../core/workspace-prep.js'\n\n/** Was this module absent, as opposed to present and broken? */\nfunction isMissingModule(error: unknown): boolean {\n return (error as { code?: string } | null)?.code === 'ERR_MODULE_NOT_FOUND'\n}\n\n/**\n * Optional by construction: `import()` inside a try, so a missing package is a no-op rather than a\n * failure at load time. A static import would make every one of them a hard dependency.\n */\nasync function optional(specifier: string, use: (module: unknown) => void): Promise<void> {\n try {\n use(await import(/* @vite-ignore */ specifier))\n } catch (error) {\n if (!isMissingModule(error)) throw error\n }\n}\n\n/**\n * The MODULE's copy of a package, not sentinel's.\n *\n * Under pnpm, an import written here resolves from sentinel's own directory, so it sees only\n * sentinel's dependencies. That is right for anything whose effect is GLOBAL, and wrong for\n * anything whose effect is per-copy: pinning `Settings.defaultZone` on sentinel's luxon leaves\n * the module's luxon in the machine's local zone, and the tests drift by an hour twice a year\n * with nothing saying why.\n *\n * Measured 2026-09-21: neither `luxon` nor `dotenv-flow` resolves from sentinel, while both\n * resolve from the module under test. The silent `optional` above therefore skipped BOTH, so a\n * migrated suite lost the `.env` cascade and the UTC pin at once, without a word.\n */\nfunction fromModule(specifier: string): unknown | undefined {\n try {\n const require = createRequire(join(process.cwd(), 'noop.cjs'))\n return require(specifier)\n } catch {\n return undefined\n }\n}\n\n/**\n * `dotenv-flow`, which the root jest setup loaded first.\n *\n * Vite's own `.env` handling does NOT replace it, which was checked before writing this. Measured on\n * Vitest 4 against a fixture holding `.env` and `.env.test`: the cascade is read and `MODE` is\n * `test`, but only `VITE_`-prefixed values are exposed, and only on `import.meta.env`. `process.env`\n * comes back untouched, and the code under test reads unprefixed `process.env`.\n *\n * `purge_dotenv` is carried across: it clears variables a previous load left behind, and without it\n * a value from one run leaks into the next. Not a detail in a suite that asserts on URLs.\n */\nasync function loadEnvironment(): Promise<void> {\n // A plain dependency of sentinel now: it mutates `process.env`, which is global, so WHICH copy\n // runs does not matter. It is the other half of replacing the root setup, and the root is going\n // away (Héla, 2026-09-21: \"mon but est de supprimer la config root\").\n await optional('dotenv-flow', (module) => {\n const flow = module as {\n config?: (options: Record<string, unknown>) => void\n default?: unknown\n }\n const config =\n flow.config ?? (flow.default as { config?: (o: Record<string, unknown>) => void })?.config\n /*\n * From the WORKSPACE ROOT, not from the module.\n *\n * dotenv-flow reads its cascade from the current directory, and the two runners do not share\n * one: jest ran from the repo root, where `.env`, `.env.test` and `.env.token` live, while\n * `sentinel --run --test` runs from the module, where there is nothing to read. Measured on\n * `libs/cloud/events-notifications`: from the module, a service call waits for an endpoint its\n * env never named and the test dies on a 5 s timeout; from the root, it answers in 200 ms.\n *\n * The root is found rather than configured: the setup cannot be handed a value, since a module\n * that overrides `test.env` would replace whatever the preset injected there.\n */\n const workspaceRoot = findWorkspaceRoot(process.cwd())\n config?.({\n silent: true,\n purge_dotenv: true,\n ...(workspaceRoot === undefined ? {} : { path: workspaceRoot }),\n })\n })\n}\n\n/**\n * Luxon's default zone, carried as luxon's own setting and NOT translated to `process.env.TZ`.\n *\n * They are different instructions: one configures luxon, the other the whole process, `Date` and\n * `Intl` included. Swapping them would change what a suite does while claiming to migrate it, and\n * timezone is not a detail here — a machine's zone accounted for a large part of 345 local failures\n * on `host-admin` that did not exist in CI.\n */\nasync function pinLuxonZone(): Promise<void> {\n // The module's copy, deliberately: `Settings` is per-copy state, so sentinel's own luxon is the\n // one package this setup must NOT configure.\n /*\n * Through the RUNNER's resolver first, which is what the tests use. `fromModule` goes through\n * `require`, and a package shipping both builds hands it the CJS one while Vite hands the tests\n * the ESM one. Two copies, two `Settings`, and the pin lands on the one nobody reads: measured on\n * `libs/cloud/events-notifications`, whose suite ran in `Europe/Paris` and compared timestamps\n * two hours apart. The preset aliases luxon to one path so both routes agree.\n */\n let pinned = false\n await optional('luxon', (module) => {\n const settings = (module as { Settings?: { defaultZone: string } }).Settings\n if (settings === undefined) return\n settings.defaultZone = 'utc'\n pinned = true\n })\n if (pinned) return\n\n const own = fromModule('luxon') as { Settings?: { defaultZone: string } } | undefined\n if (own?.Settings !== undefined) {\n own.Settings.defaultZone = 'utc'\n return\n }\n\n // Said out loud rather than skipped: a suite whose dates silently run in the machine's zone is\n // the kind of failure that gets blamed on the migration months later.\n process.stderr.write(\n 'sentinel (test): luxon was not found in this module, so the UTC default zone is NOT pinned. ' +\n 'Dates will follow the machine zone, as they did not under jest.\\n',\n )\n}\n\n/**\n * Everything the workspace needs beyond the msw lifecycle.\n *\n * NOT included: the `jest.mock('dynamoose')` and `jest.mock('@opentelemetry/exporter-metrics-otlp-grpc')`\n * calls the jest setup made. A module mock is a per-suite decision that `vi.mock` must make in the\n * file that needs it, and hoisting it into a shared setup is what makes a test pass for a reason\n * nobody can see. The migration reports them instead, so the module that relies on one declares it.\n */\nexport async function installWorkspaceSetup(): Promise<void> {\n await loadEnvironment()\n await pinLuxonZone()\n}\n"],"mappings":";;;;;;;;;AA6DA,SAAS,QAAQ,UAAU;;;ACA3B,SAAS,cAAc,OAAyB;AAC9C,SACE,OAAO,UAAU,cAAc,OAAO,yBAAyB,OAAO,WAAW,MAAM;AAE3F;AASA,SAAS,gBACP,gBACiC;A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AAkB,SAAY,CAAC,IAAI,EAAE,MAAM,cAAc;AAAA,IAC/D,CAAC;AAAA,EACH,CAAC;AACH;AAUA,eAAe,eAA8B;AAU3C,MAAI,SAAS;AACb,QAAM,SAAS,SAAS,CAAC,WAAW;AAClC,UAAM,WAAY,OAAkD;AACpE,QAAI,aAAa,OAAW;AAC5B,aAAS,cAAc;AACvB,aAAS;AAAA,EACX,CAAC;AACD,MAAI,OAAQ;AAEZ,QAAM,MAAM,WAAW,OAAO;AAC9B,MAAI,KAAK,aAAa,QAAW;AAC/B,QAAI,SAAS,cAAc;AAC3B;AAAA,EACF;AAIA,UAAQ,OAAO;AAAA,IACb;AAAA,EAEF;AACF;AAUA,eAAsB,wBAAuC;AAC3D,QAAM,gBAAgB;AACtB,QAAM,aAAa;AACrB;;;AR3FA,yBAAyB,MAAM;AAC/B,qBAAqB,EAAE;AACvB,gCAAgC,EAAE;AAClC,qBAAqB,EAAE;AACvB,4BAA4B,EAAE;AAC9B,4BAA4B;AAC5B,kBAAkB,EAAE;AAOpB,MAAM,sBAAsB;","names":["vi","vi","expect","vi","vi","vi","require"]}
@@ -0,0 +1,36 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ /** A TypeScript transformer a service runs at build time, as its build target declares it. */
4
+ interface TransformerDeclaration {
5
+ /** The package to load it from, e.g. `@nestjs/swagger/plugin`. */
6
+ name: string;
7
+ /** Passed to the transformer's own factory, unread here. */
8
+ options?: Record<string, unknown>;
9
+ }
10
+ interface DecoratorMetadataOptions {
11
+ /** The module being built. Its tsconfig is the one whose emit must be preserved. */
12
+ root: string;
13
+ /**
14
+ * An explicit tsconfig, when the service does not use either conventional name.
15
+ *
16
+ * Relative paths resolve against `root`.
17
+ */
18
+ tsconfig?: string;
19
+ /** The transformers this service declared, translated from its webpack target. */
20
+ transformers?: readonly TransformerDeclaration[];
21
+ }
22
+ declare const decoratorMetadata: (options: DecoratorMetadataOptions) => Plugin;
23
+
24
+ interface Alias {
25
+ find: RegExp;
26
+ replacement: string;
27
+ }
28
+ /**
29
+ * Read the mappings from the workspace's base tsconfig.
30
+ *
31
+ * Longest pattern first, because Vite takes the first alias that matches and the mappings
32
+ * overlap by design: `@front/theme/node` must not be swallowed by `@front/theme`.
33
+ */
34
+ declare const tsconfigAliases: (workspaceRoot: string, file?: string) => Alias[];
35
+
36
+ export { type Alias as A, type DecoratorMetadataOptions as D, decoratorMetadata as d, tsconfigAliases as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.3.0",
3
+ "version": "1.4.0-alpha.1",
4
4
  "description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -49,6 +49,22 @@
49
49
  "./test/react": {
50
50
  "types": "./dist/roles/test/react/toolchain.d.ts",
51
51
  "import": "./dist/roles/test/react/toolchain.js"
52
+ },
53
+ "./test/nest": {
54
+ "types": "./dist/roles/test/nest/toolchain.d.ts",
55
+ "import": "./dist/roles/test/nest/toolchain.js"
56
+ },
57
+ "./test/setup/nest": {
58
+ "types": "./dist/roles/test/setup/nest.d.ts",
59
+ "import": "./dist/roles/test/setup/nest.js"
60
+ },
61
+ "./test/msw": {
62
+ "types": "./dist/roles/test/setup/msw-server.d.ts",
63
+ "import": "./dist/roles/test/setup/msw-server.js"
64
+ },
65
+ "./test/setup/msw-lifecycle": {
66
+ "types": "./dist/roles/test/setup/msw-lifecycle.d.ts",
67
+ "import": "./dist/roles/test/setup/msw-lifecycle.js"
52
68
  }
53
69
  },
54
70
  "files": [
@@ -56,19 +72,23 @@
56
72
  "lint",
57
73
  "oxlint",
58
74
  "plugins",
59
- "!dist/**/*.map"
75
+ "!dist/**/*.map",
76
+ "dist/roles/**/*.map"
60
77
  ],
61
78
  "dependencies": {
62
79
  "@nx/eslint-plugin": "23.0.1",
63
80
  "@tailwindcss/vite": "4.1.18",
64
81
  "@vitejs/plugin-react": "6.0.1",
82
+ "@vitest/coverage-v8": "4.1.4",
65
83
  "commander": "^13.0.0",
84
+ "dotenv-flow": "4.1.0",
66
85
  "eslint-plugin-jest-dom": "5.5.0",
67
86
  "eslint-plugin-no-barrel-files": "1.2.1",
68
87
  "eslint-plugin-react-refresh": "0.4.19",
69
88
  "eslint-plugin-storybook": "10.3.5",
70
89
  "eslint-plugin-styled-components-a11y": "2.2.0",
71
90
  "jsonc-parser": "^3.3.1",
91
+ "msw": "1.3.3",
72
92
  "nitro": "3.0.260415-beta",
73
93
  "oxc-parser": "0.147.0",
74
94
  "oxfmt": "0.63.0",
@@ -77,7 +97,8 @@
77
97
  "typescript": "5.9.3",
78
98
  "vite": "8.2.2",
79
99
  "vite-plugin-svgr": "5.2.0",
80
- "vitest": "4.1.4"
100
+ "vitest": "4.1.4",
101
+ "vitest-mock-extended": "5.1.1"
81
102
  },
82
103
  "devDependencies": {
83
104
  "@hublo/sentinel": "link:.",