Javascript jasmine没有从';src&x27;目录

Javascript jasmine没有从';src&x27;目录,javascript,maven,jasmine,Javascript,Maven,Jasmine,我已经成功地构建了我的maven项目,它使用将源代码和测试javascript文件放在正确的位置。当我有一个简单的测试,例如: describe('true', function() { it('should be true', function() { expect(true).toBe(true); }) }) 整个东西构建没有问题,所有茉莉花规格都通过了。但是,当我尝试创建我在target/jasmine/src文件夹中包含的一个文件中概述的对象的实例时,

我已经成功地构建了我的maven项目,它使用将源代码和测试javascript文件放在正确的位置。当我有一个简单的测试,例如:

describe('true', function() {
    it('should be true', function() {
        expect(true).toBe(true);
    })
})
整个东西构建没有问题,所有茉莉花规格都通过了。但是,当我尝试创建我在target/jasmine/src文件夹中包含的一个文件中概述的对象的实例时,我得到一个“ReferenceError:”Stat“is not defined”错误


js文件是否加载不正确?这里完全被难住了。

你用正确的方法建立了茉莉花吗?jasmine似乎找不到您的js文件,这里有一个maven配置示例:

<plugin>
        <groupId>com.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>

com.github.searls
你有所有可能的标签。

检查你的pom是否正确。。。希望能有帮助

在精神紧张和运气不佳的情况下,我只是修改了插件以忽略感知到的javascript错误,这样一切都可以编译。瞧,一切都成功了!脚本刚刚被无序添加。对于那些感兴趣的人,我在TestMojo.java的第90行添加了“client.setThroweExceptionOnScriptorror(false)”,因此现在当标记设置为false(默认值)时,javascript错误将被忽略

是的,我的pom.xml看起来就像这样,只是我省略了jsTestSrcDir标记,因为它默认为src/test/javascript,我的测试在这里。当我运行'maven install'时,我会在'target/jasmine/src'文件夹中获得所有正确的js文件,它们应该在那里。但是,由于某些原因,它们没有从这里加载。您是否尝试使用require?例如:var Blog=require('../MyClass').MyClass;在你描述的最上面。在这个链接中你有一个例子:是的,我也试过这个。我得到“ReferenceError:“require”未定义。还有其他想法吗?谢谢你的帮助,这已经让我发疯好几天了!源代码包含的文件的顺序很重要,首先放在库中,然后放在Stat对象的路径(从jsSrcDir)中。啊!我明白了。源包含的根目录在前面定义的中。现在看来很明显我已经解决了。
<plugin>
        <groupId>com.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>