This is the first blog in a series of two blogs about Karma testing (with code coverage) for Oracle JET. This first blog will help you with setting up the files in the project to get karma up and running. The second blog can be found here and will show you how to actually test your code in the viewModels.
Start a new project.
First we start our new Oracle JET project following the example on the Oracle JET website.
Now check if your project is working by running:
Next step is to add all the npm modules for karma, jasmine and supporting coverage reports.
Add a directory named test, this is where the testfiles will be. Add a file named test-main.js in the directory and leave it empty for now.
Go back to the main directory of your project. Next step is to make the configurations for karma, I do this using
The framework we are using is Jasmine, we do need the Require.js plugin so answer yes for that question. I use Chrome as a browser but you can pick whatever browser you like. All the other questions I left empty or answered with “no”.
Open the karma.conf.js and add the libraries, viewModel, testfiles and the test-main file to files. Read the complete article here.
For regular information become a member in the WebLogic Partner Community please visit: http://www.oracle.com/partners/goto/wls-emea ( OPN account required). If you need support with your account please contact the Oracle Partner Business Center.