Skip to content

Commit 27f6501

Browse files
committed
fix(types): cleanup testing helper types
1 parent 9f3398b commit 27f6501

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ async function readOptions<
9494
};
9595
}
9696

97-
export function getExistingApp<SLocals extends ServiceLocals = ServiceLocals>() {
98-
if (!app) {
99-
throw new Error('getExistingApp requires a running app, and there is not one available.');
100-
}
101-
return app as ServiceExpress<SLocals>;
102-
}
103-
10497
class RequestTestingHelpers {
10598
_fetch: ReturnType<typeof makeFetch>;
10699

@@ -117,6 +110,18 @@ class RequestTestingHelpers {
117110
}
118111
}
119112

113+
export interface ServiceUnderTest<SLocals extends ServiceLocals = ServiceLocals>
114+
extends ServiceExpress<SLocals> {
115+
test: RequestTestingHelpers;
116+
}
117+
118+
export function getExistingApp<SLocals extends ServiceLocals = ServiceLocals>() {
119+
if (!app) {
120+
throw new Error('getExistingApp requires a running app, and there is not one available.');
121+
}
122+
return app as ServiceUnderTest<SLocals>;
123+
}
124+
120125
export async function getReusableApp<
121126
SLocals extends ServiceLocals = ServiceLocals,
122127
RLocals extends RequestLocals = RequestLocals,
@@ -125,7 +130,7 @@ export async function getReusableApp<
125130
| Partial<ServiceStartOptions<SLocals, RLocals>>
126131
| ServiceFactory<SLocals, RLocals>,
127132
cwd?: string,
128-
): Promise<ServiceExpress<SLocals> & { test: RequestTestingHelpers }> {
133+
): Promise<ServiceUnderTest<SLocals>> {
129134
const logFn = (error: Error) => {
130135
// eslint-disable-next-line no-console
131136
console.error('Could not start app', error);

0 commit comments

Comments
 (0)