diffplug / diffplug/selfie

fluent API for snapshotting only specific subsets of a snapshot

Open
#482 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
101
Forks
18
PR merge metrics
No merged PRs in 30d

Description

It would be nice to be able to truncate a snapshot to only certain specific lines. Something like:

```java
expectSelfie(blah).lines(1).toBe_TODO() // first line
expectSelfie(blah).lines(2).toBe_TODO() // first two lines
expectSelfie(blah).lines(-2).toBe_TODO() // last two lines
expectSelfie(blah).lines(-1).toBe_TODO() // last one line

var snapshot = expectSelfie(blah)
snapshot.lines(2).toBe_TODO() // first two lines
snapshot.lines(-2).toBe_TODO() // last two lines
```

I have also sometimes wanted to match a certain regex, like maybe

```
expectSelfie(blah).withinRegex("(?m)^.*$\n?^.*$").toBe_TODO()
```

So far, each time that I have wanted this, I have found a better way to solve this by filtering before the snapshot gets taken...

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the existing expectSelfie API and how snapshot values are matched. Clarify whether line selection and regex matching are still needed, define their semantics, and agree on the fluent API before identifying implementation and test locations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.