rails teaspoon Testing in engine Not loading *_spec.js - javascript

i'm working on an engine (gem) that has some js code to be tested but seems i can't get it working. I've followed the wiki article and set a basic example, but i'm only getting 0 examples, 0 failures.
Steps done:
Added s.add_development_dependency 'teaspoon-jasmine' in the gemspec file
dummy is in spec/dummy
spec/teaspoon_env.rb:
unless defined?(Rails)
ENV["RAILS_ROOT"] = File.expand_path("../dummy", __FILE__)
require File.expand_path("#{ENV["RAILS_ROOT"]}/config/environment", __FILE__)
end
Teaspoon.configure do |config|
...
config.root = MyEngineName::Engine.root
...
end
Rakefile:
desc "Run the javascript specs"
task :teaspoon => "app:teaspoon"
spec/javascripts/spec_helper.js (default as it was generated)
spec/javascripts/example_spec.js:
describe("My great feature", function() {
it("Bang", () => {
expect(true).toBe(false);
});
});
The problem is that when i try to run the test engine, i'm getting:
$> teaspoon
Starting the Teaspoon server...
Thin web server (v1.7.0 codename Dunder Mifflin)
Maximum connections set to 1024
Listening on 127.0.0.1:57036, CTRL+C to stop
Teaspoon running default suite at http://127.0.0.1:57036/teaspoon/default
Finished in 0.01600 seconds
0 examples, 0 failures
I've also try to run the following commands, with the same result:
$> bundle exec teaspoon
$> rake teaspoon
$> bundle exec teaspoon spec/javascripts/example_spec.js
And even $> bundle exec teaspoon spec/javascripts/non_existent_file_spec.js
I have not much idea of what is not working. As non standard app, i'm using es6 through browserify-rails (which is working ok), and got in engine.rb:
config.browserify_rails.paths = [
lambda { |p| p.start_with?(MyEngineName::Engine.root.join("app").to_s) }
]
Any help or clue would be much appreciated.
UPDATE:
I've created an engine from strach so it is easy to check and reproduce the issue.
Repo Engine example
In particular, the commit related to the teaspoon setup is this one

It is due to the arrow function in your test. Change it to vanilla JS to make it work:
it("Bang", function() {
expect(true).toBe(false);
});
The browser option works just fine with es6.

Try using a Rake command for the Rakefile
rake spec

Related

Detect Browserify broken build before committing/deploying

I'm using Browserify to bundle up my JS before pushing to my Bitbucket repo, and then using Codeship to test the build and push to Heroku.
I'm using Node/Express to serve my app, and in my index.jade I have a <script /> pointing to /dist/index.js.
A couple of times, I've mistakenly pushed my latest code with broken Browserify output, ie. the contents of /dist/index.js will be:
console.error('cannot find module XYZ')
And I've deployed this to my live app. UH OH.
I've put in a very rudimentary test which gets ran on Codeship which I'm hoping should avoid this in the future:
var exit = function() {
process.exit(1)
}
var success = function() {
process.exit(0)
}
var fs = require('fs')
var index
try {
index = fs.readFileSync(__dirname + '/../public/dist/index.js', 'utf-8')
} catch (e) {
exit()
}
if(!index){
exit()
}
var invalid = index.length < 1000
if(invalid){
return exit()
}
success()
I'm just checking if the file exists, and that the contents of the file is over 1000 characters.
Not sure if there's a specific answer to this, but would be a reasonable approach to making sure broken Browserify output never gets committed/deployed?
I haven't used Codeship before, but I have used other similar services. You haven't described how you push - I'm going to assume you're using git.
With git, this becomes easy: write a pre-push hook that will abort the push if something fails. Here's an example from a project I'm working on:
#!/bin/bash
# the protected branches
#
protected_branches='develop master'
# Check if we actually have commits to push
#
commits=`git log #{u}..`
if [ -z "$commits" ]; then
exit 0
fi
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# is the current branch in the list of protected branchs? if so, then run the
# tests
#
if grep -q "$current_branch" <<< "$protected_branches"; then
# move into the dir containing the tests
#
pushd $(git rev-parse --show-toplevel)/contract >/dev/null
gulp test
RESULT=$?
# back to whatever dir we were in before
#
popd >/dev/null
if [ $RESULT -ne 0 ]; then
echo "-------- Failed Tests"
exit 1
fi
fi
exit 0
This is a modified version of a script I found in this blog post.
Basically, this script checks to see if I'm pushing one of the protected branches and, if so, runs my tests. If those test fail, then the push is aborted.
You could, of course, change the conditions under which the push is aborted. For example, write some code to check & see if your browserify bundle is correct and fail if it's not. You mention checking the length of your bundle - maybe something like length=$(ls -l | cut -c 30-34) and then check the value of length (sorry, I'm not a real bash guru).
The benefit of this approach is that the messed up code never leaves your local machine - you run the test locally and if it fails, the code doesn't get pushed. This is likely to be faster than running in on Codeship's service.

Not very helpful callstack when running a mocha test using selenium webdriverjs

When running a test in mocha using the selenium webdriver for JavaScript the call-stack it not really helpful.
As a simple example I've used the following simple test script test.js:
var webdriver = require('selenium-webdriver'),
test = require('selenium-webdriver/testing');
const TIMEOUT = 30000;
test.describe('selenium webdriverjs', function () {
var driver;
this.timeout(TIMEOUT);
test.before(function () {
driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.firefox()).build();
driver.manage().timeouts().pageLoadTimeout(TIMEOUT);
});
test.after(function () {
driver.quit();
});
test.it('error stack', function () {
driver.get('http://www.google.com');
driver.findElement(webdriver.By.id('doesnotexit'));
});
});
that generates the following error stack when (for example) run from Gulp:
selenium webdriverjs
1) error stack
0 passing (4s)
1 failing
1) selenium webdriverjs error stack:
NoSuchElementError: Unable to locate element: {"method":"id","selector":"doesnotexit"}
at new bot.Error (...\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
at Object.bot.response.checkResponse (...\node_modules\selenium-webdriver\lib\atoms\response.js:109:9)
at ...\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
at promise.Promise.goog.defineClass.invokeCallback_ (.../node_modules/selenium-webdriver/lib/goog/../webdriver/promise.
js:1337:14)
at promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_.execute_ (.../node_modules/selenium-
webdriver/lib/goog/../webdriver/promise.js:2776:14)
at promise.ControlFlow.goog.defineClass.goog.defineClass.abort_.error.executeNext_ (.../node_modules/selenium-webdriver
/lib/goog/../webdriver/promise.js:2758:21)
at goog.async.run.processWorkQueue (...\node_modules\selenium-webdriver\lib\goog\async\run.js:124:15)
From: Task: selenium webdriverjs error stack
at Context.ret (...\node_modules\selenium-webdriver\testing\index.js:128:10)
at callFnAsync (...\node_modules\mocha\lib\runnable.js:306:8)
at Test.Runnable.run (...\node_modules\mocha\lib\runnable.js:261:7)
at Runner.runTest (...\node_modules\mocha\lib\runner.js:421:10)
at ...\node_modules\mocha\lib\runner.js:528:12
at next (...\node_modules\mocha\lib\runner.js:341:14)
at ...\node_modules\mocha\lib\runner.js:351:7
at next (...\node_modules\mocha\lib\runner.js:283:14)
at Immediate._onImmediate (...\node_modules\mocha\lib\runner.js:319:5)
The stack consists of a series of deeply nested function in the mocha and selenium libraries of the local node_modules directory and actual test script test.js is not even part of the stack.
I'm wondering, if this is really the best information I can get from this setup if I just did something wrong?
Yes, this is really too much unnecessary and not really helpful information with all of the meaningless async traceback cruft, but the most important part of it, the webdriver error itself, is on top and is pretty self-descriptive:
NoSuchElementError: Unable to locate element:
{"method":"id","selector":"doesnotexit"}
You may try to clean up the output with the help of mocha-clean package. When applied, it should really leave the error message itself and only relevant parts of the stack trace eliminating everything mocha- and selenium-webdriver-specific:
Mocha stack traces are riddled with frames that you don't want to see,
like code from modules and Mocha internals. It strips away mocha
internals, node_modules, absolute paths (based on cwd), and other
unneccessary cruft.

How to run node js application programmatically using forever

I need to run the set of node js files which contains the configuration information where It has to run typically port number and IP address then using the forever in node.js I need to run the script in the terminal with the configuration without having any manual input.
For Programmatic approach , you can use Forever-Moniter
var forever = require('forever-monitor');
var child = new (forever.Monitor)('your-filename.js', {
max: 3,
silent: true,
options: []
});
child.on('exit', function () {
console.log('your-filename.js has exited after 3 restarts');
});
child.start();
You could make use of the child_process module. Check the doc, there're some useful information there: http://nodejs.org/api/child_process.html
To give a brief example
var exec = require('child_process').exec;
exec('forever', function callback(error, stdout, stderr){
// cb
});
If you don't need a callback / don't want to wait for the execution:
var exec = require('child_process').exec('forever').unref();
Was that helpful?
Best
Marc
Edit: Ok, not sure if I really got the point of your question, but my answer combined with https://stackoverflow.com/a/23871739/823851 might offer a good solution.
Usage:
forever start hello.js to start a process.
forever list to see list of all processes started by forever
forever stop hello.js to stop the process, or forever stop 0 to stop the process with index 0 (as shown by forever list).
node-config is a good module for managing different configurations of a Node.js app.
For example, to make a "production" config, /config/production.json would contain:
{
"port" : "3000",
"ip" : "192.168.1.1"
}
In one of your node application JS files:
config = require('config')
....
var port = config.port;
var ip = config.ip;
And to launch the app in this configuration, just first set your NODE_ENV to production from the shell before running your app.
export NODE_ENV=production
forever start app.js
Make additional config JSON files as needed for each of your environments. default.json is used when no environment is specified.

Hide 'Running X task' in grunt

I have been working on a project setup and deploy Gruntfile but would like to hide the command line output so that the following:
Running "init" task
Running "prompt:init" (prompt) task
[?] If you continue your project information will be overwritten.
Continue? (Y/n)
becomes
[?] If you continue your project information will be overwritten.
Continue? (Y/n)
when running grunt. I know it's only cosmetic but it's something I would like to do and cannot seem to find anything on Grunt's API documentation to indicate this can be done.
This is currently not supported, but possible thanks to the following workaround (from shama on GitHub):
grunt.log.header = function () {};
Basically, this overrides the log header function (which is responsible for the "running x task" message) by an empty function that does nothing, and more importantly, outputs nothing.
There's another way to do it:
First, run npm install grunt-log-headers to install grunt-log-headers.
Then add require('grunt-log-headers')(grunt); to your Gruntfile.js to enable it.
Finally, add this to any task for which you want to hide the log header:
options: {
gruntLogHeader: false
}
Example:
grunt.initConfig({
sometask: {
options: {
gruntLogHeader: false,
}
}
});
In fact, an issue has already been created for this. It's currently being worked on, and will normally be available in the version 0.5.0.

Geb Tests for pages with javascript in grails 2.3.5

I am upgrading from grails 2.2.4 to grails 2.3.5 and the last problem I am having is with geb functional tests. I have upgraded geb to 0.9.2.
The first problem is that it seems like it is first trying to run the geb tests as spock tests even though there aren't any geb spock tests, before running as a regular geb test.
The second problem is that in both cases when javascript is enabled, i.e.
in GebConfig.groovy
driver = {
def driver = new HtmlUnitDriver()
driver.javascriptEnabled = true
return driver
}
I get the following exception :
| ======= EXCEPTION START ========
Exception class=[net.sourceforge.htmlunit.corejs.javascript.EvaluatorException]
com.gargoylesoftware.htmlunit.ScriptException: syntax error (http://localhost:8081/xyz/static/IKfETRJERwBRdVMGxGDGgTIvzB2B464w7472lQKpd3b.js#156)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:684)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:524)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1144)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:1039)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:409)
at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute(HtmlScript.java:266)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:286)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:683)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:642)
at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1170)
at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1072)
at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)
at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:330)
at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3116)
at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2083)
at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:918)
at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)
at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:899)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:242)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:188)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:156)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:437)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:393)
at com.gargoylesoftware.htmlunit.html.HtmlPage.refresh(HtmlPage.java:2234)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitNavigation.refresh(HtmlUnitDriver.java:1282)
at geb.Browser.go(Browser.groovy:395)
at geb.Page.to(Page.groovy:184)
at geb.Browser.via(Browser.groovy:475)
at geb.Browser.to(Browser.groovy:434)
at geb.Browser.to(Browser.groovy:412)
at geb.junit4.GebTest.methodMissing(GebTest.groovy:52)
......
Caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: syntax error (http://localhost:8081/xyz/static/IKfETRJERwBRdVMGxGDGgTIvzB2B464w7472lQKpd3b.js#156)
at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.error(StrictErrorReporter.java:64)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:187)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:167)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:219)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:214)
at net.sourceforge.htmlunit.corejs.javascript.Parser.mustMatchToken(Parser.java:366)
at net.sourceforge.htmlunit.corejs.javascript.Parser.mustMatchToken(Parser.java:357)
at net.sourceforge.htmlunit.corejs.javascript.Parser.xmlInitializer(Parser.java:2292)
at net.sourceforge.htmlunit.corejs.javascript.Parser.unaryExpr(Parser.java:2252)
at net.sourceforge.htmlunit.corejs.javascript.Parser.mulExpr(Parser.java:2184)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addExpr(Parser.java:2170)
at net.sourceforge.htmlunit.corejs.javascript.Parser.shiftExpr(Parser.java:2153)
at net.sourceforge.htmlunit.corejs.javascript.Parser.relExpr(Parser.java:2130)
at net.sourceforge.htmlunit.corejs.javascript.Parser.eqExpr(Parser.java:2104)
at net.sourceforge.htmlunit.corejs.javascript.Parser.bitAndExpr(Parser.java:2095)
at net.sourceforge.htmlunit.corejs.javascript.Parser.bitXorExpr(Parser.java:2086)
at net.sourceforge.htmlunit.corejs.javascript.Parser.bitOrExpr(Parser.java:2077)
at net.sourceforge.htmlunit.corejs.javascript.Parser.andExpr(Parser.java:2068)
at net.sourceforge.htmlunit.corejs.javascript.Parser.orExpr(Parser.java:2059)
at net.sourceforge.htmlunit.corejs.javascript.Parser.condExpr(Parser.java:2025)
at net.sourceforge.htmlunit.corejs.javascript.Parser.assignExpr(Parser.java:1998)
at net.sourceforge.htmlunit.corejs.javascript.Parser.expr(Parser.java:1979)
at net.sourceforge.htmlunit.corejs.javascript.Parser.statementHelper(Parser.java:1025)
at net.sourceforge.htmlunit.corejs.javascript.Parser.statement(Parser.java:891)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:535)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:456)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileImpl(Context.java:2496)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1456)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext.compileString(HtmlUnitContextFactory.java:201)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1448)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:515)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:669)
... 38 more
Enclosed exception:
net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: syntax error (http://localhost:8081/xyz/static/IKfETRJERwBRdVMGxGDGgTIvzB2B464w7472lQKpd3b.js#156)
at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.error(StrictErrorReporter.java:64)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:187)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:167)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:219)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:214)
at net.sourceforge.htmlunit.corejs.javascript.Parser.mustMatchToken(Parser.java:366)
at net.sourceforge.htmlunit.corejs.javascript.Parser.mustMatchToken(Parser.java:357)
at net.sourceforge.htmlunit.corejs.javascript.Parser.xmlInitializer(Parser.java:2292)
at net.sourceforge.htmlunit.corejs.javascript.Parser.unaryExpr(Parser.java:2252)
at net.sourceforge.htmlunit.corejs.javascript.Parser.mulExpr(Parser.java:2184)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addExpr(Parser.java:2170)
at net.sourceforge.htmlunit.corejs.javascript.Parser.shiftExpr(Parser.java:2153)
at net.sourceforge.htmlunit.corejs.javascript.Parser.relExpr(Parser.java:2130)
at net.sourceforge.htmlunit.corejs.javascript.Parser.eqExpr(Parser.java:2104)
at net.sourceforge.htmlunit.corejs.javascript.Parser.bitAndExpr(Parser.java:2095)
at net.sourceforge.htmlunit.corejs.javascript.Parser.bitXorExpr(Parser.java:2086)
at net.sourceforge.htmlunit.corejs.javascript.Parser.bitOrExpr(Parser.java:2077)
at net.sourceforge.htmlunit.corejs.javascript.Parser.andExpr(Parser.java:2068)
at net.sourceforge.htmlunit.corejs.javascript.Parser.orExpr(Parser.java:2059)
at net.sourceforge.htmlunit.corejs.javascript.Parser.condExpr(Parser.java:2025)
at net.sourceforge.htmlunit.corejs.javascript.Parser.assignExpr(Parser.java:1998)
at net.sourceforge.htmlunit.corejs.javascript.Parser.expr(Parser.java:1979)
at net.sourceforge.htmlunit.corejs.javascript.Parser.statementHelper(Parser.java:1025)
at net.sourceforge.htmlunit.corejs.javascript.Parser.statement(Parser.java:891)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:535)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:456)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileImpl(Context.java:2496)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1456)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext.compileString(HtmlUnitContextFactory.java:201)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1448)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:515)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:669)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:524)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1144)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:1039)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:409)
at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute(HtmlScript.java:266)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:286)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:683)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:642)
at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1170)
at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1072)
at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)
at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:330)
at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3116)
at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2083)
at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:918)
at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)
at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:899)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:242)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:188)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:156)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:437)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:393)
at com.gargoylesoftware.htmlunit.html.HtmlPage.refresh(HtmlPage.java:2234)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitNavigation.refresh(HtmlUnitDriver.java:1282)
at geb.Browser.go(Browser.groovy:395)
at geb.Page.to(Page.groovy:184)
at geb.Browser.via(Browser.groovy:475)
at geb.Browser.to(Browser.groovy:434)
at geb.Browser.to(Browser.groovy:412)
at geb.junit4.GebTest.methodMissing(GebTest.groovy:52)
.....
When javascript is not enabled, the tests for pages without javascript pass but tests for pages with javascript get the following:
java.lang.UnsupportedOperationException: Javascript is not enabled for this HtmlUnitDriver instance
at org.openqa.selenium.htmlunit.HtmlUnitDriver.getPageToInjectScriptInto(HtmlUnitDriver.java:639)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.executeScript(HtmlUnitDriver.java:590)
at geb.js.JavascriptInterface._execjs(JavascriptInterface.groovy:41)
at geb.js.JavascriptInterface.exec(JavascriptInterface.groovy:71)
at geb.js.JQueryAdapter._callJQueryMethod(JQueryAdapter.groovy:33)
at geb.js.JQueryAdapter.methodMissing(JQueryAdapter.groovy:60)
at com.sra.ridge.geb.page.RidgePage.populateSecurityQuestions(RidgePage.groovy:95)
at geb.Browser.methodMissing(Browser.groovy:194)
Any suggestions for how to handle these issues? These tests passed when using grails 2.2.3 and geb 0.9.0-RC-1
The syntax error was apparently due to the hashing of javascript files by the resource plugin and setting
grails.resources.mappers.hashandcache.excludes = ['*/']
in the test environment in Config.groovy fixed the issue of the exception.
Using geb 0.9.0-RC1 fixed the issue of the tests running twice. It is unfortunate that we can't upgrade to 0.9.2 of geb.

Categories

Resources