Skip to main content
Testing config plugins ensures they work correctly and helps prevent regressions. This guide covers testing strategies with examples from the Expo source.

Testing strategies

Config plugins should be tested at multiple levels:
  1. Unit tests: Test plugin logic in isolation
  2. Integration tests: Test with actual native project files
  3. End-to-end tests: Test full prebuild workflow

Unit testing plugins

Unit tests verify plugin logic without touching the filesystem.

Basic plugin test

Testing Info.plist modifications

Testing Android Manifest modifications

Testing with real fixtures

Use fixture files from actual projects for integration testing.

Setting up fixtures

Loading and testing with fixtures

Testing code generation

Test that code injection is idempotent.

Testing with mock filesystem

Use memfs to test filesystem operations without touching disk.

Example tests from Expo source

Here are patterns from Expo’s test suite:

Testing permission helpers

Permissions-test.ts

Testing entitlements

Entitlements-test.ts

Integration testing with prebuild

Test the full prebuild process in a temporary directory.

Continuous integration

Add plugin tests to your CI pipeline. GitHub Actions example:
.github/workflows/test.yml

Best practices

1. Test edge cases

2. Test idempotency

3. Use snapshots for complex output

4. Mock external dependencies

Debugging tests

Enable debug output in tests:

Next steps