You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I say it is a bogus syntax error because when I run my test using the 'clean jasmine bdd' maven command, my test pass when I open up the browser. However, when I run my test using the 'clean test' maven command, my test fails with the following error message below. So I wonder why it work using bdd via the web browser and not from the command line. Please confirm bug. Thank you.
Here is the code I am testing...
Tester.js file:
function Tester(){
this.getInstance = function(classRef){
// get the functions as a string
var classAsString = classRef.toString();
// To expose the private functions, we create
// a new function that goes trough the functions string
// we could have done all string parsing in this class and
// only associate the functions directly with string
// manipulation here and not inside the new class,
// but then we would have to expose the functions as string
// in the code, which could lead to problems in the eval since
// string might have semicolons, line breaks etc.
var funcString = "";
funcString += "new (";
funcString += classAsString.substring(0, classAsString.length - 3);
funcString += ";\n\tthis._privates = {};\n";
funcString += "\tthis._initPrivates = function(f){\n";
funcString += "\t\tvar fs = f.toString();\n";
funcString += "\t\tvar pf = fs.match(/function\\s*?(\\w.*?)\\(/g);\n";
funcString += "\t\tthis._privates = {};\n";
funcString += "\t\tfor (var i = 0, ii = pf.length; i < ii; i++){\n";
funcString += "\t\t\tvar fn = pf[i].replace(/function\\s+/, '').replace('(', '');\n";
funcString += "\t\t\tif('"+classRef.name+"' != fn){\n";
funcString += "\t\t\t\tthis._privates[fn] = eval(fn);\n";
funcString += "\t\t\t}\n";
funcString += "\t\t}\n";
funcString += "\t\tpf = fs.match(/var\\s*\\w.*?\\s+/g);\n";
funcString += "\t\tfor(var i = 0, ii = pf.length; i < ii; i++){\n";
funcString += "\t\t\tvar fn = pf[i].replace(/var\\s*/, '').replace(' ', '');\n";
funcString += "\t\t\t\tthis._privates[fn] = eval(fn);\n";
funcString += "\t\t}\n";
funcString += "\t};\n";
funcString += "})();";
var instance = eval(funcString);
instance._initPrivates(classAsString);
// delete the initiation functions
delete instance._initPrivates;
return instance;
};
};
function TestClass(){
this.getName = function(){
return "TestClass";
};
this.getName2 = function(){
return "TestClass";
};
var getType = function(){
return "JavaScript";
};
function doTest(){
return "doing test";
};
};
TesterSpec.js file:
describe("Tester", function(){
it('should be able to call private methods', function () {
var tester = (new Tester()).getInstance(TestClass);
expect(tester).toBeDefined();
expect(tester._privates).toBeDefined();
expect(tester._privates["doTest"]).toBeDefined();
expect(tester._privates.doTest()).toEqual("doing test");
expect(tester._privates["getType"]).toBeDefined();
expect(tester._privates.getType()).toEqual("JavaScript");
});
});
And finally, here is the error message:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.594s
[INFO] Finished at: Tue Apr 10 22:52:09 CDT 2012
[INFO] Final Memory: 14M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.searls:jasmine-maven-plugin:1.1.0:test (default) on project my-calendar-gui: The jasmine-maven-plugin encountered an exception:
[ERROR] java.lang.RuntimeException: org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: SyntaxError: syntax error (file:/Users/pouncilt/git/projects/my-calendar-gui/target/jasmine/spec/Tester.js#38(eval)#31)
[ERROR] Build info: version: '2.11.0', revision: '14435', time: '2011-10-28 18:01:56'
[ERROR] System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8', java.version: '1.6.0_31'
[ERROR] Driver info: driver.version: HtmlUnitDriver
[ERROR] at com.github.searls.jasmine.runner.SpecRunnerExecutor.execute(SpecRunnerExecutor.java:40)
[ERROR] at com.github.searls.jasmine.TestMojo.executeSpecs(TestMojo.java:57)
[ERROR] at com.github.searls.jasmine.TestMojo.run(TestMojo.java:35)
[ERROR] at com.github.searls.jasmine.AbstractJasmineMojo.execute(AbstractJasmineMojo.java:233)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR] Caused by: org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: SyntaxError: syntax error (file:/Users/pouncilt/git/projects/my-calendar-gui/target/jasmine/spec/Tester.js#38(eval)#31)
[ERROR] Build info: version: '2.11.0', revision: '14435', time: '2011-10-28 18:01:56'
[ERROR] System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8', java.version: '1.6.0_31'
The text was updated successfully, but these errors were encountered:
@pouncilt I'm sure this is just due to one of the many deficiencies of HtmlUnit. If you still have this issue try upgrading to the lastest version of the plugin which uses a newer version of HtmlUnit and if all else fails try using PhantomJS instead of HtmlUnit.
I say it is a bogus syntax error because when I run my test using the 'clean jasmine bdd' maven command, my test pass when I open up the browser. However, when I run my test using the 'clean test' maven command, my test fails with the following error message below. So I wonder why it work using bdd via the web browser and not from the command line. Please confirm bug. Thank you.
Here is the code I am testing...
Tester.js file:
function Tester(){
this.getInstance = function(classRef){
// get the functions as a string
var classAsString = classRef.toString();
};
function TestClass(){
this.getName = function(){
return "TestClass";
};
};
TesterSpec.js file:
describe("Tester", function(){
it('should be able to call private methods', function () {
var tester = (new Tester()).getInstance(TestClass);
expect(tester).toBeDefined();
expect(tester._privates).toBeDefined();
expect(tester._privates["doTest"]).toBeDefined();
expect(tester._privates.doTest()).toEqual("doing test");
expect(tester._privates["getType"]).toBeDefined();
expect(tester._privates.getType()).toEqual("JavaScript");
});
});
And finally, here is the error message:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.594s
[INFO] Finished at: Tue Apr 10 22:52:09 CDT 2012
[INFO] Final Memory: 14M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.searls:jasmine-maven-plugin:1.1.0:test (default) on project my-calendar-gui: The jasmine-maven-plugin encountered an exception:
[ERROR] java.lang.RuntimeException: org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: SyntaxError: syntax error (file:/Users/pouncilt/git/projects/my-calendar-gui/target/jasmine/spec/Tester.js#38(eval)#31)
[ERROR] Build info: version: '2.11.0', revision: '14435', time: '2011-10-28 18:01:56'
[ERROR] System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8', java.version: '1.6.0_31'
[ERROR] Driver info: driver.version: HtmlUnitDriver
[ERROR] at com.github.searls.jasmine.runner.SpecRunnerExecutor.execute(SpecRunnerExecutor.java:40)
[ERROR] at com.github.searls.jasmine.TestMojo.executeSpecs(TestMojo.java:57)
[ERROR] at com.github.searls.jasmine.TestMojo.run(TestMojo.java:35)
[ERROR] at com.github.searls.jasmine.AbstractJasmineMojo.execute(AbstractJasmineMojo.java:233)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[ERROR] Caused by: org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: SyntaxError: syntax error (file:/Users/pouncilt/git/projects/my-calendar-gui/target/jasmine/spec/Tester.js#38(eval)#31)
[ERROR] Build info: version: '2.11.0', revision: '14435', time: '2011-10-28 18:01:56'
[ERROR] System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8', java.version: '1.6.0_31'
The text was updated successfully, but these errors were encountered: