Skip to content

Commit 5a76df8

Browse files
committed
Load response bodies from files
1 parent 9764a93 commit 5a76df8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

extensions/ql-vscode/src/mocks/request-handlers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,17 @@ async function readRequestFiles(scenarioDirPath: string): Promise<GitHubApiReque
3939

4040
const requests: GitHubApiRequest[] = [];
4141
for (const file of orderedFiles) {
42+
if (!file.endsWith('.json')) {
43+
continue;
44+
}
45+
4246
const filePath = path.join(scenarioDirPath, file);
4347
const request: GitHubApiRequest = await fs.readJson(filePath, { encoding: 'utf8' });
48+
49+
if (typeof request.response.body === 'string' && request.response.body.startsWith('file:')) {
50+
request.response.body = await fs.readFile(path.join(scenarioDirPath, request.response.body.substring(5)));
51+
}
52+
4453
requests.push(request);
4554
}
4655

0 commit comments

Comments
 (0)