kinbiko / kinbiko/jsonassert

[Feature Request] Generate expected output

Open
#41 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
143
Forks
18
Avg merge
2d 15h
Merged PRs (30d)
3

Description

## What problem are you trying to solve?
I understand that this is an assertion tool and not a snapshotting tool, but it's the best choice for asserting that the JSON returned from an API call is correct, and in general it works fantastically for this.

However, it is slightly clunky when you are first writing a test. Unless you know exactly what the JSON should look like, you either need to generate it manually and paste into the test or else go through one value at a time fixing up errors until the test passes. Both of which are awkward.

(And yes, I'm aware this is slightly lazy, but it's super convenient especially when there's a lot of large JSON responses to check)

## Describe how you wish this package would help you solve the problem
It would be fantastic if there were some way that the library could output the full actual JSON in some cases. Maybe if the expected JSON were just the blank string, for example.

That way you could write a test of
```
ja.Assertf(string(body), ``)
```

Run the test, copy the output JSON into the test and know that it's correct.

Contributor guide

Open the contributing guide

Research direction

Start with the ja.Assertf entry point shown in the example and review the existing JSON assertion failure behavior and tests. Define how an empty expected value should produce the full actual JSON, then verify that the output can be copied into a test and preserves semantic JSON equality.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.