Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/browser/run/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,14 @@ describe('runBrowserProgram', () => {
expect(output.result).toBe('undefined');
});

it('serializes a program with no explicit return as null', async () => {
const output = await run(`
await page.getByRole('button', { name: 'Save' }).click();
`);

expect(output.result).toBeNull();
});

it('keeps time, memory, output, redaction, and serialization limits', async () => {
await expect(run('while (true) {}', { timeoutMs: 25 })).rejects.toMatchObject({
code: 'BROWSER_RUN_TIMEOUT',
Expand Down
2 changes: 1 addition & 1 deletion src/browser/run/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export async function runBrowserProgram(
rejectRun = undefined;
}
try {
const serialized = JSON.stringify(value);
const serialized = JSON.stringify(value === undefined ? null : value);
if (serialized === undefined) throw new TypeError('Result is not JSON serializable.');
return serialized;
} catch (cause) {
Expand Down