Add xpath support for Problem Matcher
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the enhancement
Sniffing through logs using RegExp can be hairy especially if your need multiline line matching. In my particular use case I want to write a Problem Matcher for jest. The output from jest is very human friendly.
FAIL ./app.spec.js
compare a and b
✕ should fail (7ms)
● compare a and b › should fail
expect(received).toBe(expected) // Object.is equality
Expected: "b"
Received: "a"
1 | describe('compare a and b', function() {
2 | it('should fail', function() {
> 3 | expect('a').toBe('b');
| ^
4 | });
5 | });
6 |
at Object.<anonymous> (app.spec.js:3:21)
Jest provides a CLI argument to print the test results in JSON. However, parsing this output using RegExp isn't that simple either.
What if the Problem Matcher API would allow us to use xpath to grep values from a json file on disc. Such an API would be useful and quite powerful addition.
Code Snippet
{
"problemMatcher": [
{
"owner": "jest",
"pattern": [
{
"source": "./path/to/file.json",
"file": $.testResults[*].name,
"message": $.testResults[*].assertionResults[*].failureMessages
}
]
}
]
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Problem Matcher API and reviewing how its current pattern configuration is parsed. The issue names no files or tests; done would require a decided design for extracting values from JSON files with XPath-like selectors, documented configuration behavior, and coverage for the proposed matching cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100