I've set up CodeceptJS for a project and use it to test various end-to-end scenarios.
Now I want to extend the tests-suite to also run unit-tests to verify functionality of custom JS functions.
For example: I have a global object App
that has a version
attribute. As a first test, I want to confirm that App.version
is present and has a value.
My first attempt is a test.js file with the following code:
Feature('Unit Tests');
Scenario('Test App presence', ({ I }) => {
I.amOnPage('/');
I.executeScript(function() {return App.version})
.then(function(value) { I.say(value) } );
});
Problems with this code
- The major issue: How can I assert that the
App.version
is present?
My script can display the value but does not fail if it's missing - My code is very complex for such a simple test.
I'm sure there's a cleaner/faster way to perform that test, right?