If your API changes, you probably want's to know what components you have to change,
You can write that's kind of tests for that (it's call Contract Testing), but I prefer to use type.
Do you use TypeScript ? Does your API is written in TypeScript or have a swagger?
The API is GraphQL and created with Php/Laravel. I use typescript in my Nuxt project, does it help to write less test? if yes, could you explain how, please?
I will write a post with a full explain, but in short :
You generate TypeScript typing from GraphQL using tools.
Add/Replace the result files in your client project.
Type your fetch's result with generated files.
// GeneratedtypedataType={field:string;};asyncfunctionfetchData():Promise<dataType>{constfetchResult=awaitfetch("dataUrl");constjson=awaitfetchResult.json();returnjsonasdataType;}asyncfunctiontestIt(){constres=awaitfetchData();console.log(res.field);// get a typescript error if field no more in dataType}
Each time you update your API, make the 2 first step. If there is changes, you're client won't compile (if he use an out of date field).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If your API changes, you probably want's to know what components you have to change,
You can write that's kind of tests for that (it's call Contract Testing), but I prefer to use type.
Do you use TypeScript ? Does your API is written in TypeScript or have a swagger?
The API is GraphQL and created with Php/Laravel. I use typescript in my Nuxt project, does it help to write less test? if yes, could you explain how, please?
I will write a post with a full explain, but in short :
Each time you update your API, make the 2 first step. If there is changes, you're client won't compile (if he use an out of date field).