npm install -g phantomjs casperjs slimerjs
To test that Casper is properly installed:
casperjs test LiveTests.js --engine=slimerjs
To run Core projects Tests (Requires NOT having the persistence bundle):
casperjs test --includes=CoreTestsUtility.js CoreTests.js --engine=slimerjs
To run Persistence Tests (Requires the persistence bundle and a running MySQL server):
casperjs test PersistenceTests.js --engine=slimerjs
If the tests were executed successfully and passed, you’ll get something like this in your console.
image:
Tests are executed by default on port 8080. If you would like to execute tests on a different port, you can change it here.
If you have an error similar to this one:
Gecko error: it seems /usr/bin/firefox is not compatible with SlimerJS.
It may be due to a new version of Firefox not supported by your current Slimer version. You have two options:
New Tests can be added to the Persistence or CoreTests files found here.
The Persistence tests can only be executed with the persistence bundle on. These tests make sure that the functionality for persisting projects/experiments works.
The Core tests don’t need the persistence bundle. These tests are for general Geppetto functionality including: UI performance, widgets, React components, camera controls and default Geppetto projects.
New tests must be encapsulated in casper functions like this:
casper.then(function(){
//test code
});
Only casper function calls can be made from here. To learn more about the tests calls that can be made from here check out the CasperJS Test API documentation
Calls to Geppetto code or JQuery must be encapsulated inside a casper evaluate function:
casper.then(function(){
var value = casper.evaluate(function() {
//Geppetto Code or JQuery
});
//test code
});
The evaluate function returns a value, which can be used later for testing. Example:
casper.then(function(){
var expectedVisibility = true;
var visibility = casper.evaluate(function() {
return Canvas1.engine.getRealMeshesForInstancePath(variableName)[0].visible;
}, variableName);
test.assertEquals(visibility,expectedVisibility,"Visibility correct");
});
In here we are testing the visibility of a 3D Mesh inside Geppetto. The call to Geppetto objects and functions is done inside the evaluate method, which returns a boolean with the visibility of the mesh. The return value is then used to test against the expected state.
--engine=slimerjs
)