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.

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

copy
$
catalyst serve

This Alien City application is now served at default port 3000. The local endpoint URLs of the components are displayed.

Note: Every time you access the home page 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.

catalyst_alien_city_serve_node

You can now open the client component’s local URL in a browser to access the Alien City application.

catalyst_alien_city_catalyst_serve

Let’s test the application by entering a city’s name and checking for the history of an alien encounter in the city. Since we have not reported an alien encounter in a city yet, the result should be negative.

Enter a city name in the text box and click Check.

catalyst_alien_city_new_york

Since a matching record for this city is not found in the Data Store, the client displays a negative response.

catalyst_alien_city_new_york_no_alien

Now, let’s report an alien encounter. Click the Report Alien Encounter tab. Enter a city name and click Report. We have entered “Amsterdam” in our application.

catalyst_alien_city_report_encoutner

The application will display a pop-up box confirming that the data is added to the Data Store.

catalyst_alien_city_local_host_message

You can verify this by opening your Catalyst console and navigating to Data Store under Storage > CloudScale. Click the Data View tab to view the record that was just inserted.

catalyst_alien_city_data_view

Next, let’s search for this city in the client and check if it fetches this record from the Data Store. Click Check My City in the client application and enter the name of the city that you just reported. Here, we enter “Amsterdam”. Click Check.

catalyst_alien_city_report_created

The client displays a positive response.

You can also check if the client displays the duplication message by reporting the same city again.

catalyst_alien_ctiy_local_repeat_report

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


Last Updated 2024-06-12 17:41:34 +0530 +0530

RELATED LINKS

Serve CLI Resources