Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add TextEditor.getBreakpoint(line: number): Promise<Breakpoint> #1510

Merged
merged 1 commit into from
Sep 4, 2024
Merged
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
15 changes: 15 additions & 0 deletions packages/page-objects/src/components/editor/TextEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,21 @@ export class TextEditor extends Editor {
return new Breakpoint(breakpoints[0], lineElement);
}

/**
* Get paused breakpoint on line if available. Otherwise, return undefined.
* @param line number of the line to retrieve
* @returns promise which resolves to either Breakpoint page object or undefined
*/
async getBreakpoint(line: number): Promise<Breakpoint | undefined> {
const breakpoints = await this.getBreakpoints();
for (const breakpoint of breakpoints) {
if ((await breakpoint.getLineNumber()) === line) {
return breakpoint;
}
}
return undefined;
}

/**
* Get all breakpoints.
* @returns List of Breakpoints.
Expand Down
5 changes: 5 additions & 0 deletions tests/test-project/src/test/debug/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ describe('Debugging', function () {
)) as Breakpoint;
});

it('TextEditor: getBreakpoint works', async function () {
const breakpoint = await editor.getBreakpoint(7);
expect(breakpoint).not.undefined;
});

it('TextEditor: getBreakpoints works', async function () {
const breakpoints = editor.getBreakpoints();
expect((await breakpoints).length).equals(2);
Expand Down