This POC was built to demonstrate a few things:
- Establish a pattern for how ajaxed HTML content can also load JavaScript dependencies into an app
- Build upon #1 and support a way of testing each API endpoint individually via e2e testing
nvm use # used node 18
npm ci
npm start
Then visit http://localhost:3000/.
The demo has clickable buttons that fetch HTML partials wrapped in JSON. Each button loads the content into a different part of the page and passes custom values to the hydration function.
This demo was created with Cypress. You can run the test by running:
npm run cypress
The test itself is not that interesting. The important take way is the the same API endpoint used in the normal app is loaded into a wrapper template with its hydration logic immediately invoked. This demonstrates how you can use the same endpoint as JSON but also test each endpoint directly.