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(console-reporter): Generating code snippets on error #2270

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

In1th
Copy link
Contributor

@In1th In1th commented Mar 4, 2024

@In1th
Copy link
Contributor Author

In1th commented Mar 4, 2024

@jan-molak I did a base version, but I have to ask you - are stack format library independent? Because if that's not the case, then we need parser for every one of them.

(also you tried to chat with me on serenity chat, but there were some encryption issue)

@jan-molak
Copy link
Member

Hey @In1th - you can use the existing ErrorStackParser.
Here's an example of how to turn a StackFrame into a FileSystemLocation

@@ -30,10 +30,12 @@ import {
ProblemIndication,
} from '@serenity-js/core/lib/model';
import { Instance as ChalkInstance } from 'chalk'; // eslint-disable-line unicorn/import-style
import type { FileSystem } from 'packages/core/lib/io';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want @serenity-js/core/lib/io instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I noticed vs code is not doing great with this repo 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what causes it 🤔

@In1th
Copy link
Contributor Author

In1th commented Mar 7, 2024

Ok I have done some refactoring and added a flag to add tests for snippets, but I don't see any integration test using console reporter. Should I add a new integration test project for that or did I miss anything?

@jan-molak
Copy link
Member

jan-molak commented Mar 9, 2024

I don't see any integration test using console reporter

Console reporter is reasonably simple and doesn't require a separate integration test module.
Have a look at ConsoleReporter.spec.ts.

The best way to test it is to pump a stream of events into it and then assert on the output.

To generate a stream of events you can:

Since the events generated by all the test runners are identical, we don't need to test the console reporter with each test runner, just with the events.

@In1th
Copy link
Contributor Author

In1th commented Mar 19, 2024

Ok, I have it!
Screenshot 2024-03-19 at 01 53 02
Though it doesn't have code highlighting, and it's not so smart as playwright's.

Just need ok for this layout, still gotta figure out how to add user path to tests and how to change console reporter static methods to support snippets

@jan-molak
Copy link
Member

@In1th - Looks awesome, great work so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants