Reputation: 345
The following code is never run:
define("model/Contact", function() {
console.log(Contact);
describe('Something',function(){
it('shows no error',function(){
require(["model/MyModel"], function(MyModel) {
console.log(MyModel);
expect(false).toBeTruthy();
});
});
});
});
If i use a define block the code is never run within the jasmine maven plugin: http://searls.github.io/jasmine-maven-plugin/amd-support.html
My Plugin
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.3.1.2</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
<jsSrcDir>${jsFolder}/src</jsSrcDir>
<jsTestSrcDir>${jsTestFolder}/specs</jsTestSrcDir>
<preloadSources>
<source>${jsFolder}/src/extlib/requirejs/require.js</source>
</preloadSources>
</configuration>
</plugin>
Interesting is the following code:
describe('Something',function(){
it('shows no error',function(){
require(["model/MyModel"], function(MyModel) {
console.log(MyModel);
expect(false).toBeTruthy();
});
});
});
If i use this code, MyModel is defined and usable. But the expect() function never throws an error.
What i am doing wrong?
Upvotes: 0
Views: 354
Reputation: 110892
You have to require your module before you start the test:
require(["model/MyModel"], function (MyModel) {
describe('Something', function () {
it('shows no error', function () {
console.log(MyModel);
expect(false).toBeTruthy();
});
});
});
In your example the test runner finished the test before the require callbacks are running.
Upvotes: 2