Closed jwestbrook closed 10 years ago
I just added a test for this: https://github.com/jdcataldo/grunt-mocha-phantomjs/commit/71e2a48151c562b10748924b8b112d0b1aa4d5f2
Everything runs fine and the tests are passing: https://travis-ci.org/jdcataldo/grunt-mocha-phantomjs
How are you setting up the server?
Using this Gruntfile.js
https://github.com/jwestbrook/prototype/blob/master-w-updates/Gruntfile.js
I comment out the base files so that the mocha_phantomjs config is this
mocha_phantomjs:{
options: {
'urls' : [ 'http://localhost:1337/test/ajaxtests.html',
'http://localhost:1337/test/formtests.html' ]
}
// base: [ 'test/index.html',
// 'test/domtests.html',
// 'test/selectortests.html',
// 'test/layouttests.html']
}
then
$ grunt --verbose test
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Reading package.json...OK
Parsing package.json...OK
Reading src/constants.yml...OK
Parsing src/constants.yml...OK
Initializing config...OK
Registering "grunt-resolve" local Npm module tasks.
Reading package.json...OK
Parsing package.json...OK
Loading "grunt.js" tasks...OK
+ resolve
Registering "grunt-contrib-concat" local Npm module tasks.
Reading package.json...OK
Parsing package.json...OK
Loading "concat.js" tasks...OK
+ concat
Registering "grunt-mocha-phantomjs" local Npm module tasks.
Reading package.json...OK
Parsing package.json...OK
Loading "mocha_phantomjs.js" tasks...OK
+ mocha_phantomjs
Loading "Gruntfile.js" tasks...OK
+ default, dist, docs, gcc_rest, generate_docs, replacevars, runwebserver, test
Running tasks: test
Running "test" task
Running "runwebserver" task
Web server Started on port 1337.
Running "mocha_phantomjs" task
Done, without errors.
I also made sure I ran npm update
as well
$ npm list mocha-phantomjs
prototypejs@1.7.1 /prototype
└── mocha-phantomjs@3.1.6
However if I do not comment out the array of files in base then everything runs as expected
Also I just noticed that the Gruntfile you linked has other local files (in other targets understood) but I think that is where the problem lies.
I cloned the project and ran it locally. It couldn't find phantomjs. Removing mocha-phantomjs as a devDependency fixed everything for me. grunt-mocha-phantomjs installs mocha-phantomjs and phantomjs as dependencies so you should need to have it declared separately.
I see what you are saying - but let me demonstrate in a different way.
I forked grunt-mocha-phantomjs to here https://github.com/jwestbrook/grunt-mocha-phantomjs
changed the Gruntfile here https://github.com/jwestbrook/grunt-mocha-phantomjs/commit/aa9b479618478d5be44f3f939210366e31a0b7b7
ran
npm install
then
$ grunt
Running "jshint:all" (jshint) task
>> 2 files lint free.
Running "connect:server" (connect) task
Started connect web server on 127.0.0.1:8000.
Done, without errors.
$ grunt --verbose
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Initializing config...OK
Registering "grunt-contrib-connect" local Npm module tasks.
Reading grunt-mocha-phantomjs/node_modules/grunt-contrib-connect/package.json...OK
Parsing grunt-mocha-phantomjs/node_modules/grunt-contrib-connect/package.json...OK
Loading "connect.js" tasks...OK
+ connect
Registering "grunt-contrib-jshint" local Npm module tasks.
Reading grunt-mocha-phantomjs/node_modules/grunt-contrib-jshint/package.json...OK
Parsing grunt-mocha-phantomjs/node_modules/grunt-contrib-jshint/package.json...OK
Loading "jshint.js" tasks...OK
+ jshint
Registering "tasks" tasks.
Loading "mocha_phantomjs.js" tasks...OK
+ mocha_phantomjs
Loading "Gruntfile.js" tasks...OK
+ default
No tasks specified, running default tasks.
Running tasks: default
Running "default" task
Running "jshint" task
Running "jshint:all" (jshint) task
Verifying property jshint.all exists in config...OK
Files: Gruntfile.js, tasks/mocha_phantomjs.js -> all
Options: force=false, reporterOutput=null, jshintrc=".jshintrc"
JSHint options: force=false, reporterOutput=null, jshintrc=".jshintrc"
OK
>> 2 files lint free.
Running "connect" task
Running "connect:server" (connect) task
Verifying property connect.server exists in config...OK
File: [no files]
Options: protocol="http", port=8000, hostname="localhost", base=".", directory=null, keepalive=false, debug=false, livereload=false, open=false, middleware=undefined
Started connect web server on 127.0.0.1:8000.
Running "mocha_phantomjs" task
Done, without errors.
Does this make sense?
Yup this makes sense. grunt-mocha-phantomjs is setup as a multitask so it is looking for a target. Since you don't specify one, nothing runs. If you specify a new target such as mocha_phantomjs:test, everything will run fine. This is why my mocha_phantomjs:server runs no problem.
OK thanks for explaining it - I'll adjust my targets in the config.
If I define
The grunt task runs with nothing done - as there are no "files" to run - but If only want to test a specific test script that runs on a webserver I cannot