Skip to content

Commit 29e6118

Browse files
committed
fix: delay stubbed query responses for more realistic tests
1 parent 25afc21 commit 29e6118

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/shared/sandboxMockUtils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ type SbxProcessSqlConfig = {
189189
/**
190190
* Stubs the query for the newly created SandboxProcess from a sandbox update.
191191
* Stubs the query for a cloned sandbox process (see `CreateSandbox.getSourceId()`).
192+
* The query response is delayed 100ms for a more realistic test and to prevent
193+
* issues with sandbox cache (ConfigFile) merging/writing.
192194
*
193195
* @param config
194196
* @returns sinon.SinonStub
@@ -198,5 +200,11 @@ export const stubToolingQuery = (config: ToolingQueryStubConfig): sinon.SinonStu
198200
return sinonSandbox
199201
.stub(connection.tooling, 'query')
200202
.withArgs(sandboxProcessSoql)
201-
.resolves({ records: [sbxProcess], done: true, totalSize: 1 });
203+
.callsFake(
204+
async () =>
205+
// @ts-expect-error return type doesn't match the complex query type
206+
new Promise((resolve) => {
207+
setTimeout(() => resolve({ records: [sbxProcess], done: true, totalSize: 1 }), 100);
208+
})
209+
);
202210
};

0 commit comments

Comments
 (0)