Coder Social home page Coder Social logo

Comments (14)

occasl avatar occasl commented on July 24, 2024

On second thought, I'll just keep my specs in the default directory (that works).

That, however, leads to a different issue. The plugin is not picking up my vendor libs that I need bootstrapped (e.g., ExtJS). So I have this in the configuration for the plugin:

          <configuration>
                <!--<jsTestSrcDir>${basedir}/src/main/webapp/spec</jsTestSrcDir>-->
                <jsSrcDir>${basedir}/src/main/webapp</jsSrcDir>
                <sourceIncludes>
                    <include>src/main/webapp/lib/extjs4/**/*.js</include>
                    <include>src/main/webapp/app/**/*.js</include>
                </sourceIncludes>
                <!--<specIncludes>
                    <include>${basedir}/src/main/webapp/spec/**/*.js</include>
                </specIncludes>-->                    
            </configuration>

But then I see this in the output:

 J A S M I N E   S P E C S
-------------------------------------------------------
[INFO] 
Jasmine Check
  Check Ext <<< FAILURE!
    * ReferenceError: "Ext" is not defined. in file:/C:/dev/QES/ponderosa-ui/UiView/ponderosa-ui/target/jasmine/spec/JasmineExtSpec.js (line 3)

Jasmine Check
  Check Ext4 Exists <<< FAILURE!
    * ReferenceError: "Ext" is not defined. in file:/C:/dev/QES/ponderosa-ui/UiView/ponderosa-ui/target/jasmine/spec/spec/JasmineExtSpec.js (line 3)

2 failures:

  1.) Jasmine Check it Check Ext <<< FAILURE!
    * ReferenceError: "Ext" is not defined. in file:/C:/dev/QES/ponderosa-ui/UiView/ponderosa-ui/target/jasmine/spec/JasmineExtSpec.js (line 3)

  2.) Jasmine Check it Check Ext4 Exists <<< FAILURE!
    * ReferenceError: "Ext" is not defined. in file:/C:/dev/QES/ponderosa-ui/UiView/ponderosa-ui/target/jasmine/spec/spec/JasmineExtSpec.js (line 3)

Results: 2 specs, 2 failures

Thoughts?

from jasmine-maven-plugin.

dfreeman avatar dfreeman commented on July 24, 2024

Everything inside sourceIncludes is relative to jsSrcDir, so it's going to be looking for ${basedir}/src/main/webapp/src/main/webapp/... the way you have it configured now. The same is true for specs.

Additionally, if you're using ExtJS in your tests, you'll want to modify the default runner template so that the tests execute from Ext.onReady(), otherwise you're likely to run into some odd bugs (some of which you may see anyway, just because of exactly when the various different portions of a Jasmine spec get executed)

from jasmine-maven-plugin.

occasl avatar occasl commented on July 24, 2024

Ok, thanks that resolves the issue.

from jasmine-maven-plugin.

occasl avatar occasl commented on July 24, 2024

I've seemed to run into another issue when I actually start testing the codebase. I decided to reproduce this using the ExtJS simple project. This only happens with the plugin as I can run the tests as expected when running in a browser. Here's the error:

1.) Users it should have users <<< FAILURE!
    * TypeError: Cannot call method "getController" of null in file:/C:/apps/apache-tomcat-7.0.14/webapps/simple/target/jasmine/spec/specs/users.js (line 6)
    * TypeError: Cannot call method "getCount" of null in file:/C:/apps/apache-tomcat-7.0.14/webapps/simple/target/jasmine/spec/specs/users.js (line 23)

  2.) Users it should open the editor window <<< FAILURE!
    * TypeError: Cannot call method "getController" of null in file:/C:/apps/apache-tomcat-7.0.14/webapps/simple/target/jasmine/spec/specs/users.js (line 6)
    * TypeError: Cannot call method "editUser" of null in file:/C:/apps/apache-tomcat-7.0.14/webapps/simple/target/jasmine/spec/specs/users.js (line 29)

Here is how I have things configured:

<configuration>
    <srcDirectoryName>/</srcDirectoryName>
    <jsSrcDir>${basedir}</jsSrcDir>
    <sourceIncludes>
    <include>extjs4/**/*.js</include>
        <include>app-test.js</include>
    <include>app/**/*.js</include>
    </sourceIncludes>
    <jsTestSrcDir>${basedir}/app-test</jsTestSrcDir>
    <specIncludes>
        <include>specs/**/*.js</include>
    </specIncludes>
    <specRunnerHtmlFileName>run-tests.html</specRunnerHtmlFileName>
</configuration>

Debug output:

[DEBUG]   (f) browserVersion = FIREFOX_3
[DEBUG]   (f) debug = false
[DEBUG]   (f) format = documentation
[DEBUG]   (f) haltOnFailure = true
[DEBUG]   (f) jasmineTargetDir = C:\apps\apache-tomcat-7.0.14\webapps\simple\target\jasmine
[DEBUG]   (f) jsSrcDir = C:\apps\apache-tomcat-7.0.14\webapps\simple
[DEBUG]   (f) jsTestSrcDir = C:\apps\apache-tomcat-7.0.14\webapps\simple\app-test
[DEBUG]   (f) junitXmlReportFileName = TEST-jasmine.xml
[DEBUG]   (f) manualSpecRunnerHtmlFileName = ManualSpecRunner.html
[DEBUG]   (f) mavenProject = MavenProject: com.qualcomm.ssat.poc.simple:simple-ui:1.0.0-SNAPSHOT @ C:\apps\apache-tomcat-7.0.14\webapps\simple\pom.xml
[DEBUG]   (f) packageDir = C:\apps\apache-tomcat-7.0.14\webapps\simple\target\simple-ui-1.0.0-SNAPSHOT
[DEBUG]   (f) packageJavaScriptPath = js
[DEBUG]   (f) serverPort = 8234
[DEBUG]   (f) sourceIncludes = [extjs4/**/*.js, app-test.js, app/**/*.js]
[DEBUG]   (f) specDirectoryName = spec
[DEBUG]   (f) specIncludes = [specs/**/*.js]
[DEBUG]   (f) specRunnerHtmlFileName = run-tests.html
[DEBUG]   (f) srcDirectoryName = /
[DEBUG]   (f) timeout = 300
[DEBUG] -- end configuration --

I also created a my own spec runner, run-tests.html, that is as follows:

<head>

    <link rel="stylesheet" type="text/css" href="app-test/lib/jasmine-1.1.0/jasmine.css">

    <script type="text/javascript" src="extjs4/ext-all-debug.js"></script>

    <script type="text/javascript" src="app-test/lib/jasmine-1.1.0/jasmine.js"></script>
    <script type="text/javascript" src="app-test/lib/jasmine-1.1.0/jasmine-html.js"></script>

    <script type="text/javascript" src="app-test/specs/example.js"></script>
    <script type="text/javascript" src="app-test/specs/users.js"></script>

    <script type="text/javascript" src="app-test.js"></script>

</head>

Thanks for your assistance. Additionally, I posted the entire project to my github account https://github.com/occasl/jasmine-simple.

from jasmine-maven-plugin.

searls avatar searls commented on July 24, 2024

Thanks for posting the project, that'll be helpful.

Be warned that others have tried & failed to get ExtJS to work under HtmlUnit. :-/

from jasmine-maven-plugin.

dfreeman avatar dfreeman commented on July 24, 2024

Your custom spec runner isn't being used. Try <customRunnerTemplate>run-tests.html</customRunnerTemplate> instead of that <specRunnerHtmlFileName> entry in your pom.xml.

Your setup appears to have some race conditions; running with the jasmine:bdd goal and just refreshing the page several times, I see two of the tests pass/fail seemingly at random. There may be other issues as well -- Justin is right that HtmlUnit and ExtJS aren't always cooperative with one another on the first go, but it's definitely doable with some trial and error.

from jasmine-maven-plugin.

occasl avatar occasl commented on July 24, 2024

I gave that a try but unfortunately I get this:

Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "reporter" is not defined. (injected script#1)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3772)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3750)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3835)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.name(ScriptRuntime.java:1763)
    at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1781)
    at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:845)
    at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
    at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:429)
    at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:269)
    at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3162)
    at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:490)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:595)
    ... 31 more

from jasmine-maven-plugin.

occasl avatar occasl commented on July 24, 2024

I really gave it an honest effort the last few days, and I can get it to run fairly consistent with jasmine:bdd but I can't get it to run with the Maven plugin which is disappointing. I continue to get the error above. I'm going to look into phantom.js as an alternative.

from jasmine-maven-plugin.

searls avatar searls commented on July 24, 2024

Hi Lou,

I'm sorry to hear about your frustrations. I personally use
jasmine-headless-webkit for almost all of my
day-to-day development, and it works great in CI too. Why don't you give
that a try?

from jasmine-maven-plugin.

mzaks avatar mzaks commented on July 24, 2024

I had the same problem.

I guess it is an Error in HTML-Unit I got this error only each second time and was a little bit confused.
The reporter is the window.reporter defined in html Template.
So it is a JavaScript error which comes up in the Runtime only every second time :)

I could fix it by changing the html template

...
window.reporter = new jasmine.$reporter$();

require(specs, function() {
        jasmine.getEnv().addReporter(window.reporter);
        jasmine.getEnv().execute();
});

As you can see I use RequireJS template.

from jasmine-maven-plugin.

occasl avatar occasl commented on July 24, 2024

Are you using ExtJS too? I tried the window.reporter trick but no dice. My template looks like this to integrate with ExtJS4:

Ext.Loader.setConfig({enabled: true,
        paths: {
            'Ext.ux':'lib/extjs4/ux/',
            'Ponderosa': 'app'
        }
});
Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.grid.PagingScroller',
    'Ext.ux.grid.FiltersFeature',
    'Ext.grid.feature.Grouping',
    'Ext.grid.plugin.CellEditing',
    'Ext.state.CookieProvider'/*,
    'Ext.QuickTips'*/
]);

var Application = null;

window.reporter = new jasmine.TrivialReporter();

Ext.onReady(function() {
    Application = Ext.create('Ext.app.Application', {
        name: 'Ponderosa',

        controllers: [
            'vehicle.VehiclesTabController'
        ],

        launch: function() {
                jasmine.getEnv().addReporter(window.reporter);
                jasmine.getEnv().execute();
        }
    });
});

from jasmine-maven-plugin.

mzaks avatar mzaks commented on July 24, 2024

No I don't use ExtJS I use RequireJS with BackboneJS.

I think the problem is that Rhino which is shipped with HTMLUnit as JavaScript engine, is trying to interpret the JavaScript in parallel so it has not all global variables set.
For example I had to mock up 'console' because it is also sometimes not there.

So the trick would be to try out when he can find the 'reporter' variable without ExtJS- only plain Jasmine. and than experiment a little :)

On the second thought maybe this will help

jasmine.getEnv().addReporter(new jasmine.TrivialReporter());

from jasmine-maven-plugin.

thomasklein avatar thomasklein commented on July 24, 2024

Run into the same issue. What is important for the 'jasmine maven plugin' is the global var 'window.reporter' to be assigned with an jasmine reporter instance. Otherwise you get the above 'ReferenceError: "reporter" is not defined.' error.

from jasmine-maven-plugin.

klieber avatar klieber commented on July 24, 2024

@occasl Not sure if you are even using the plugin anymore since this issue is over a year old but there have been quite a few changes to the plugin recently so I'd ask that you please try out that version. In the meantime, I'm going to close this issue. If you are still experiencing issues with the latest version let me know and I'll reopen the issue.

from jasmine-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.