Test the Application

Before you deploy the application to the remote console, you can test the application on a local server and check if everything works fine using the Catalyst CLI.

We will first test the cron function using the functions shell in the CLI, and then serve the Advanced I/O function and the client locally to test the frontend of the application.

To open the functions shell in your CLI, execute the following command from your project directory (CATALYST_PROJECT_HOME):

copy
$
catalyst functions:shell

This will open the functions shell for the cron function in the CLI where you can test its execution.

cron_function_node_shell

To invoke the function, enter newsapp() in the shell and press Enter. This will make the API call to NewsAPI and fetch the news items from each category, and populate them in the Data Store. cron_node_shell

The CLI will display the status of the function execution. The CLI will display the status of the function execution. You can exit the functions shell by killing the terminal command based on your local environment.

Now, let’s host the client component locally and check the frontend of the application.

To serve the Catalyst project locally, execute the following command from your project directory (CATALYST_PROJECT_HOME):

copy
$
catalyst serve

The news application will now be served at default port 3000. The local endpoint URLs of the components are displayed.

Note: Every time you access the homepage or any of the sub-pages of your client or the function, the CLI will display a live log of the URL accessed, along with the HTTP request method.

cron_node_serve


You can now open the application in a browser using the local URL of the client displayed in the CLI.

cron_catalyst_output


The news application displays the general news headlines in the index page. You can click a topic on the left to check the latest headlines in that category. You can open the original news article by clicking on a headline.

You can also open your Catalyst console to check the data populated in the tables in the Data Store. Click on a table’s name in the Data Store, and click Data View to check the records.

cron_node_dataview


If this setup is working correctly, we can deploy the application to production.

You can quit the serve command session in your terminal by pressing Ctrl+C keys twice.

Last Updated 2023-12-15 18:54:08 +0530 +0530

RELATED LINKS

Serve Resources