You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have worked a little bit on the library (see #13) and it would have been super helpful to have a suite of tests to be sure that I was not breaking anything during the refactoring. I want to collect here some ideas, to see if we can come up with something that can be useful.
Jest testing + Mocks
Potentially we could use Jest to test the API calls (using mocks for the API responses), even if I am not 100% sure how much this would be helpful (eg. we would not notice a change a break in the code if Figma updates their APIs, because we're mocking them). Any ideas of possible workaround or approaches for testing API interfaces?
Figma file
We could have a Figma file (.fig) attached to repo, that one can import and then, updating the file ID/key in a specific file, one can run a set of tests against that file (eg. during the development I created a script that listed/posted/deleted comments to a file). Of course, we can't test every API method (eg. we would need a team) but maybe a subset of calls could be tested directly using the real Figma APIs (we test the requests me make, we tests the responses we receive). We could even go further, and create a Figma user (with an email owned by @Morglod) with a base license (in that case I suppose you can test even more calls).
Use figma-api-gen to generate schemas for methods & types
Create readonly-public figma file with tons of different nodes, effects, properties
Call api on figma file & test it with schemas
Its also necessary, because figma's api doc is not really accurate; some nodes & apis was different in real use (one of the reason for 'yet another api package')
Also with figma-api-gen is planned to use diffs on generated schemas to automatically find changes in api; it may be useful for testing suite
Whoops, I came here by accident, but I have an idea 😂
From what I read is what you want to do is use contract testing (instead of mocks). Tools like polly.js can do that (would be my goto). They record the API response and store it in a file (you commit that file to the repo). Next time tests are run, they use the file (if available) and replay the response. If the file cannot be found another recording will be done. The recorded response is a snapshot at a given time. To update the tests, all you have to do is delete the file and run the tests again.
... now that I describe that, it is mocks - but automated? 😅
I have worked a little bit on the library (see #13) and it would have been super helpful to have a suite of tests to be sure that I was not breaking anything during the refactoring. I want to collect here some ideas, to see if we can come up with something that can be useful.
Jest testing + Mocks
Potentially we could use Jest to test the API calls (using mocks for the API responses), even if I am not 100% sure how much this would be helpful (eg. we would not notice a change a break in the code if Figma updates their APIs, because we're mocking them). Any ideas of possible workaround or approaches for testing API interfaces?
Figma file
We could have a Figma file (
.fig
) attached to repo, that one can import and then, updating the file ID/key in a specific file, one can run a set of tests against that file (eg. during the development I created a script that listed/posted/deleted comments to a file). Of course, we can't test every API method (eg. we would need a team) but maybe a subset of calls could be tested directly using the real Figma APIs (we test the requests me make, we tests the responses we receive). We could even go further, and create a Figma user (with an email owned by @Morglod) with a base license (in that case I suppose you can test even more calls).Any other ideas, suggestions?
/cc @honzatmn maybe you have also some ideas :)
The text was updated successfully, but these errors were encountered: