I've managed to successfully build my maven project which uses the jasmine-maven-plugin to put the source and test javascript files in the right places. When I have a simple test such as:
describe('true', function() {
it('should be true', function() {
expect(true).toBe(true);
})
})
the whole thing builds with no problems, and all the jasmine specs pass. But when I try to create an instance of an object that I've outlined in one of the files that are included target/jasmine/src folder, I get a "ReferenceError: "Stat" is not defined" error.
describe('stat test',function() {
var stat = new Stat();
it('get data',function() {
stat.data = 13;
expect(stat.getData()).toBe(13);
});
});
Are the js files not loading properly? Totally stumped here.
I've managed to successfully build my maven project which uses the jasmine-maven-plugin to put the source and test javascript files in the right places. When I have a simple test such as:
describe('true', function() {
it('should be true', function() {
expect(true).toBe(true);
})
})
the whole thing builds with no problems, and all the jasmine specs pass. But when I try to create an instance of an object that I've outlined in one of the files that are included target/jasmine/src folder, I get a "ReferenceError: "Stat" is not defined" error.
describe('stat test',function() {
var stat = new Stat();
it('get data',function() {
stat.data = 13;
expect(stat.getData()).toBe(13);
});
});
Are the js files not loading properly? Totally stumped here.
Share Improve this question asked Jul 3, 2012 at 20:46 user1429419user1429419 1274 silver badges12 bronze badges2 Answers
Reset to default 4Did you set up in the correct way jasmine? It seems that jasmine can't find your js files, here you have an example of the maven configuration:
<plugin>
<groupId>.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<goals>
<goal> test </goal>
</goals>
</execution>
</executions>
<configuration>
<jsSrcDir> main/www/js </jsSrcDir> <---HERE you define the source directory
<haltOnFailure>false</haltOnFailure>
<sourceIncludes> <---- HERE you specifies which files you include into the test
<include>libs/jquery-1.7.1.js</include>
<include>libs/underscore.js</include>
<include>**/*.js</include>
</sourceIncludes>
<sourceExcludes> <----- HERE you define the files that you exclude
<exclude>jsonresponses-mock.js</exclude>
<exclude>libs/jquery.mockjax.js</exclude>
</sourceExcludes>
<jsTestSrcDir> test/www/fakeJs </jsTestSrcDir> <---Define your Test source Dir
<haltOnFailure>true</haltOnFailure>
<browserVersion>FIREFOX_3</browserVersion>
<serverPort>8234</serverPort>
<specDirectoryName>specs</specDirectoryName>
</configuration>
</plugin>
At the bottom of this page: http://searls.github./jasmine-maven-plugin you have all the possibles tags. Check if you have your pom in the correct way... Hope it can help!!
After much mental strain and not much luck, I just modified the plugin to ignore perceived javascript errors so that everything would pile. Lo and behold, it all worked! Scripts were just being added out of order. For those interested, I added "client.setThrowExceptionOnScriptError(false)" at line #90 in TestMojo.java, so now when the tag is set to false (default), javascript errors are ignored.