Closed kood1 closed 10 years ago
I figured out how to run the tests in Karma using Jasmine! At high-level:
Choose 'jasmine' for your framework inside karma config
frameworks: ['jasmine']
Create a file with html fixture simply containing one iframe (e.g. jasmine.html)
<iframe id="app" style="width:100%; height:800px; border:0;" src=""></iframe>
Include above file in karma config via html2js preprocessor
preprocessors: { '**/*.html': ['html2js'] }
In karma config, set proxy: "/" to the URL of msl-server (e.g. "http://localhost:8001")
proxies: { '/' : 'http://localhost:8001' }
In karma config, change urlRoot config to something other than "/"
urlRoot: '/root'
In beforeEach() of your Jasmine spec, include:
document.body.innerHTML = __html__['jasmine.html']; ('#app').attr('src','/approot/yourapp.html');
You need to have msl-server running before running karma tests. You also need to use the port number specified in your karma config as your port number when calling msl-client APIs.
Similar approach can be followed for Mocha tests as well.
I will write a wiki page or create documentation on github io page soon.
The plugin should essentially need to do the following:
We should also create a light library which drives iframe through jQuery:
Finished the basic POC for karma plugin, it contains the following feature:
Thanks @ransha. Let's plan to push out alpha version of karma-msl plugin to npm next week.
The light library driving iframe should be part of msl-client-browser library
@ransha, @bryantrobbins, @JacobSheppard - just to be clear, we did decide that we will create a separate msl-runner library instead of adding to msl-client-browser for the basic functions like openApp(), triggerEvent() and get iframe, right?
@ransha, @bryantrobbins, @JacobSheppard - browser-helper.js? iframe-helper.js? iframe-driver.js?
Reference #35 for the app container driver library
Made a PR to cdnjs - https://github.com/cdnjs/cdnjs/pull/3912
Updated msl-client-browser example on getting started doc with version 1.0.2. This is using the appcontainer-driver.js.
BTW, we need to use karma-jasmine 2.0
Updated msl-client-browser to 1.0.3 to include https://github.com/FINRAOS/MSL/issues/37
@ransha, we should include both https://github.com/FINRAOS/MSL/blob/master/msl-client-browser/mockapi-browser.min.js and https://github.com/FINRAOS/MSL/blob/master/msl-client-browser/appcontainer-driver.min.js as part of the plugin.
Package published on npm - https://www.npmjs.org/package/karma-msl
Code published here - https://github.com/FINRAOS/karma-msl
Create a plugin for karma to run as a framework. With the plugin added to the karma config, msl-server should start automatically before executing the tests (jasmine, mocha, etc). In addition, the HTML fixture containing an iframe (to load the app running on the msl-server) should be added automatically to the runner HTML page before executing the tests.
Karma - https://github.com/karma-runner/karma