PhantomJS failed to load your page. Use --force to continue - javascript

I am trying to run test with grunt-contrib-jasmine trough command line "grunt jasmine", but its fails giving the warning : "PhantomJS failed to load your page. Use --force to continue."...
base.spec.js:
describe('Namespace',function(){
it('Provides the global *** object',function(){
expect(***).to.be.an('object');
expect(***).to.include.keys('App','Templates');
});
});
gruntfile.js including this:
jasmine : {
src : ['apps/<%=target%>/js/**/*.js'],
options : {
host : 'http://127.0.0.1:5000',
specs : 'tests/<%=target%>/**/*spec.js',
}
},
.
.
.
grunt.loadNpmTasks('grunt-contrib-jasmine');
Can't understand what is wrong...
Please help, Thanks in advance...

In gruntfile.js make your src: 'apps/<%=target%>/js/**/FileName',
(remove the .js after filename)
Add this before jasmine:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
test : {
port : 8000,
base: 'test'
}
},
set a default task so it can perform connection and then execute:
grunt.registerTask('default', ['connect','jasmine']);
if it yet fails then try doing grunt jasmine --force to know where its failing

Related

grunt task undefined not found

I'm fairly new to Grunt and trying to run a custom task using grunt-protractor-coverage plugin but I get the error
Warning: Task "undefined" not found. Use --force to continue.
My script is as follows.
module.exports = function(grunt) {
grunt.registerTask('test', 'Log some stuff.', function() {
console.log('Logging some stuff...');
});
grunt.initConfig({
instrument: {
files: 'server/**/*.js',
options: {
lazy: true,
basePath: "instrumented"
}
}
});
grunt.loadNpmTasks('grunt-protractor-coverage');
grunt.registerTask('instrument');
// Default task(s)
grunt.registerTask('default', ['instrument']);
};
I had this issue before, and solved it by updating grunt. Would be a good first step to try:
npm --global update grunt-cli

Grunt File Blocks `Required config property ... missing`

I cannot seem to get fileblocks running. Every time I run grunt I get this error message:
Running "wiredep:app" (wiredep) task
Running "fileblocks:dev" (fileblocks) task
Verifying property fileblocks.dev exists in config...ERROR
>> Unable to process task.
Warning: Required config property "fileblocks.dev" missing. Use --force to continue.
Aborted due to warnings.
I have a modular setup for integrating the various tasks executed by Grunt. I have installed file-blocks by running npm install --save-dev grunt-file-blocks and my Gruntfile.js is:
module.exports = function(grunt) {
grunt.initConfig({
pkg: require('./package.json')
});
grunt.loadTasks('grunt-tasks');
grunt.registerTask('default', ['wiredep', 'fileblocks:dev']);
};
Here's my grunt-tasks/fileblocks.js:
module.exports = function(grunt) {
grunt.initConfig({
fileblocks: {
dev: {
src: 'app/*.html',
blocks: {
'css': {
src: 'app/*.css'
},
'js': {
src: 'src/*.js'
}
}
}
}
});
grunt.loadNpmTasks('grunt-file-blocks');
};
So, I expect fileblock:dev to run the fileblocks task dev that I've defined, but I get the aforementioned error. Help!

Why do I get an error code from growl when using grunt-notify?

I installed grunt-notify to get messages on desktop.
Here is the Gruntfile.js :
module.exports = function(grunt) {
grunt.initConfig({
notify: {
test: {
options: {
message: "YO"
}
}
}
});
grunt.loadNpmTasks('grunt-notify');
// simplified example
grunt.registerTask('default', ['notify:test']);
};
The console output on grunt -v
E:\Temp>grunt -v
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Initializing config...OK
Registering "grunt-notify" local Npm module tasks.
Reading E:\Temp\node_modules\grunt-notify\package.json...OK
Parsing E:\Temp\node_modules\grunt-notify\package.json...OK
Loading "notify.js" tasks...OK
+ notify
Loading "notify_hooks.js" tasks...OK
+ notify_hooks
Loading "Gruntfile.js" tasks...OK
+ default
No tasks specified, running default tasks.
Running tasks: default
Running "default" task
Running "notify:test" (notify) task
Verifying property notify.test exists in config...OK
File: [no files]
Options: title="Temp", message="YO"
>> [grunt-notify] growl: C:\Utils\growlnotify\growlnotify.COM
>> [growl] cmd: growlnotify
>> [growl] args: /i:E:\Temp\node_modules\grunt-notify\images\grunt-logo.png YO /t:Temp
>> [growl] return_code: 4294967295
Done, without errors.
We can see a return_code: 4294967295 (-1 converted to unsigned 32-bit value). .
If I manually do the following command line : E:\Temp>growlnotify /i:E:\Temp\node_modules\grunt-notify\images\grunt-logo.png YO /t:Temp
I got the message (without the logo) :
So, why I got an error code when passing via grunt-notify, but not on a manual line command?
Note : I'm using Windows 7 Pro
Edit : after following this issue : https://github.com/dylang/grunt-notify/issues/91, I succeed to get the image with the command line :
C:\temp>growlnotify /i:"C:/temp/node_modules/grunt-notify/images/grunt-logo.png" "YO" /t:temp
But still doesn't work through grunt...

Error using LiveReload on virtual machine with grunt

I am working with a virtualbox set up with vagrant/puphpet (ubuntu 12.04).
I set up grunt and contrib-watch successfully. I installed the chrome extension ... everything as specified here : https://github.com/gruntjs/grunt-contrib-watch#live-reloading
My Gruntfile is as follow :
module.exports = function(grunt)
{
require('load-grunt-tasks')(grunt);
grunt.initConfig({
compass: { // Task
dist: { // Target
options: { // Target options
sassDir: 'sass',
cssDir: 'css',
environment: 'development',
httpPath: '/',
imagesDir: 'img',
relativeAssets: true
}
}
},
watch: {
options: { livereload: true },
sass: {
files: ['sass/**/*.scss'],
tasks: ['compass'],
options: { spawn: false }
}
}
});
grunt.registerTask('default', ['compass']);
}
I run command "grunt watch" and it processes my sass right. But in Chrome's console I get the following error :
GET http://127.0.0.1:35729/livereload.js?ext=Chrome&extver=2.0.9
net::ERR_CONNECTION_REFUSED injected.js:116
If I add the script manualy in my view I still get the error :
GET http://localhost:35729/livereload.js net::ERR_CONNECTION_REFUSED
Any idea where this error could come from and why it's not loading the script ?
Your gruntfile looks alright.
It looks like your virtual machine refuses the connection. Make sure the live reload port is open in iptables.
In Ubuntu, that can be done simply with ufw:
sudo apt-get install ufw
sudo ufw enable
sudo ufw allow 35729/tcp

I am getting warning when I run Grunt saying 'default' task not found

I am new to Grunt. Whenever I have run the Grunt command it gives this warning and aborts. The warning is given below.
Loading "Gruntfile.js" tasks...ERROR
TypeError: Object # has no method 'loadNpmtasks' Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
I know this type of question has been asked before. I have seen those answers. All of them have some syntax error. I can't find anything in mine. My code has been given below.
module.exports = function(grunt){
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
concat : {
dist : {
src : [
'something.js',
'anything.js'
], dest : 'new.js'
}
}
});
grunt.loadNpmtasks('grunt-contrib-concat');
grunt.registertasks('default', ['concat']);
};
Your methods name are wrong, the t from tasks is lowercase instead of uppercase.
loadNpmtasks should be loadNpmTasks and registertasks should be registerTasks

Categories

Resources