Configure local testing

Testing your data project locally ensures that your resources are working as expected before you deploy your project to Tinybird.

There are several ways of generating test data for your local project. You can:

This is an experimental version of Tinybird. Join #forward in our Slack community to share your feedback.

Check deployment

After you finish developing your project, run tb deploy --check to validate the deployment before creating it. This is a good way of catching potential breaking changes. See tb deploy for more information.

tb deploy --check    
Running against Tinybird Local

» Validating deployment...

» Changes to be deployed...

-----------------------------------------------------------------
| status   | name         | path                                |
-----------------------------------------------------------------
| modified | user_actions | datasources/user_actions.datasource |
-----------------------------------------------------------------

✓ Deployment is valid

Fixture files

Fixtures are NDJSON files that contain sample data for your project. Fixtures are stored inside the fixtures folder in your project.

my-app/
├─ datasources/
│  ├─ user_actions.datasource
│  └─ ...
├─ fixtures/
│  ├─ user_actions.ndjson
│  └─ ...

Every time you run tb build, the CLI checks for fixture files and includes them in the build. Fixture files must have the same name as the associated .datasource file.

Generate mock data

The tb mock command creates fixtures based on your data sources. See tb mock for more information.

For example, the following command creates a fixture for the user_actions data source.

tb mock user_actions

» Creating fixture for user_actions...
✓ /fixtures/user_actions.ndjson created
...

You can use the --prompt flag to add more context to the data that is generated. For example:

tb mock user_actions --prompt "Create mock data for 23 users from the US"`

Call the Events API

Another way of testing your project is to call the local Events API endpoint using a generator, for example Mockingbird.

Obtain a token using tb token ls. Then, use the a command to send data to the local Events API endpoint:

# Install the Mockingbird CLI
npm install @tinybirdco/mockingbird-cli

# Call the Events API
TB_ENDPOINT=http://localhost mockingbird-cli tinybird
  --schema schema.json \
  --datasource "<your_data_source>" \
  --token "<your_token>" \
  --endpoint "custom" \
  --eps 50 \
  --limit 200

As you call the Events API, you can see errors and warnings in the console. Use this information to debug your datafiles.

Create a test suite

Once your project builds correctly, you can generate a test suite using tb test.

For example, the following command creates a test suite for the user_action_insights_widget pipe.

# Pass a pipe name to create a test
tb test create user_action_insights_widget

Then, customize the tests to fit your needs.

You can use the --prompt flag to add more context to the data that is generated. For example:

tb test create user_action_insights_widget --prompt "Make sure total events is 1014"

Next steps

Updated