Skip to content

Commit 819f866

Browse files
committed
Make docker container test less flaky
1 parent 5d4a466 commit 819f866

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

test/integration/interceptors/docker-attachment.spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,20 @@ describe('Docker single-container interceptor', function () {
120120
it(`should intercept external ${target} requests`, async function () {
121121
this.timeout(60000);
122122
const { interceptor, server } = await interceptorSetup;
123-
const mainRule = await server.forGet('https://example.com').thenReply(404);
123+
const mainRule = await server.forGet('https://example.testserver.host').thenReply(404);
124124

125125
const containerId = await buildAndRun(target.toLowerCase(), {
126-
arguments: ['https://example.com']
126+
arguments: ['https://example.testserver.host']
127127
});
128128

129-
await delay(500);
129+
// Wait up to 5 seconds for the interceptor to detect the container.
130+
// Should be much faster, can be slow in CI:
131+
for (let i = 0; i < 50; i++) {
132+
await delay(100);
133+
const { targets } = await interceptor.getMetadata!('summary');
134+
if (targets.length) break;
135+
}
136+
130137
expect(
131138
_.map(((await interceptor.getMetadata!('summary')).targets), ({ id }: any) => id)
132139
).to.include(containerId);
@@ -136,7 +143,7 @@ describe('Docker single-container interceptor', function () {
136143
await new Promise((resolve) => server.on('response', resolve));
137144

138145
const seenRequests = await mainRule.getSeenRequests();
139-
expect(seenRequests.map(r => r.url)).to.include('https://example.com/');
146+
expect(seenRequests.map(r => r.url)).to.include('https://example.testserver.host/');
140147
});
141148
});
142149

0 commit comments

Comments
 (0)