netlify-plugin-gatsby
                                
                                 netlify-plugin-gatsby copied to clipboard
                                
                                    netlify-plugin-gatsby copied to clipboard
                            
                            
                            
                        test: [draft] proof of concept to improve test speed
Summary
This is a proof of concept to rewrite the createMetadataFileAndCopyDatastore unit tests using mocked file operations.
Previously, the createMetadataFileAndCopyDatastore tests copied the whole Gatsby demo directory to a temporary folder and executed tests against them. Copying the Gatsby files and cleaning them up afterwards pushes each test to approximately 25 seconds even though the code being tested executes quickly. These execute more like end-to-end tests than unit tests.
I've added a draft.config.spec.ts test suite which mocks out all necessary file operations and the uuidv4 creation. This allows us to quickly execute the tests and control the flow of necessary operations. There should be 100% test coverage of this function.
Test plan
All tests should execute as previously but the new draft.config.spec.ts tests should be super speedy. 🏎️
Local execution time
| Test Suite | Description | Execution Time | 
|---|---|---|
| config.spec.ts | Only createMetadataFileAndCopyDatastoretests enabled | ~79.544s | 
| draft.config.spec.ts | Only testing createMetadataFileAndCopyDatastore | ~3.713s | 
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Deploy Preview for netlify-plugin-gatsby-demo ready!
| Name | Link | 
|---|---|
| Latest commit | 2536f34eeb234c0dafcf86e71083c8e9d41ff307 | 
| Latest deploy log | https://app.netlify.com/sites/netlify-plugin-gatsby-demo/deploys/62d677f9e9e2c4000819950b | 
| Deploy Preview | https://deploy-preview-438--netlify-plugin-gatsby-demo.netlify.app | 
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. | 
To edit notification comments on pull requests, go to your Netlify site settings.
Thanks for doing this!
I think this change improves the tests significantly and is worth investing the time to get this polished up and merged.
Perhaps once we have this merged in we can take a look at similar tests in the NextJS plugin and see if we can apply similar improvements there.