@terreno/test 57.18.0 → 57.19.2

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 (115) hide show
  1. package/CHANGELOG.md +1681 -0
  2. package/README.md +6 -0
  3. package/dist/assertions/expectAPIError.d.ts +18 -0
  4. package/dist/assertions/expectAPIError.js +33 -0
  5. package/dist/assertions/strictResponseProperties.d.ts +14 -0
  6. package/dist/assertions/strictResponseProperties.js +37 -0
  7. package/dist/cache/mongoTestCache.js +2 -2
  8. package/dist/cli/collectFiles.d.ts +38 -0
  9. package/dist/cli/collectFiles.js +73 -0
  10. package/dist/cli/testHygiene.d.ts +134 -0
  11. package/dist/cli/testHygiene.js +357 -0
  12. package/dist/cli/testHygieneCli.d.ts +2 -0
  13. package/dist/cli/testHygieneCli.js +5 -0
  14. package/dist/cli/testHygieneRules.d.ts +58 -0
  15. package/dist/cli/testHygieneRules.js +517 -0
  16. package/dist/cli/testShard.d.ts +155 -0
  17. package/dist/cli/testShard.js +377 -0
  18. package/dist/cli/testShardCli.d.ts +2 -0
  19. package/dist/cli/testShardCli.js +5 -0
  20. package/dist/expo/authTokenStorage.d.ts +76 -0
  21. package/dist/expo/authTokenStorage.js +160 -0
  22. package/dist/expo/expoModuleMocks.d.ts +24 -0
  23. package/dist/expo/expoModuleMocks.js +456 -0
  24. package/dist/expo/libraryModuleMocks.d.ts +17 -0
  25. package/dist/expo/libraryModuleMocks.js +347 -0
  26. package/dist/expo/mockHelpers.d.ts +39 -0
  27. package/dist/expo/mockHelpers.js +45 -0
  28. package/dist/expo/mockModuleAliases.d.ts +50 -0
  29. package/dist/expo/mockModuleAliases.js +174 -0
  30. package/dist/expo/reactNativeMock.d.ts +39 -0
  31. package/dist/expo/reactNativeMock.js +421 -0
  32. package/dist/expo/registerExpoTestEnvironment.d.ts +69 -0
  33. package/dist/expo/registerExpoTestEnvironment.js +163 -0
  34. package/dist/expo/renderWithTerreno.d.ts +47 -0
  35. package/dist/expo/renderWithTerreno.js +47 -0
  36. package/dist/http/authWithToken.d.ts +20 -0
  37. package/dist/http/authWithToken.js +30 -0
  38. package/dist/index.d.ts +14 -1
  39. package/dist/index.js +33 -1
  40. package/dist/logging/silenceLogs.js +0 -2
  41. package/dist/mocks/aiSdk.d.ts +77 -0
  42. package/dist/mocks/aiSdk.js +102 -0
  43. package/dist/mocks/cloudTasks.d.ts +91 -0
  44. package/dist/mocks/cloudTasks.js +197 -0
  45. package/dist/mocks/expoPush.d.ts +53 -0
  46. package/dist/mocks/expoPush.js +57 -0
  47. package/dist/mocks/gcs.d.ts +101 -0
  48. package/dist/mocks/gcs.js +162 -0
  49. package/dist/mocks/googleAuth.d.ts +69 -0
  50. package/dist/mocks/googleAuth.js +55 -0
  51. package/dist/mocks/mockGroup.d.ts +11 -0
  52. package/dist/mocks/mockGroup.js +21 -0
  53. package/dist/mocks/notifiers.d.ts +21 -0
  54. package/dist/mocks/notifiers.js +26 -0
  55. package/dist/mocks/sendgrid.d.ts +22 -0
  56. package/dist/mocks/sendgrid.js +32 -0
  57. package/dist/mocks/twilio.d.ts +72 -0
  58. package/dist/mocks/twilio.js +64 -0
  59. package/dist/preload/registerBackendPreload.js +4 -1
  60. package/dist/time/freezeTime.d.ts +16 -0
  61. package/dist/time/freezeTime.js +49 -0
  62. package/dist/transaction/testTransaction.d.ts +43 -6
  63. package/dist/transaction/testTransaction.js +371 -92
  64. package/dist/utils/waitUntil.d.ts +22 -0
  65. package/dist/utils/waitUntil.js +34 -0
  66. package/package.json +53 -8
  67. package/src/assertions/expectAPIError.ts +51 -0
  68. package/src/assertions/strictResponseProperties.ts +42 -0
  69. package/src/cache/mongoTestCache.ts +2 -2
  70. package/src/cli/collectFiles.ts +115 -0
  71. package/src/cli/testHygiene.ts +539 -0
  72. package/src/cli/testHygieneCli.ts +4 -0
  73. package/src/cli/testHygieneRules.ts +719 -0
  74. package/src/cli/testShard.ts +532 -0
  75. package/src/cli/testShardCli.ts +4 -0
  76. package/src/expo/authTokenStorage.ts +198 -0
  77. package/src/expo/expoModuleMocks.ts +503 -0
  78. package/src/expo/libraryModuleMocks.ts +411 -0
  79. package/src/expo/mockHelpers.ts +73 -0
  80. package/src/expo/mockModuleAliases.ts +252 -0
  81. package/src/expo/reactNativeMock.ts +534 -0
  82. package/src/expo/registerExpoTestEnvironment.ts +260 -0
  83. package/src/expo/renderWithTerreno.ts +79 -0
  84. package/src/http/authWithToken.ts +38 -0
  85. package/src/index.ts +82 -1
  86. package/src/logging/silenceLogs.ts +0 -2
  87. package/src/mocks/aiSdk.ts +199 -0
  88. package/src/mocks/cloudTasks.ts +323 -0
  89. package/src/mocks/expoPush.ts +134 -0
  90. package/src/mocks/gcs.ts +305 -0
  91. package/src/mocks/googleAuth.ts +136 -0
  92. package/src/mocks/mockGroup.ts +32 -0
  93. package/src/mocks/notifiers.ts +36 -0
  94. package/src/mocks/sendgrid.ts +57 -0
  95. package/src/mocks/twilio.ts +143 -0
  96. package/src/preload/registerBackendPreload.ts +4 -1
  97. package/src/time/freezeTime.ts +61 -0
  98. package/src/transaction/testTransaction.ts +456 -124
  99. package/src/utils/waitUntil.ts +47 -0
  100. package/biome.jsonc +0 -20
  101. package/bunfig.toml +0 -16
  102. package/src/cache/mongoTestCache.test.ts +0 -103
  103. package/src/env/setTerrenoTestEnv.test.ts +0 -26
  104. package/src/http/authAsUser.test.ts +0 -40
  105. package/src/http/getBaseServer.test.ts +0 -45
  106. package/src/logging/setupEnvironment.test.ts +0 -24
  107. package/src/logging/silenceLogs.test.ts +0 -52
  108. package/src/logging/testLogger.test.ts +0 -58
  109. package/src/mocks/sentryBun.test.ts +0 -230
  110. package/src/mongo/connection.test.ts +0 -43
  111. package/src/mongo/mongoServer.test.ts +0 -99
  112. package/src/preload/registerBackendPreload.test.ts +0 -10
  113. package/src/transaction/testTransaction.test.ts +0 -64
  114. package/src/utils/helpers.test.ts +0 -46
  115. package/tsconfig.json +0 -18
@@ -0,0 +1,260 @@
1
+ import {afterEach, beforeEach, mock, setSystemTime} from "bun:test";
2
+ import {DateTime} from "luxon";
3
+
4
+ import {
5
+ clearAuthTokenStorage,
6
+ createAuthTokenStorageModuleMocks,
7
+ resetAuthTokenStorageMocks,
8
+ } from "./authTokenStorage";
9
+ import {
10
+ createExpoGlobal,
11
+ createExpoModuleMocks,
12
+ type ExpoModuleMockOptions,
13
+ } from "./expoModuleMocks";
14
+ import {createLibraryModuleMocks} from "./libraryModuleMocks";
15
+ import type {ModuleFactory, ModuleMockMap} from "./mockHelpers";
16
+ import {createReactNativeModuleMocks} from "./reactNativeMock";
17
+
18
+ /** What the `afterEach` hook the registrar installs resets. Every flag defaults to `true`. */
19
+ export interface ExpoTestCleanupOptions {
20
+ /** Empty the in-memory SecureStore/AsyncStorage and reset their mocks. */
21
+ clearStorage?: boolean;
22
+ /** `mock.restore()`: put every `spyOn` spy back. Does not undo `mock.module`. */
23
+ restoreMocks?: boolean;
24
+ /**
25
+ * Specifiers whose environment mock is re-registered after each test, undoing a suite's own
26
+ * `mock.module` for them (which `mock.restore()` cannot). Default `[]`.
27
+ */
28
+ restoreModules?: readonly string[];
29
+ /** Set `__DEV__` back to `true`. */
30
+ resetDevFlag?: boolean;
31
+ }
32
+
33
+ /** Options for `registerExpoTestEnvironment`. Every field is optional. */
34
+ export interface ExpoTestEnvironmentOptions extends ExpoModuleMockOptions {
35
+ /** Install the `afterEach` reset (`true`), skip it (`false`), or pick its steps. Default `true`. */
36
+ cleanup?: boolean | ExpoTestCleanupOptions;
37
+ /** ISO timestamp the clock is frozen at before each test (`setSystemTime`). Default: real clock. */
38
+ fixedNow?: string;
39
+ /**
40
+ * Package prefixes that hold their own `react-native` copy, e.g. `"@terreno/ui/node_modules/"`.
41
+ * Bun loads a nested copy as a separate module, so it needs its own mock.
42
+ */
43
+ nestedPackagePrefixes?: readonly string[];
44
+ /** Factories that replace a default mock, or add a module the defaults do not cover. */
45
+ overrides?: ModuleMockMap;
46
+ /**
47
+ * Directory the app resolves packages from. Each mock is also registered under the file path a
48
+ * specifier resolves to from here, so it still applies when the app and `@terreno/test` resolve
49
+ * a package to different copies. `false` registers bare specifiers only. Default `process.cwd()`.
50
+ */
51
+ resolveFrom?: string | false;
52
+ /** Write `TZ` and `EXPO_OS` into `process.env`. Default `true`. */
53
+ setProcessEnv?: boolean;
54
+ /** Specifiers to leave unmocked (the real module loads). */
55
+ skip?: readonly string[];
56
+ /** Serve image, font, and media imports as Metro-style asset stubs. Default `true`. */
57
+ stubAssets?: boolean;
58
+ }
59
+
60
+ /** Handle returned by `registerExpoTestEnvironment`. */
61
+ export interface ExpoTestEnvironment {
62
+ /** The specifiers mocked, in registration order. */
63
+ mockedModules: string[];
64
+ /** Re-registers this environment's mock for `specifier`, undoing a suite's own `mock.module`. */
65
+ restoreModuleMock: (specifier: string) => void;
66
+ }
67
+
68
+ /** File extensions served as `{uri, width, height}` stubs instead of being parsed as code. */
69
+ export const ASSET_FILE_PATTERN =
70
+ /\.(png|jpe?g|gif|webp|bmp|svg|ttf|otf|woff2?|mp3|mp4|wav|m4a|mov)$/u;
71
+
72
+ interface ExpoTestGlobals {
73
+ __DEV__?: boolean;
74
+ IS_REACT_ACT_ENVIRONMENT?: boolean;
75
+ expo?: unknown;
76
+ }
77
+
78
+ let isAssetPluginInstalled = false;
79
+
80
+ const installAssetPlugin = (): void => {
81
+ if (isAssetPluginInstalled) {
82
+ return;
83
+ }
84
+ isAssetPluginInstalled = true;
85
+ // Metro turns asset imports into descriptors; Bun would try to parse the bytes as JavaScript.
86
+ Bun.plugin({
87
+ name: "terreno-expo-asset-stub",
88
+ setup(build) {
89
+ build.onLoad({filter: ASSET_FILE_PATTERN}, () => ({
90
+ exports: {default: {height: 1, uri: "test-asset", width: 1}},
91
+ loader: "object",
92
+ }));
93
+ },
94
+ });
95
+ };
96
+
97
+ const installGlobals = (): void => {
98
+ const globals = globalThis as typeof globalThis & ExpoTestGlobals;
99
+ globals.__DEV__ = true;
100
+ globals.IS_REACT_ACT_ENVIRONMENT = true;
101
+ if (globals.expo !== undefined) {
102
+ return;
103
+ }
104
+ // expo-modules-core reads `globalThis.expo` when it loads, before any native module call.
105
+ globals.expo = createExpoGlobal();
106
+ };
107
+
108
+ const tryResolve = (specifier: string, fromDirectory: string): string | undefined => {
109
+ try {
110
+ return Bun.resolveSync(specifier, fromDirectory);
111
+ } catch {
112
+ return undefined;
113
+ }
114
+ };
115
+
116
+ /** Every module the environment mocks by default, keyed by specifier. */
117
+ export const createDefaultExpoModuleMocks = ({
118
+ nestedPackagePrefixes = [],
119
+ platform = "ios",
120
+ ...expoOptions
121
+ }: Pick<ExpoTestEnvironmentOptions, "nestedPackagePrefixes"> &
122
+ ExpoModuleMockOptions = {}): ModuleMockMap => ({
123
+ ...createReactNativeModuleMocks({packagePrefixes: ["", ...nestedPackagePrefixes], platform}),
124
+ ...createExpoModuleMocks({...expoOptions, platform}),
125
+ ...createLibraryModuleMocks(),
126
+ ...createAuthTokenStorageModuleMocks(),
127
+ });
128
+
129
+ const resolveCleanup = (
130
+ cleanup: ExpoTestEnvironmentOptions["cleanup"]
131
+ ): Required<ExpoTestCleanupOptions> | undefined => {
132
+ if (cleanup === false) {
133
+ return undefined;
134
+ }
135
+ const options = cleanup === true || cleanup === undefined ? {} : cleanup;
136
+ return {
137
+ clearStorage: options.clearStorage ?? true,
138
+ resetDevFlag: options.resetDevFlag ?? true,
139
+ restoreMocks: options.restoreMocks ?? true,
140
+ restoreModules: options.restoreModules ?? [],
141
+ };
142
+ };
143
+
144
+ /**
145
+ * Prepares Bun to run Expo / React Native component tests. Call it from a `bunfig.toml` preload
146
+ * (or at the top of a test file, then `await import()` what the test renders) before anything
147
+ * imports `react-native`:
148
+ *
149
+ * - mocks `react-native` and its Flow-only internals, the common `expo-*` modules,
150
+ * `expo-router`, `@expo/vector-icons`, and common native libraries (Reanimated, Gesture
151
+ * Handler, SVG, safe-area-context, NetInfo, SecureStore, AsyncStorage, ...);
152
+ * - sets `__DEV__`, `IS_REACT_ACT_ENVIRONMENT`, `globalThis.expo`, `TZ`, and `EXPO_OS`;
153
+ * - stubs image / font / media imports;
154
+ * - installs an `afterEach` that restores spies, empties the in-memory storage, and resets
155
+ * `__DEV__`.
156
+ *
157
+ * `skip` leaves a module real; `overrides` replaces or adds a factory.
158
+ */
159
+ export const registerExpoTestEnvironment = (
160
+ options: ExpoTestEnvironmentOptions = {}
161
+ ): ExpoTestEnvironment => {
162
+ const {
163
+ cleanup,
164
+ fixedNow,
165
+ overrides = {},
166
+ platform = "ios",
167
+ resolveFrom = process.cwd(),
168
+ setProcessEnv = true,
169
+ skip = [],
170
+ stubAssets = true,
171
+ timeZone = "America/New_York",
172
+ } = options;
173
+
174
+ const frozenAt = fixedNow ? DateTime.fromISO(fixedNow, {setZone: true}) : undefined;
175
+ if (frozenAt && !frozenAt.isValid) {
176
+ throw new Error(`registerExpoTestEnvironment: fixedNow "${fixedNow}" is not an ISO timestamp`);
177
+ }
178
+
179
+ if (setProcessEnv) {
180
+ process.env.TZ = timeZone;
181
+ process.env.EXPO_OS = platform;
182
+ }
183
+ installGlobals();
184
+ if (stubAssets) {
185
+ installAssetPlugin();
186
+ }
187
+
188
+ const skipped = new Set(skip);
189
+ const defaults = createDefaultExpoModuleMocks({
190
+ expoConfig: options.expoConfig,
191
+ locale: options.locale,
192
+ nestedPackagePrefixes: options.nestedPackagePrefixes,
193
+ platform,
194
+ scheme: options.scheme,
195
+ timeZone,
196
+ });
197
+ const factories: ModuleMockMap = {...defaults, ...overrides};
198
+
199
+ const register = (specifier: string, factory: ModuleFactory): void => {
200
+ mock.module(specifier, factory);
201
+ if (resolveFrom === false) {
202
+ return;
203
+ }
204
+ const appPath = tryResolve(specifier, resolveFrom);
205
+ if (appPath && appPath !== tryResolve(specifier, __dirname)) {
206
+ mock.module(appPath, factory);
207
+ }
208
+ };
209
+
210
+ const mockedModules: string[] = [];
211
+ for (const [specifier, factory] of Object.entries(factories)) {
212
+ if (skipped.has(specifier)) {
213
+ continue;
214
+ }
215
+ register(specifier, factory);
216
+ mockedModules.push(specifier);
217
+ }
218
+
219
+ const restoreModuleMock = (specifier: string): void => {
220
+ const factory = factories[specifier];
221
+ if (!factory || skipped.has(specifier)) {
222
+ throw new Error(`registerExpoTestEnvironment does not mock "${specifier}"`);
223
+ }
224
+ register(specifier, factory);
225
+ };
226
+
227
+ if (frozenAt) {
228
+ beforeEach(() => {
229
+ setSystemTime(frozenAt.toJSDate());
230
+ });
231
+ }
232
+
233
+ const cleanupSteps = resolveCleanup(cleanup);
234
+ const isStorageMocked = !skipped.has("expo-secure-store") && !("expo-secure-store" in overrides);
235
+ if (cleanupSteps || frozenAt) {
236
+ afterEach(() => {
237
+ if (frozenAt) {
238
+ setSystemTime();
239
+ }
240
+ if (!cleanupSteps) {
241
+ return;
242
+ }
243
+ if (cleanupSteps.restoreMocks) {
244
+ mock.restore();
245
+ }
246
+ if (cleanupSteps.clearStorage && isStorageMocked) {
247
+ clearAuthTokenStorage();
248
+ resetAuthTokenStorageMocks();
249
+ }
250
+ if (cleanupSteps.resetDevFlag) {
251
+ (globalThis as typeof globalThis & ExpoTestGlobals).__DEV__ = true;
252
+ }
253
+ for (const specifier of cleanupSteps.restoreModules) {
254
+ restoreModuleMock(specifier);
255
+ }
256
+ });
257
+ }
258
+
259
+ return {mockedModules, restoreModuleMock};
260
+ };
@@ -0,0 +1,79 @@
1
+ import {TerrenoProvider, type TerrenoProviderProps} from "@terreno/ui";
2
+ import {type RenderOptions, type RenderResult, render} from "@testing-library/react-native";
3
+ import {type ComponentType, createElement, type ReactElement, type ReactNode} from "react";
4
+
5
+ /** The slice of a Redux store `react-redux`'s `Provider` needs. */
6
+ export interface ReduxStoreLike {
7
+ dispatch: (action: never) => unknown;
8
+ getState: () => unknown;
9
+ subscribe: (listener: () => void) => () => void;
10
+ }
11
+
12
+ /** `TerrenoProvider` props a test can set: color scheme, theme primitives, icons, OpenAPI URL. */
13
+ export type TerrenoThemeOptions = Omit<TerrenoProviderProps, "children">;
14
+
15
+ /** Options for `renderWithTerreno` and `createTerrenoWrapper`. */
16
+ export interface RenderWithTerrenoOptions extends Omit<RenderOptions, "wrapper"> {
17
+ /** Redux store to provide. Requires the optional `react-redux` peer dependency. */
18
+ store?: ReduxStoreLike;
19
+ /** Props passed to `TerrenoProvider`. */
20
+ theme?: TerrenoThemeOptions;
21
+ /** Extra provider rendered inside `TerrenoProvider`, around the element under test. */
22
+ wrapper?: ComponentType<{children: ReactNode}>;
23
+ }
24
+
25
+ type ProviderComponent = ComponentType<{children?: ReactNode; store: ReduxStoreLike}>;
26
+
27
+ /**
28
+ * `react-redux` is optional, so it is only loaded when a test passes a store. `load` exists so the
29
+ * missing-package error can be tested without uninstalling the package.
30
+ */
31
+ export const loadReduxProvider = (
32
+ load: () => unknown = (): unknown => require("react-redux")
33
+ ): ProviderComponent => {
34
+ try {
35
+ return (load() as {Provider: ProviderComponent}).Provider;
36
+ } catch (error) {
37
+ throw new Error(
38
+ "renderWithTerreno: passing `store` requires the `react-redux` package. Install it as a devDependency.",
39
+ {cause: error}
40
+ );
41
+ }
42
+ };
43
+
44
+ /**
45
+ * Builds the wrapper `renderWithTerreno` uses — an optional Redux `Provider`, then
46
+ * `TerrenoProvider`, then `wrapper` — for `renderHook` or a custom `render` call.
47
+ */
48
+ export const createTerrenoWrapper = ({
49
+ store,
50
+ theme = {},
51
+ wrapper: InnerWrapper,
52
+ }: Pick<RenderWithTerrenoOptions, "store" | "theme" | "wrapper"> = {}): ComponentType<{
53
+ children: ReactNode;
54
+ }> => {
55
+ const ReduxProvider = store ? loadReduxProvider() : undefined;
56
+ const TerrenoWrapper = ({children}: {children: ReactNode}): ReactElement => {
57
+ const content = InnerWrapper ? createElement(InnerWrapper, null, children) : children;
58
+ const themed = createElement(TerrenoProvider, {...theme, children: content});
59
+ if (!ReduxProvider || !store) {
60
+ return themed;
61
+ }
62
+ return createElement(ReduxProvider, {store}, themed);
63
+ };
64
+ return TerrenoWrapper;
65
+ };
66
+
67
+ /**
68
+ * Renders `ui` with `@testing-library/react-native` inside `TerrenoProvider` (theme, icons,
69
+ * toasts, portal host), and inside a Redux `Provider` when `store` is given.
70
+ *
71
+ * Requires the optional peers `@terreno/ui`, `@testing-library/react-native`, `react`, and
72
+ * `react-native` (mocked by `registerExpoTestEnvironment`), plus `react-redux` for `store`.
73
+ */
74
+ export const renderWithTerreno = (
75
+ ui: ReactElement,
76
+ {store, theme, wrapper, ...renderOptions}: RenderWithTerrenoOptions = {}
77
+ ): RenderResult => {
78
+ return render(ui, {...renderOptions, wrapper: createTerrenoWrapper({store, theme, wrapper})});
79
+ };
@@ -0,0 +1,38 @@
1
+ import type express from "express";
2
+ import supertest from "supertest";
3
+ import type TestAgent from "supertest/lib/agent";
4
+
5
+ export interface AuthWithTokenOptions {
6
+ /** Access token to send, usually minted with `@terreno/api`'s `generateTokens(user, authOptions)`. */
7
+ token: string | null | undefined;
8
+ /** Extra headers set on every request, e.g. `{"app-version": "1.10.0"}`. */
9
+ headers?: Record<string, string>;
10
+ }
11
+
12
+ /**
13
+ * Returns a supertest agent that sends `Authorization: Bearer <token>` on every request.
14
+ *
15
+ * Pair it with a token minted directly from the user to skip `POST /auth/login`, whose password
16
+ * hashing costs ~200ms per call. Keep `authAsUser` for tests that exercise the login flow itself.
17
+ *
18
+ * ```ts
19
+ * const {token} = await generateTokens(user, authOptions);
20
+ * const agent = await authWithToken(app, {token});
21
+ * ```
22
+ */
23
+ export const authWithToken = async (
24
+ app: express.Application,
25
+ {token, headers = {}}: AuthWithTokenOptions
26
+ ): Promise<TestAgent> => {
27
+ if (!token) {
28
+ throw new Error(
29
+ "authWithToken: token is empty; check that the user exists and TOKEN_SECRET is set"
30
+ );
31
+ }
32
+ const agent = supertest.agent(app);
33
+ await agent.set("authorization", `Bearer ${token}`);
34
+ for (const [key, value] of Object.entries(headers)) {
35
+ await agent.set(key, value);
36
+ }
37
+ return agent;
38
+ };
package/src/index.ts CHANGED
@@ -1,11 +1,16 @@
1
+ export {type ExpectedAPIError, expectAPIError} from "./assertions/expectAPIError";
2
+ export {
3
+ assertStrictResponseProperties,
4
+ collectPropertyPaths,
5
+ } from "./assertions/strictResponseProperties";
1
6
  export {
2
7
  createMongoTestCache,
3
8
  type MongoTestCacheController,
4
9
  type MongoTestCacheOptions,
5
10
  } from "./cache/mongoTestCache";
6
-
7
11
  export {setTerrenoTestEnv, type TerrenoTestEnvOptions} from "./env/setTerrenoTestEnv";
8
12
  export {type AuthAsUserOptions, type AuthUserCredentials, authAsUser} from "./http/authAsUser";
13
+ export {type AuthWithTokenOptions, authWithToken} from "./http/authWithToken";
9
14
  export {type GetBaseServerOptions, getBaseServer} from "./http/getBaseServer";
10
15
  export {
11
16
  createLogSilencer,
@@ -13,7 +18,78 @@ export {
13
18
  type SilenceLogsController,
14
19
  type SilenceLogsOptions,
15
20
  } from "./logging/silenceLogs";
21
+ export {
22
+ type CreateMockLanguageModelOptions,
23
+ createMockLanguageModel,
24
+ type MockLanguageModel,
25
+ type MockLanguageModelFinishReason,
26
+ type MockLanguageModelGenerateResult,
27
+ type MockLanguageModelResponse,
28
+ type MockLanguageModelStreamPart,
29
+ type MockLanguageModelToolCall,
30
+ type MockLanguageModelUsage,
31
+ mockLanguageModelStreamParts,
32
+ } from "./mocks/aiSdk";
33
+ export {
34
+ type CloudTasksCreateTaskRequest,
35
+ type CloudTasksHttpRequest,
36
+ type CloudTasksMock,
37
+ type CloudTasksMockClient,
38
+ type CloudTasksTask,
39
+ type CloudTasksTime,
40
+ type DrainCloudTasksOptions,
41
+ type DrainedCloudTask,
42
+ decodeCloudTaskBody,
43
+ type EnqueuedCloudTask,
44
+ registerCloudTasksMock,
45
+ } from "./mocks/cloudTasks";
46
+ export {
47
+ type ExpoMockClient,
48
+ type ExpoMockPushMessage,
49
+ type ExpoMockPushReceipt,
50
+ type ExpoMockPushTicket,
51
+ type ExpoPushMock,
52
+ registerExpoPushMock,
53
+ } from "./mocks/expoPush";
54
+ export {
55
+ type GcsFileMocks,
56
+ type GcsGetFilesQuery,
57
+ type GcsMock,
58
+ type GcsMockBucket,
59
+ type GcsMockFile,
60
+ type GcsObjectMetadata,
61
+ type GcsSaveOptions,
62
+ type GcsStoredObject,
63
+ registerGcsMock,
64
+ } from "./mocks/gcs";
65
+ export {
66
+ type GoogleAuthMock,
67
+ type GoogleAuthMockClient,
68
+ type GoogleAuthMockIdTokenPayload,
69
+ type GoogleAuthMockRequestOptions,
70
+ type GoogleAuthMockResponse,
71
+ type GoogleAuthMockTicket,
72
+ type RegisterGoogleAuthMockOptions,
73
+ registerGoogleAuthMock,
74
+ } from "./mocks/googleAuth";
75
+ export {registerTerrenoNotifierMocks, type TerrenoNotifierMocks} from "./mocks/notifiers";
76
+ export {
77
+ registerSendGridMock,
78
+ type SendGridMock,
79
+ type SendGridMockResponse,
80
+ type SendGridMockSendResult,
81
+ } from "./mocks/sendgrid";
16
82
  export {registerSentryBunMock} from "./mocks/sentryBun";
83
+ export {
84
+ registerTwilioMock,
85
+ type TwilioMessageCreateParams,
86
+ type TwilioMock,
87
+ type TwilioMockClient,
88
+ type TwilioMockMessage,
89
+ type TwilioMockVerification,
90
+ type TwilioMockVerificationCheck,
91
+ type TwilioMockVerifyService,
92
+ } from "./mocks/twilio";
17
93
  export {
18
94
  buildDatabaseUri,
19
95
  DEFAULT_LOCAL_MONGO_URI,
@@ -40,12 +116,16 @@ export {
40
116
  registerSimpleMongoPreload,
41
117
  type SimpleMongoPreloadOptions,
42
118
  } from "./preload/registerBackendPreload";
119
+ export {type FreezeTimeInput, type FreezeTimeOptions, freezeTime} from "./time/freezeTime";
43
120
  export {
121
+ type AbortTestTransactionOptions,
44
122
  abortTestTransaction,
45
123
  getTestSession,
46
124
  installTransactionPatches,
125
+ isTestTransactionOperationCancelled,
47
126
  resetTestSessionAfterReconnect,
48
127
  startTestTransaction,
128
+ TestTransactionOperationCancelledError,
49
129
  } from "./transaction/testTransaction";
50
130
  export {ensureAllIndexes} from "./utils/ensureAllIndexes";
51
131
  export {timeout} from "./utils/timeout";
@@ -54,3 +134,4 @@ export {
54
134
  waitForDocument,
55
135
  waitForDocuments,
56
136
  } from "./utils/waitForDocuments";
137
+ export {type WaitUntilOptions, waitForCalls, waitUntil} from "./utils/waitUntil";
@@ -22,8 +22,6 @@ export interface SilenceLogsController {
22
22
  const getApiWinstonLogger = (): winston.Logger | undefined => {
23
23
  try {
24
24
  // Runtime-only so @terreno/test compiles without @terreno/api.
25
- // noExplicitAny: optional peer resolved at preload time
26
- // biome-ignore lint/suspicious/noExplicitAny: optional peer resolved at preload time
27
25
  const api = require("@terreno/api") as any;
28
26
  return api.winstonLogger as winston.Logger | undefined;
29
27
  } catch {