Hi all,
We’re excited to release an open beta of a new Blocks Testing package!
This new npm
package will make it much easier to write tests for the apps that you build - crucially, without having to rely on the Airtable backend to run your block in a testing environment.
With the Blocks Testing package, you’re able to create a new test driver instance:
import TestDriver from '@airtable/blocks-testing';
import MyApp from '../frontend/my-app';
const testDriver = new TestDriver({
/* test fixture data here */
});
render(
<testDriver.Container>
<MyApp />
</testDriver.Container>,
);
Add input to the app:
await testDriver.base.createTableAsync('a new table', [
{name: 'address', type: FieldType.EMAIL},
]);
And verify that the app works as expected:
const checkbox = screen.getByRole('checkbox');
expect(checkbox.checked).toBe(true);
The Blocks Testing package is compatible with many popular testing frameworks, so you can choose your favorite way to write your tests.
We’ve published a new guide that walks you through how to set up and use this new testing package.
We’ve also updated our Todo List and Update Record example blocks with new example tests, to show you how you might write these tests in practice.
Our ultimate goal is for our Airtable blocks platform to better support increasingly powerful, large-scale apps, and automated testing is a crucial component of this.
As always, we’d love your feedback on this new Blocks Testing package!