Skip to content

Commit 04d2fbf

Browse files
author
cod1k
committed
Add abort signals to test runners
Updated test definitions across multiple suites to accept and pass abort signals (`signal`) for enhanced request handling. Adjusted the `start` method in the test runner to support optional abort signals.
1 parent 41cec5b commit 04d2fbf

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

dev-packages/cloudflare-integration-tests/runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function createRunner(...paths: string[]) {
8686
}
8787
return this;
8888
},
89-
start: function (): StartResult {
89+
start: function (signal?: AbortSignal): StartResult {
9090
const { resolve, reject, promise: isComplete } = deferredPromise(cleanupChildProcesses);
9191
const expectedEnvelopeCount = expectedEnvelopes.length;
9292

@@ -155,7 +155,7 @@ export function createRunner(...paths: string[]) {
155155
'--var',
156156
`SENTRY_DSN:http://public@localhost:${mockServerPort}/1337`,
157157
],
158-
{ stdio },
158+
{ stdio, signal },
159159
);
160160

161161
CLEANUP_STEPS.add(() => {

dev-packages/cloudflare-integration-tests/suites/basic/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, it } from 'vitest';
22
import { eventEnvelope } from '../../expect';
33
import { createRunner } from '../../runner';
44

5-
it('Basic error in fetch handler', async () => {
5+
it('Basic error in fetch handler', async ({ signal }) => {
66
const runner = createRunner(__dirname)
77
.expect(
88
eventEnvelope({
@@ -26,7 +26,7 @@ it('Basic error in fetch handler', async () => {
2626
},
2727
}),
2828
)
29-
.start();
29+
.start(signal);
3030
await runner.makeRequest('get', '/', { expectError: true });
3131
await runner.completed();
3232
});

dev-packages/cloudflare-integration-tests/suites/tracing/anthropic-ai/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createRunner } from '../../../runner';
66
// want to test that the instrumentation does not break in our
77
// cloudflare SDK.
88

9-
it('traces a basic message creation request', async () => {
9+
it('traces a basic message creation request', async ({ signal }) => {
1010
const runner = createRunner(__dirname)
1111
.ignore('event')
1212
.expect(envelope => {
@@ -35,7 +35,7 @@ it('traces a basic message creation request', async () => {
3535
]),
3636
);
3737
})
38-
.start();
38+
.start(signal);
3939
await runner.makeRequest('get', '/');
4040
await runner.completed();
4141
});

dev-packages/cloudflare-integration-tests/suites/tracing/durableobject/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, it } from 'vitest';
22
import { createRunner } from '../../../runner';
33

4-
it('traces a durable object method', async () => {
4+
it('traces a durable object method', async ({ signal }) => {
55
const runner = createRunner(__dirname)
66
.expect(envelope => {
77
const transactionEvent = envelope[1]?.[0]?.[1];
@@ -21,7 +21,7 @@ it('traces a durable object method', async () => {
2121
}),
2222
);
2323
})
24-
.start();
24+
.start(signal);
2525
await runner.makeRequest('get', '/hello');
2626
await runner.completed();
2727
});

dev-packages/cloudflare-integration-tests/suites/tracing/openai/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createRunner } from '../../../runner';
66
// want to test that the instrumentation does not break in our
77
// cloudflare SDK.
88

9-
it('traces a basic chat completion request', async () => {
9+
it('traces a basic chat completion request', async ({ signal }) => {
1010
const runner = createRunner(__dirname)
1111
.ignore('event')
1212
.expect(envelope => {
@@ -37,7 +37,7 @@ it('traces a basic chat completion request', async () => {
3737
]),
3838
);
3939
})
40-
.start();
40+
.start(signal);
4141
await runner.makeRequest('get', '/');
4242
await runner.completed();
4343
});

0 commit comments

Comments
 (0)