I have multiple tests that need to share the same common utilities script. I wouldn't want to place this file in the source folder structure, since it's only relevant for testing.
So my source folder is:
<jsSrcDir>${project.basedir}/src/main/js</jsSrcDir>
and my test source:
<jsTestSrcDir>src/test/js</jsTestSrcDir>
In src/test/js I have a testUtil.js file that I need to load in other jasmine tests. Is it possible to access such files from within a jasmine test?
describe('Load Util Module', function() {
it('check util is loaded', function() {
//load testUtil.js
});
});
This is how I managed to do it:
I added require.js to my specs folder
In the jasmine-maven-plugin configuration I added the REQUIRE_JS spec runner template:
The data file is located in:
having the following content:
The tests to be injected this data object require a define directive: