gruntjs / grunt-contrib-qunit Goto Github PK
View Code? Open in Web Editor NEWRun QUnit tests in Headless Chrome.
License: MIT License
Run QUnit tests in Headless Chrome.
License: MIT License
0.4.0 throws up on Travis with Fatal error: spawn ENOENT�
.
Had to downgrade to 0.3.0 to get it going again for AssetManager JS.
See the failed build log.
hi all, I need your help!
grunt qunit
Running "qunit:all" (qunit) task
Testing tests/test.html Fglobal failure
Message: ReferenceError: Can't find variable: seajs
file:///E:/workspace/webstorm/tui.pek/tuijs/tests/test.html:20
Warning: 1/1 assertions failed (20ms) Use --force to continue.
Aborted due to warnings.
test.html like this:
<title>Tuijs Unit Test</title><script src="qunit/qunit-1.14.0.js"></script>
<script src="../dist/sea-2.1.1.js"></script>
<script src="../dist/tui.config.js"></script>
<script>
(function(){
seajs.use(['tuiInit'], function(){
$.extend(seajs.data.alias, {testInit: '../tests/test.Init.js'});
});
seajs.use(['testInit'], function(){});
})();
</script>
Apologies in advance if this issue belongs under a different repo.
If I run npm install grunt-contrib-qunit on a mac, commit that repository, and then pull the same thing down on windows, 'grunt qunit' does not work, complaining about phantomjs not being installed locally.
That's to be expected because the phantomjs package checks for the current platform and pulls down the necessary binaries.
However, if I then run npm install grunt-contrib-qunit on the windows machine, the macosx phantomjs files are removed and replaced with the windows ones. Seeing as we have to install grunt locally as of 0.4.0, I need to be able to put both sets of binaries in our repo so that we can work on both platforms.
Previously, we just installed grunt/qunit/phantom globally per machine and that fixed it. Now, I'm looking at somehow trying to drop the right binaries in manually and update the shell scripts/BAT files to make it work. And that will probably blow up if anybody tries to update the package.
Thoughts? I'm hoping I'm just missing something obvious.
I am contributing PR's for https://github.com/kmiyashiro/grunt-mocha and trying to make documentation / behavior close as possible to grunt-contrib-qunit.
Every time my tests fail, the PhantomJS processes stick around, giving my laptop something like this:
But it's clean as a whistle if the tests pass.
It could be related to this issue in grunt-lib-phantomjs:
However, I tried using the latest version 7b87a48995ff3d905f4d01e4fc247fdb95d93b8d, but that didn't fix the problem either.
Please get this fixed. This problem renders the plugin unusable.
Fyi, I'm on a Mac w/ Mavericks, if that helps.
I really like the idea of the httpBase
option, but I believe that it can be quite misleading and cause some confusion.
My initial expectation was that setting the httpBase
option to http://localhost:8000
(for example) would result in all the strings (not only found files) in the src
option to be appended with this string and passed on to the PhantomJS browser.
I thought that the following would provide the http://localhost:8000/test.html
to the browser if the test.html
was located in the www
directory:
connect: {
server: {
options: {
base: 'www'
}
}
},
qunit: {
main: {
options: {
httpBase: 'http://localhost:8000/'
},
src: ['test.html']
}
}
The previous example does not pass on any tests to the browser.
The only way this option can be useful is if the actual test files are being served by the web server from the root of the project, which I believe is not very often the case.
I also tried the following, which to me seems like the only way that the option could have worked without breaking the (what I suspect to be) Grunt.js convention of only listing source files that are found to actually exist:
connect: {
server: {
options: {
base: 'www'
}
}
},
qunit: {
main: {
options: {
httpBase: 'http://localhost:8000/'
},
files: [{
expand: true,
cwd: 'www',
src: ['test.html']
}]
}
}
The preceding example unfortunately provides the erroneous http://localhost:8000//www/test.html
to the browser.
Perhaps I'm missing something here, but I believe that if the httpBase
option is not used with a dynamically built files object that it won't be very useful.
Running "qunit:all" (qunit) task
Testing http://localhost:2323/tests DEBUG: -------------------------------
I got this message as soon as the task starts, and I didn't right --debug in the terminal.
Is there any options to turn this debugging off?
I got this error when I try to open a HTML5 Web Database using the html5sql.js.
html5sql.openDatabase("App", "App Database", 50*1024*1024);
It seems related with Phantomjs but I am a kind of stuck here.
So any help could be much appreciated.
What's the rational for supplying the grunt qunit event callbacks with multiple arguments instead of a single argument with the details?
Example: QUnit.testStart (http://api.qunitjs.com/QUnit.testStart/) invokes the callback with an argument containing both the name and the module, but the grunt qunit.testStart event supplies just the name, as a single argument
Running "qunit:all" (qunit) task
Testing https://virt01.proxy.wmflabs.org/b39576b4/test...ERROR
Warning: PhantomJS unable to load "https://virt01.proxy.wmflabs.org/b39576b4/test" URI. Use --force to continue.
Aborted due to warnings.
Most tests go over HTTP, but some projects also like to test HTTPS.
I tried both sites with valid certificates, invalid certificates and self-signed certificates. None of them work. There is an --ignore-ssl-errors=yes
option that might fix it until phantomjs gets their ssl stuff in order.
See also a thread on StackOverflow.
Is there a way to pass in a command line option to the grunt task to only run certain modules? For example, I have a bunch of tests, but perhaps I only want to run one (or a few) QUnit modules right now ... can I do something like:
~$ grunt qunit --modules="setOne, setTwo"
I know I could split these into files and tweak my Gruntfile, but I'm looking for an "on the fly" kind of thing that wouldn't be checked into my repo.
If there isn't such a feature... anyone know how I might be able to do that? (I haven't developed anything for Grunt previously.)
TL;DR: There's any bug related to these lines or even any QUnit bug to address and report?
There's a turtle above the tree. :)
I don't know what or who put the turtle above the tree since these lines are there since the initial commit of this repo.
All I know if we see a turtle on a tree, it's because there's a reason to it, otherwise the turtle won't go there alone.
I'm trying to run npm install
inside a virtualbox, but getting following errorno 53.
root@ubuntu1204:/home/prayagupd/vboxshared/onlywallet# npm install grunt-contrib-qunit
npm http GET https://registry.npmjs.org/grunt-contrib-qunit
npm http 304 https://registry.npmjs.org/grunt-contrib-qunit
npm http GET https://registry.npmjs.org/grunt-lib-phantomjs
npm http 304 https://registry.npmjs.org/grunt-lib-phantomjs
npm http GET https://registry.npmjs.org/eventemitter2
npm http GET https://registry.npmjs.org/semver
npm http GET https://registry.npmjs.org/phantomjs
npm http GET https://registry.npmjs.org/temporary
npm http 304 https://registry.npmjs.org/eventemitter2
npm http 304 https://registry.npmjs.org/phantomjs
npm http 304 https://registry.npmjs.org/temporary
npm http 304 https://registry.npmjs.org/semver
npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/media/sf_vboxshared/onlywallet/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/test'
npm ERR! error rolling back [email protected] { [Error: ENOTEMPTY, rmdir '/media/sf_vboxshared/onlywallet/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/test']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: '/media/sf_vboxshared/onlywallet/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/test' }
npm ERR! Error: EROFS, symlink '../semver/bin/semver'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "grunt-contrib-qunit"
npm ERR! cwd /media/sf_vboxshared/onlywallet
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! path ../semver/bin/semver
npm ERR! code EROFS
npm ERR! errno 56
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /media/sf_vboxshared/onlywallet/npm-debug.log
npm ERR! not ok code 0
My package.json is as below,
1 {
2 "name": "zazzercode",
3 "version": "0.1",
4 "devDependencies": {
5 "grunt": "~0.4.1",
6 "intern": "~1.2.1",
7 "grunt-contrib-jshint": "~0.8.0",
8 "grunt-contrib-qunit": "~0.4.0",
9 "grunt-contrib-watch": "~0.5.3",
10 "grunt-contrib-uglify": "~0.3.2",
11 "grunt-contrib-concat": "~0.3.0",
12 "grunt-closure-compiler": "0.0.18"
13 },
14 "repository": {
15 "type": "git",
16 "url": "https://github.com/iPrayag/onlywallet"
17 }
18 }
I've gotten this module up and running, but I feel like I've done so much that this module should already be responsible for. The examples are a little vague in this regard. I'm looking for clarification on some things.
My tests live in a folder at the root (same level as my Gruntfile) called "test" (test/).
Inside of my test folder, here is the directory structure
ls test/
app.test.js
index.html
libs.test.js
qunit/
qunit-1.11.0.css
qunit-1.11.0.js
Right off the bat, am I concerned as to why I am responsible for having to download qunit myself (shouldn't this come with the module? I'm sure it does). I then create my test runner like this:
<!--
Base HTML from: http://jordankasper.com/blog/2013/04/automated-javascript-tests-using-grunt-phantomjs-and-qunit/
-->
<!doctype html>
<html>
<head>
<meta charset='UTF-8' />
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
<title>QUnit Test Runner</title>
<link rel='stylesheet' href='qunit/qunit-1.11.0.css'>
<!-- add any external libraries your code needs -->
<script src='../static/js/vendor/jquery/jquery-1.9.1.js'></script>
<script src='../static/js/main.js'></script>
<!-- add any JS files under test (or put them in different .html files) -->
<script src='qunit/qunit-1.11.0.js'></script>
<!-- your tests, any and all to run with the given fixtures below -->
<script src='libs.test.js'></script>
<script src='app.test.js'></script>
</head>
<body>
<div id="qunit"></div> <!-- QUnit fills this with results, etc -->
<div id='qunit-fixture'>
<!-- any HTML you want to be present in each test (will be reset for each test) -->
</div>
</body>
</html>
So I am having to specify all of my dependencies, and all of my tests.
However, in the grunt-contrib-qunit README, it appears there is a way to manually specify files, but then how do I specify dependencies on libs? Why am I even building my own test runner if it's going through phantom anyway?
The usage I imagine is that I provide an array of tests or a path to tests (like in one of the examples), and then I specify the path to my own JS files, or an array of each file (in order of how I want them loaded), and then a Spec Runner is created dynamically and deleted from my system.
I believe that the directory structure should look like this:
ls test/
app.test.js
libs.test.js
Am I using this all wrong? Am I not seeing it in the docs?
The amount of logging for every single test is quite a lot:
attributes - it has a set column_count
Message: has set column_count to 2
Actual: 5
Expected: 2
at file:///Users/jasper/Dev/yip/common/tests/lib/qunit.js:472
at file:///Users/jasper/Dev/yip/common/tests/models/reports/block.js:109
at file:///Users/jasper/Dev/yip/common/tests/lib/qunit.js:136
at file:///Users/jasper/Dev/yip/common/tests/lib/qunit.js:279
at process (file:///Users/jasper/Dev/yip/common/tests/lib/qunit.js:1277)
at file:///Users/jasper/Dev/yip/common/tests/lib/qunit.js:383
The first few lines are quite handy obviously, but the complete range of files/line-numbers take a lot of visual space, while they're not very useful (except the actual test-file/line of course). Is there a way to make this more compact? It's getting quite messy when having a lot of tests that are initially not implemented (TDD).
Hey all,
I'm getting a strange issue when trying to run phantomJS in my workflow on a CentOS system.
Here is the error it's reporting:
[4mRunning "qunit:all" (qunit) task[24m
Testing http://localhost:8000/tests.html
Running PhantomJS...[31mERROR[39m
[31m>> [39m/home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: /home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: cannot execute binary file 0 [ '/home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: /home/jenkins/jenkins/workspace/nick_node_te/web-client/client/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs: cannot execute binary file' ]
[33mWarning: PhantomJS exited unexpectedly with exit code 126. Use --force to continue.[39m
Here are my permissions for phantomjs:
-rwxr-x--x. 1 root root 11308856 Sep 26 12:39 phantomjs
I was directed to bring it up in this project instead of the phantomJS one (ariya/phantomjs#11646).
Is it possible this is from installing the module (with npm install) on a Mac, committing it, and then deploying it to a CentOS server? Or is it something entirely different?
I also have put out a SO post on it (http://stackoverflow.com/questions/19013918/phantomjs-crash-exit-code-126), but haven't gotten any bites.
Can anyone help? Is this a bug?
I need to use Connect's useAvailablePort (https://github.com/gruntjs/grunt-contrib-connect#useavailableport) because sometimes the CI server already runs a build for another branch and grunt-contrib-connect fails to bind the port.
It would be nice if urls
array supports values with type function
to lazy evaluate them.
This way I could use https://github.com/gruntjs/grunt-contrib-connect#oncreateserver to get the port value and use it in the url.
At the moment my workaround is to use different ports for the different branches.
This may be related to #19 but it looks different.
I've been using the QUnit RequireJS demo here, which successfully runs both in the browser and through this grunt task. However, when I modify that version to load asynchronously, it works in the browser, but not in Grunt.
I ran Grunt --debug and noticed the following error message halfway through:
[D] ["phantomjs","inject","C:\\Users\\C\\Desktop\\qunit-require-
master\\node_modules\\grunt-contrib-qunit\\phantomjs\\bridge.js"]
[D] ["phantomjs","error.onError","ReferenceError: Can't find variable: QUnit",[{
"file":"C:\\Users\\C\\Desktop\\qunit-require-master\\node_module
s\\grunt-contrib-qunit\\phantomjs\\bridge.js","line":14,"function":""},{"file":"
C:\\Users\\C\\Desktop\\qunit-require-master\\node_modules\\grunt
-contrib-qunit\\phantomjs\\bridge.js","line":58,"function":""}]]
If I attach logs to each function, it's clear that bridge.js is running before QUnit is fully injected.
so I can publish it!
The qunit.js file overrides the following QUnit callbacks: QUnit.log, QUnit.testStart, QUnit.testDone, QUnit.moduleStart, QUnit.moduleDone, QUnit.begin, QUnit.done
Steps to reproduce
// grunt.js
module.exports = function( grunt ) {
grunt.initConfig({
qunit: {
unit: "http://jsbin.com/emogom/1/"
}
});
grunt.registerTask( "default", "qunit" );
};
> grunt
Expected: 6 tests of 6 passed
Actual: 5/6 assertions failed (26ms) Use --force to continue.
grunt.initConfig({
qunit: {
all: [ ... url ... ]
}
});
Running "qunit:all" (qunit) task
Verifying property qunit.all exists in config...OK
Warning: Cannot read property 'srcRaw' of undefined Use --force to continue.
FEATURE
I'm not sure if this is beyond the scope of this project (I haven't yet studied the internals), but it would be wonderful to be able to run Qunit tests in both PhantomJS and a strict node environment using the consistent grunt-contrib-qunit interface. How difficult would this be to add? Am I missing a feature in the documentation?
I can't get it working. It says: "Wildcards and URLs may be combined by specifying both.", what does it mean? I tried it in many ways but I couldn't get it working, could you give me an example?
The most obvious I tried is:
qunit: {
all: {
options: {
urls: ["http://localhost:<%= connect.dev.options.port %>/**/tests/**/*.html"]
}
}
}
Thank you!
OS 10.8.2, using phantomjs 1.8.1 and grunt v0.3.17:
This was originally filed as requirejs/requirejs#618. I am filing a ticket here because the require-2.1.4.js version of the test runs fine in QUnit in the browser, just opening test/index.html in a web browser.
While I am open to this being an issue with requirejs, my first thought is it may be due to how the qunit grunt task binds to the running qunit tests and how it detects with QUnit is "done".
One guess at the problem may be that requirejs 2.1.4 waits a bit longer to start the actual qunit test, after whatever signal the grunt qunit driver uses to detect "done".
So, any insight into what I might look at in the grunt qunit code, or pointers is appreciated.
Although I'm fairly new to grunt, wouldn't it make sense to include the qunit css somewhere in the module? If I'm going to use your version of qunit I would say you should be an authoritative voice on what version of it's dependencies I should use. I can submit a pull request if you agree.
There should be some documented way to run qunit tests with noglobals=true.
For example, qunit-minimalist has an option that allows you to set
parameters: 'noglobals=true'
to run unit tests with the noglobals check. I could not find a way to do it with grunt-contribut-qunit. If there's already a way, it should be documented.
I have a test that fails with grunt when try to emulate the user input typing (I use http://bililite.com/blog/2011/01/23/improved-sendkeys/ to send the key press emulation). It works well in the chrome browser (the test ends ok).
I search related errors in phantom.js and seems fixed.
I use the version 0.2.2 of grunt-contrib-qunit
Any clue to help me?
Thanks!!!
The plugin injects bridge.js script into PhantomJS for tests execution (here is it: https://github.com/gruntjs/grunt-contrib-qunit/blob/master/phantomjs/bridge.js)
There is such code there:
QUnit.log(function(obj) {
// What is this I don’t even
if (obj.message === '[object Object], undefined:undefined') { return; }
// Parse some stuff before sending it.
var actual = QUnit.jsDump.parse(obj.actual);
var expected = QUnit.jsDump.parse(obj.expected);
// Send it.
sendMessage('qunit.log', obj.result, actual, expected, obj.message, obj.source);
});
I think it's a bad idea to parse (via QUnit.jsDump.parse) all objects being passed into QUnit's methods (like equal).
In my case this code results OutOfMemory due to complexity and recursion in passed objects.
grunt-lib-phantomjs
fails to install due to an error in a dependency of its own: node-unzip
.
Error shown is:
TypeError: undefined is not a function
at Until.PullStream._flush (/Users/lupo/Documents/workspace/enoise-core/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/unzip/node_modules/pullstream/pullstream.js:112:5)
at Until.<anonymous> (_stream_transform.js:131:12)
at Until.g (events.js:175:14)
at Until.EventEmitter.emit (events.js:117:20)
at finishMaybe (_stream_writable.js:332:12)
at endWritable (_stream_writable.js:339:3)
at Until.Writable.end (_stream_writable.js:326:5)
at /Users/lupo/Documents/workspace/enoise-core/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/node_modules/unzip/lib/parse.js:282:25
at process._tickCallback (node.js:415:13)
This issue is reported both in grunt-lib-phantomjs
and node-unzip
:
I'm getting an issue when setting up a simple qunit test to be run through grunt with phantom:
PhantomJS timed out, possibly due to a missing QUnit start() call
I'm kind of stumped, I would love to know what I'm missing!
My grunt file looks like this:
qunit: {
all: ['tests/*.html']
},
connect: {
server: {
options: {
port: 3000,
base: '.'
}
}
},
I'm using these versions:
[email protected]
[email protected]
And where is what my sample looks like:
<html>
<head>
<meta charset="utf-8">
<title>Tests</title>
<link rel="stylesheet" href="/tests/resources/qunit-1.10.0.css">
</head>
<body>
<div id="qunit"></div>
<script src="/tests/resources/qunit-1.10.0.js"></script>
<script>
console.log("====TEST===")
test( "hello test", function() {
ok( 1 == "1", "Passed!" );
});
</script>
</body>
</html>
I know it's running because I get the console log output. Any help would be much appreciated!
I am developing on grunt + grunt-express-server + grunt-contrib-qunit.
I need to a following function: select a specify file on input element when page is rendered.
Using vagrant, I set up a basic 12.04.2 VM, and then try install and run this module, and get the "Warning: PhantomJS not found" error.
This is due to phantomjs dependencies not being installed on the OS.
A simple fix is to manually install those dependencies: sudo apt-get install fontconfig
I wrote a bit more about this here: http://stackoverflow.com/a/17927397/492325
Perhaps it's worth mentioning these required dependencies in the README.
When executing install qunit, we tried on many machines (Mac) but always getting error:
event.js:72
throw er; //Unhadled 'error' event
Error: connect ETIMEDOUT
Your script is trying to download phantomjs-1.9.7-macosx.zip and save to local however it looks like there is no way to pass the process, please kindly fix.
Thanks,
Jeru
do you think it would be a good idea to have a hook before and after each test to use another grunt task to inject html into the qunit-fixture?
qunit: {
options: {
setup: ['task-inserting-html-into-fixture'], // grunt-replace for example
teardown: ['task-removing-html-from-fixture'] // grunt-contrib-clean for example
},
all: {
files: 'test/test-suite.html'
}
}
or as I am already wishing for something maybe the qunit task could do that itself:
qunit: {
all: {
html: 'html/**/*.html', // globbing pattern to file that is inserted into the qunit-fixture before each test
files: 'test/test-suite.html'
}
}
This way there still is no connection to the test itself. That means after inserting the html the task won't know what test needs this snippet. Maybe this could be done with naming convention?
qunit: {
all: {
files: 'test/test-suite.html' // test.js is linked in that file and test.html gets injected?
}
}
Then I would have to create endless many test-suites that all link to another tests.js file. Still better than inserting the html myself and having to maintain 2 copies of it (actual template file and qunit-fixture contents) :-/
Or maybe there is a better way to insert pieces of html into the fixture programmatically?
Hi all,
I have installed grunt via npm install
with that 'package.json' file
{
"name": "turtlejs",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-qunit": "~0.1.0",
"grunt-contrib-jshint": "~0.1.0",
"grunt-contrib-uglify": "~0.1.0",
"grunt-contrib-connect": "~0.1.0"
}
}
and this is my 'Gruntfile.js'
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
jshint: {
options: {
browser: true
},
all: ['grunt.js', '*.js', 'test/*.js']
},
qunit: {
all: {
options: {
urls: [
'http://localhost:8000/test/index.html'
]
}
}
},
connect: {
server: {
options: {
port: 8000,
base: '.'
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task.
grunt.registerTask('default', ['jshint', 'connect', 'qunit']);
};
when i run grunt i have this error for the qunit task:
Running "qunit:all" (qunit) task
Warning: Cannot read property 'srcRaw' of undefined Use --force to continue.
what is wrong?
Seems like there were a few fixes since 0.2.2, is it possible to release 0.2.3?
Hello,
I'm trying to use a qunit grunt task, I encounter the following error:
$ grunt qunit
Running "qunit:all" (qunit) task
Testing http://localhost:3001/searchfield.html
Running PhantomJS...ERROR
>> In order for this task to work properly, PhantomJS must be installed locally
>> via NPM. If you're seeing this message, generally that means the NPM install
>> has failed. Please submit an issue providing as much detail as possible at:
>> https://github.com/gruntjs/grunt-lib-phantomjs/issues
Warning: PhantomJS not found. Use --force to continue.
My Gruntfile.js looks like that:
module.exports = function(grunt) {
grunt.initConfig({
qunit: {
all: {
options: {
urls: ['http://localhost:3001/searchfield.html']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-qunit');
};
And after a npm install
command, it seems everything went fine (at least, no error):
> [email protected] install /Users/oncletom/workspace/input-search/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs
> node install.js
Requesting /Users/oncletom/workspace/input-search/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs/tmp/phantomjs-1.8.2-macosx.zip
Receiving...
Received 781K...
Received 1562K...
Received 2344K...
Received 3126K...
Received 3908K...
Received 4690K...
Received 5473K...
Received 6255K...
Received 7037K...
Received 7818K...
Received 8600K...
Received 8934K total.
Extracting zip contents
[email protected] node_modules/grunt-contrib-qunit
└── [email protected] ([email protected], [email protected], [email protected], [email protected])
Any idea?
I've already used grunt-mocha which embbeds phantomjs too, and I had no problem (hence it was a couple of weeks ago).
Thanks.
If you have over 100 tests some of which take a couple of seconds to run because of call backs it would speed things up to be able to run tests in a multi threaded environment.
I'm working on switching a bunch of environments to use grunt-contrib-qunit.
For certain projects it consistently keeps running forever. It won't time out:
15:02:44 + /var/lib/jenkins/bin/grunt qunit '--qunit-url=http://localhost:9412/mediawiki-extensions-VisualEditor-b39576b433/index.php?title=Special:JavaScriptTest/qunit'
15:02:47 Running "qunit:all" (qunit) task
15:02:56 Testing http://localhost:9412/mediawiki-extensions-VisualEditor-b39576b433/index.php?title=Special:JavaScriptTest/qunit........................................................................................................................
15:23:22 ......................................................Build was aborted by Krinkle
The tests run fine in real browsers, where it takes less then a minute.
I need to test my script at different viewport sizes. In my tests I'd like to change the viewport size of PhantomJS by setting page.viewportSize. Is there a way to gain access to it?
I ran into an issue where I was getting a very non-descriptive error message for my problem:
PhantomJS timed out, possibly due to a missing QUnit start() call
The issue was really that I wasn't loading the qunit library properly. But it too much longer to debug that then it should have. More descriptive errors would be great if you have the control to do it! Refs issue #15
With a barebones qunit task ([email protected], [email protected]) on OSX and CentOS 5.4:
// ...
qunit: {
all: ["test/qunit/index.html"]
}
// ...
Sometimes all the tests will pass:
>> 1033 assertions passed (1401ms)
But more often than not the task will crash at a random point in the test:
Running PhantomJS...ERROR
Warning: PhantomJS unable to load "test/qunit/index.html" URI. Use --force to continue.
I'm not sure if this is an issue with the task, grunt-lib-phantomjs or phantomjs itself. All of the tests are within test/qunit/index.html
and are included by requirejs.
My qunit tests run fine when accessed from a browser but when executing them through grunt qunit
, it say:
± |master ✗| → grunt qunit
Running "qunit:all" (qunit) task
Testing test/test.htmlOK
Warning: 0/0 assertions ran (15ms) Use --force to continue.
Aborted due to warnings.
The test.js file looks something like this:
require.config({
baseUrl: "../app/"
});
require(['my-mod'], function (myMod) {
test('simple tests', 1, function () {
// do stuff with myMod
ok(true, 'works.');
});
});
Once I remove the require()
functions and move the test()
block to the top level of the script file, it works:
± |master ✗| → grunt qunit
Running "qunit:all" (qunit) task
Testing test/test.html.OK
>> 1 assertions passed (17ms)
Done, without errors.
Is there a workaround for this or not a supported feature?
Today I ran grunt in a project and it unexpectedly starting throwing errors like these:
[..]
Running "qunit:all" (qunit) task
Testing test/index.html Fatal error: spawn ENOENT
The trace lead me to the internals which hardcode the (absolute) path to phantomjs from when I originally ran installed this project (probably one of the dependencies, but I'm not sure which).
Since the last time I ran the tests, I upgraded phantomjs (a trivial brew upgrade phantomjs
) to the now latest version. The absolute symlink-following path changed (as it does after every version, e.g. /usr/local/Cellar/phantomjs/1.9.2/bin/phantomjs
), and now qunit is failing everywhere (the alias /usr/local/bin/phantomjs
and my PATH still work fine, and afaic the lib should only remember that, not follow the symlink and hardcode the path).
I did re-run npm install
but that doesn't help unless the version of grunt-contrib-qunit (and its dependencies) changes.
I'm keen to suppress the console output (available in 0.5.0), do we know when this might be released?
Thanks,
-Amir
In the following example, '?min' is dropped from the file url.
qunit: {
all: ['test/index.html?min']
}
Looks like during file.expandFileURLs. Is there a way to get that to pass through? jQuery has this option on their unit tests to test the minified version, and so does my project.
Hi there,
I'm trying to use QUnit with Grunt... but I'm stuck with Warning: PhantomJS timed out, possibly due to a missing QUnit start() call. Use --force to continue.
So, I'm wondering if someone has a -almost- complete example of integration...
Here's my try:
Gruntfile.js:
// https://npmjs.org/package/grunt-contrib-qunit
qunit: {
all: ['build/*.html', 'build/*.js']
}, // qunit
[...]
grunt.registerTask('test', ['jshint', 'qunit']);
Thank you for your help! ;-)
My package.json says: "grunt-contrib-qunit": "^0.4.0". This probably has to do with PhantomJS, but maybe it has to do with how this plugin is using PhantomJS so I'll post this here.
Running all my tests in Firefox takes ~1 second and in Chrome ~.5 seconds, but the grunt-contrib-qunit plugin takes ~11 seconds.
Here's a link to the debug output of PhantomJS when my test runs: https://gist.github.com/tieTYT/7faa0b6e8669f4ea4ac1
I'm sure some of this time has to do with how PhantomJS must start up every time and Firefox / Chrome are already open, but I can see with my eyes that the tests themselves are taking a lot of time, so it's not just the start up time.
Is there anything that can be done about this? Is there anything I can do?
I'm using this plugin for my grunt as testrunner for some tests, but after some time my computer has no memory left. I checked why, and saw far over 100 phantomjs processes running. So, I've gone further and realized, that for every url in the urls: [] array this runner starts a new phantomjs, and the old process is left alone.
Usually I would expect, that this runner starts one phantomjs, let this call every url and exits the phantomjs then.
My setup:
Windows 7 professional 64bit
grunt-cli: v0.1.13
grunt: v0.4.5
grunt-contrib-qunit: 0.5.1
If important: I'm using grunt-qunit-junit version 0.1.0
Grunt configuration:
qunit: {
all: {
options: {
'--load-images': false,
urls: []
}
}
},
This is pretty much eating up all my memory (I was wondering why my 8gig of ram were full)
If you need something else to know, just ask
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.