Testing framework for CodePush-compatible plugins with:
- Mocha helpers for integration suites
- Mock update server utilities
- Android and iOS emulator managers
- Scenario and update setup helpers for plugin repositories
npm install --save-dev @srcpush/plugin-testing-framework mochaThis framework is designed to run from the root of the plugin repository under test.
process.cwd()should point to the plugin repository- the plugin repository
package.jsonshould contain the pluginnameandversion - by default, the test app template is loaded from the package itself at
test/template - you can override the template path with
TEST_TEMPLATE_PATH
import{Platform,PluginTestingFramework,ProjectManager,TestBuilder,}from"@srcpush/plugin-testing-framework";classMyProjectManagerextendsProjectManager{publicgetPluginName(): string{return"react-native";}publicasyncsetupProject(): Promise<void>{thrownewError("Implement setupProject for your plugin");}publicasyncsetupScenario(): Promise<void>{thrownewError("Implement setupScenario for your plugin");}publicasynccreateUpdateArchive(): Promise<string>{thrownewError("Implement createUpdateArchive for your plugin");}publicasyncpreparePlatform(): Promise<void>{thrownewError("Implement preparePlatform for your plugin");}publicasynccleanupAfterPlatform(): Promise<void>{thrownewError("Implement cleanupAfterPlatform for your plugin");}publicasyncrunApplication(): Promise<void>{thrownewError("Implement runApplication for your plugin");}}constprojectManager=newMyProjectManager();constsupportedPlatforms=[newPlatform.Android(newPlatform.AndroidEmulatorManager()),newPlatform.IOS(newPlatform.IOSEmulatorManager()),];PluginTestingFramework.initializeTests(projectManager,supportedPlatforms,()=>{TestBuilder.describe("basic flow",()=>{TestBuilder.it("runs a core assertion",true,async(done)=>{done();});});});The framework reads these environment variables:
ANDROID_EMU: Android emulator nameIOS_EMU: iOS simulator identifierANDROID_SERVER: Android mock server URLIOS_SERVER: iOS mock server URLRUN_DIR: directory used for the working test appUPDATE_DIR: directory used for update packagesPLUGIN_PATH: override the plugin directory used fornpm packTEST_TEMPLATE_PATH: override the packaged test templateCORE=true: only run core testsCLEAN=true: restart emulators before setupNPM=true: install the plugin from npm instead ofnpm packIS_OLD_ARCHITECTURE=true: consumer-specific compatibility flag
npm install
npm run verifyThis repository is configured to publish to npm from GitHub Actions.
Recommended setup:
- Create the GitHub repository at
srcpush/plugin-testing-framework. - In npm, configure a trusted publisher for this repository and the workflow file
.github/workflows/publish.yml. - Publish a GitHub Release to trigger the npm workflow.
The package is published as @srcpush/plugin-testing-framework with public access.
MIT