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";
class MyProjectManager extends ProjectManager {
public getPluginName(): string {
return "react-native";
}
public async setupProject(): Promise<void> {
throw new Error("Implement setupProject for your plugin");
}
public async setupScenario(): Promise<void> {
throw new Error("Implement setupScenario for your plugin");
}
public async createUpdateArchive(): Promise<string> {
throw new Error("Implement createUpdateArchive for your plugin");
}
public async preparePlatform(): Promise<void> {
throw new Error("Implement preparePlatform for your plugin");
}
public async cleanupAfterPlatform(): Promise<void> {
throw new Error("Implement cleanupAfterPlatform for your plugin");
}
public async runApplication(): Promise<void> {
throw new Error("Implement runApplication for your plugin");
}
}
const projectManager = new MyProjectManager();
const supportedPlatforms = [
new Platform.Android(new Platform.AndroidEmulatorManager()),
new Platform.IOS(new Platform.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