Escape-Technologies / graphman

Quikly scaffold a postman collection for a GraphQL API. Compatible with Postman & Insomnia.
MIT License
240 stars 11 forks source link

Generate sample test cases for collections #32

Open Gbahdeyboh opened 1 year ago

Gbahdeyboh commented 1 year ago

GraphQL is a very declarative query language. It provides a declarative approach to data fetching. From the schema, you already know what kind of data to expect and you can choose to request just what you need.

Postman has something called postman scripts that can be used to write unit-like tests. Its assertion and test suite were built atop mocha and chai making it quite similar in usage to them.

Postman scripts can be written and run in the tests tab in Postman, which is a NodeJS runtime environment for collections.

Because of the declarative nature of GraphQL, it is possible to generate sample test cases for GraphQL APIs on postman collections. It doesn't have to be anything fancy, it could be just very basic data validation checks for s start.

I am not familiar with what Escape provides, but we could also have a few security test cases that are auto-generated and can be run on the fly.

nohehf commented 1 year ago

That's a cool idea, tho apart from just creating the test structure and maybe asserting the data types and testing a few limit cases (like wrong input and so on) I don't believe that we could really generate useful tests. And sadly including Escape like tests (even small ones) would be really hard. I'll let the issue open for now but I don't think is a priority for now, tho any suggestions are welcomed. :)