How to test locally hosted page with google tool before release

There are two solutions available:

One is to simply test the code directly on the test page. The three google search testing tools, namely Mobile Friendly tool, AMP testing page, and the Rich Snippet/ Strucure Data testing tool offer this possibility. You have to keep in mind that external resources such as your css and js files should also be available for rendering in the case of the Mobile friendly tool.

You can modify your code directly online and test your modification which is a really nice feature.

If you want to integrate the test in your workflow but your pages are hosted behind a firewall or are simply available on your local machine, google wrote a nice article on how to make this file available for testing online.

https://developers.google.com/search/docs/guides/debug