You can use Paramedic to build and run a Cordova app with plugin tests, run these tests on local emulators, and report the results. It can be used on a local or Continuous Integration environment.
Cordova Paramedic is currently used to automatically run all plugin tests on CI.
Specifies test plugin, you may specify multiple --plugin flags and they will all be installed and tested together. You can refer to absolute path, npm registry or git repo.
If the plugin requires variables to install, you can specify them along with its name.
Configuration file is used when no parameters are passed to cordova-paramedic call or explicitly specified via --config parameter:
cordova-paramedic <- paramedic will attempt to find .paramedic.config.js in working directory
cordova-paramedic --config ./sample-config/.paramedic.config.js
Cordova Paramedic (Test Automation)
cordova-paramedicis a tool to automate execution of Cordova plugins tests (viacordova-plugin-test-framework).You can use Paramedic to build and run a Cordova app with plugin tests, run these tests on local emulators, and report the results. It can be used on a local or Continuous Integration environment.
Cordova Paramedic is currently used to automatically run all plugin tests on CI.
(See this workshop instructions for some additional explanation.)
Table of Contents
--platform(required)--plugin(required)--verbose(optional)--cli(optional)--justbuild(optional)--target(optional)--timeout(optional)--outputDir(optional)--cleanUpAfterRun(optional)--tccDb(optional)--args(optional)Supported Cordova Platforms
What does it do?
A full Paramedic run will:
Create and prepare the app
cordova createcordova plugin add %local_path%(e.g.cordova plugin add ../cordova-plugin-inappbrowser):../cordova-plugin-inappbrowser)../cordova-plugin-inappbrowser/tests)cordova-plugin-test-framework(from npm)paramedic-plugincdvtests/index.html(provided bycordova-plugin-test-frameworkand the plugin tests)cordova platform add ...cordova requirements ...Run the tests
Either run the main tests locally...
Clean up
1. Handle timeouts of test execution above 2. Collect Device Logs 3. Uninstall App 4. Kill Emulator Process 5. Clean up ProjectInstallation
Using npmjs registry version:
Using GitHub version:
or
If cloning from GitHub, you will need to run
npm linkinside the checkout repository.Alternativly, replace all occurences of
cordova-paramedicwith the command:cordova-paramedic/main.jsfor Linux or macOSnode cordova-paramedic/main.jsfor WindowsUsage
Paramedic parameters can be passed via command line arguments or separate configuration file:
By Command Line Arguments:
By Configuration File:
Common usages
Some common use cases of Paramedic:
Run without any parameters to get a list of supported parameters:
Test your current plugin on an Android emulator:
Test your current plugin on a specific Android device (ID via
adb devices -l):Command Line Interface
What to build and test
--platform(required)Specifies target Cordova platform (could refer to local directory, npm or git)
--plugin(required)Specifies test plugin, you may specify multiple
--pluginflags and they will all be installed and tested together. You can refer to absolute path, npm registry or git repo. If the plugin requires variables to install, you can specify them along with its name.--verbose(optional)Verbose mode. Display more information output
--cli(optional)A path to Cordova CLI. Useful when you’re testing against locally installed Cordova version.
--justbuild(optional)Just builds the project, without running the tests.
Emulator/Device to use for tests
--target(optional)For Android: The device ID (from
adb devices -l) of a device the tests should be run on.For iOS: A string that is used to pick the device (from the
cordova run --list --emulatoroutput) the tests should be run on.Test configuration
--timeout(optional)Time in millisecs to wait for tests to pass|fail (defaults to 10 minutes).
--outputDir(optional)Directory location to store test results in junit format and the device logs
--cleanUpAfterRun(optional)Flag to indicate the sample application folder must be deleted.
--tccDb(optional)iOS only parameter. The path to the sample TCC DB file, with permissions, to be copied to the simulator.
--args(optional)Add additional parameters to the
cordova buildandcordova runcommands.Configuration file
Configuration file is used when no parameters are passed to
cordova-paramediccall or explicitly specified via--configparameter:Example configuration file is showed below.
More configuration file examples could be found in
sample-configfolder.API Interface
You can also use
cordova-paramedicas a module directly: