-
Notifications
You must be signed in to change notification settings - Fork 28
Loader Functional Testing Pattern
Eric Heasley edited this page May 26, 2015
·
1 revision
Write loader tests as functional tests to provide a clean environment in which the loader can operate. Whenever possible use the following pattern for inspecting test results.
Step 1: In the functional test's HTML file, create the global object window.loaderTestResults
and store test result data in that object. For example:
<!DOCTYPE html>
<html>
<body>
<script src="path/to/loader.js"></script>
<script>
// do some testing and then at the end
window.loaderTestResults = {
someTestResults: someData
};
});
</script>
</body>
</html>
Step 2: Create an Intern test case that watches for the loaderTestResults
variable to be set and then evaluates the data it contains.
registerSuite({
'some test case'(): {
return this.remote
.get((<any>require).toUrl('path/to/test.html')
.then(pollUntil(function () {
return (<any>window).loaderTestResults;
}, null, timeout))
.then(function (results: any) {
assert.strictEqual(results.someTestResults, 'expected data');
});
}