
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
cordova-plugin-test-framework
Advanced tools
The cordova-plugin-test-framework
plugin does two things:
Tests run directly inside existing cordova projects, so you can rapidly switch between testing and development. You can also be sure that your test suite is testing the exact versions of plugins and platforms that your app is using.
Use your existing cordova app, or create a new one.
Plugins bundle their tests using a nested plugin in a /tests
directory. To make this interesting, add some of these plugins and their respective tests. Here are a few examples:
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git#:/tests
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git#:/tests
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation#:/tests
Follow the docs for Setting up the test harness.
Add a directory named tests
to the root of your plugin. Within this directory, create a nested plugin.xml
for the tests plugin. It should have a plugin id with the form plugin-id-tests
(e.g. the cordova-plugin-device
plugin has the nested id cordova-plugin-device-tests
) and should contain a <js-module>
named tests
. E.g:
<js-module src="tests/tests.js" name="tests">
</js-module>
For example, the cordova-plugin-device
plugin has this nested plugin.xml
.
Create a package.json
inside your project's tests/
folder. Plugins require a package.json
now and tests are considered their own plugins. The latest version of the tools ensure to run npm install
on any plugin added to a project and pull in any dependencies. Therefore, plugin authors can now put npm dependencies around their tests into the package.json
file.
For example,the cordova-plugin-device
plugin contains a package.json
.
The cordova-plugin-test-framework
plugin will automatically find all tests
modules across all plugins for which the nested tests plugin is installed.
Simply export a function named defineAutoTests
, which (gasp!) defines your auto-tests when run. Use the jasmine-2.0
format. E.g.:
exports.defineAutoTests = function() {
describe('awesome tests', function() {
it('do something sync', function() {
expect(1).toBe(1);
...
});
it('do something async', function(done) {
setTimeout(function() {
expect(1).toBe(1);
...
done();
}, 100);
});
});
describe('more awesome tests', function() {
...
});
};
Note: Your tests will automatically be labeled with your plugin id, so do not prefix your test descriptions.
Simply export a function named defineManualTests
, which (gasp!) defines your manual-tests when run. Manual tests do not use jasmine-2.0, and success/failure results are not officially reported in any standard way. Instead, create buttons to run arbitrary javascript when clicked, and display output to user using console
or by manipulating a provided DOM element. E.g.:
exports.defineManualTests = function(contentEl, createActionButton) {
createActionButton('Simple Test', function() {
console.log(JSON.stringify(foo, null, '\t'));
});
createActionButton('Complex Test', function() {
contentEl.innerHTML = ...;
});
};
Note: Your tests will automatically be labeled with your plugin id, so do not prefix your test descriptions.
See: cordova-plugin-device
tests.
Use your existing cordova app, or create a new one.
Add this plugin:
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git
Change the start page in config.xml
with <content src="cdvtests/index.html" />
or navigate to cdvtests/index.html
from within your app.
Thats it!
Q: Should I add cordova-plugin-test-framework
as a <dependency>
of my plugin?
Q: What do I do if my plugin tests must have very large assets?
Q: Should I ship my app with the test framework plugin installed?
cdvtests/index.html
) from a help section of your app, to give end users a way to run your test suite out in the feild. That may help diagnose causes of issues within your app. Maybe.FAQs
Cordova Test Framework Plugin
The npm package cordova-plugin-test-framework receives a total of 245 weekly downloads. As such, cordova-plugin-test-framework popularity was classified as not popular.
We found that cordova-plugin-test-framework demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.