Test your modules
  • 25 Mar 2024
  • 2 Minutes to read
  • Dark
    Light
  • PDF

Test your modules

  • Dark
    Light
  • PDF

Article summary

After you’ve written your module, you can test it by creating a demo app and installing your module in there. You can then run the demo app locally or deploy it using the Crowdbotics dashboard. This allows you to mimic the experience other developers will have when they install your module in their Crowdbotics app.

To create the demo app:

  1. In a terminal window, navigate to the location where you initialized your project.

  2. Run: cb demo

    --verbose — Optional — Provides additional information to help you understand the command's execution and troubleshoot any issues.

Add your module

You can now add your module to the demo app using the add command.

  • We recommend installing the react-native-app-menu module if you are testing a module that includes React Native, as this gives you an automatically populated app menu from which you can easily see all available routes—including your new module.

  • If you are working on a backend project, you can get a similar functionality by using the Django management command: manage.py show_urls.

    • On Docker, run this command (in a separate window from where you run docker-compose up):
      docker-compose exec web python3 manage.py show_urls

    • You can also add the following to filter for module-related URLs:
      …manage.py show_urls | grep  "modules"

Add your module to the demo app: cb add <module-type-prefix+module-name>

The module-name is the same as the folder in your modules repository. If you have any problems with this step, check to make sure that the meta.json file is configured with the project root, and that your names match.

Test your added module inside the demo project

There are two basic ways to test your module within the demo project: locally or by deploying using the Crowdbotics dashboard. You can do both! Local testing may be a little bit quicker if you are already set up with the Crowdbotics scaffold and docker, though deploying using the Crowdbotics dashboard lets you test more network functionality.

Running the app locally

  1. When your app is ready, run: cd demo

  2. To start the backend, run: cd backend 

  3. Follow the instructions in the backend/README.md file regarding setting up the app. We recommend Docker.

  4. To start the frontend, follow the instructions in demo/README.md file.
    You can run your app using the iOS emulator, Android emulator, or in the browser.

Deploying the app using the Crowdbotics dashboard

Using the Crowdbotics dashboard, you can create a new project from a GitHub repo. To do this, we’ll first create a repo for the demo app, then use the dashboard to deploy our app.

  1. Find the associated GitHub repository in the settings panel of your app.

  2. Clone that git repo.

  3. Navigate to the cloned repo: cd <path/to/your/new-project-repo>

  4. Remove all the code generated in this repo: rm -r *
    You will replace this with the code from modules/demo.

  5. Copy your demo app into your newly empty project: 
    cp -r path/to/modules/demo path/to/your/new-project-repo

  6. Commit and push your changes to the remote repository.

  7. Deploy using the Crowdbotics dashboard.

Once your app is deployed, you can use https://app.crowdbotics.com/dashboard/app/settings to generate admin credentials. You can then navigate to the Django admin panel for your app by going to: https://app.crowdbotics.com/admin

API documentation for your app is automatically generated and available at: your-app-slug.crowdbotics.com/api-docs/


Was this article helpful?