grunt-lib-phantomjs
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -24,4 +24,74 @@ /* | ||
}, | ||
test: { | ||
basic: { | ||
options: { | ||
url: 'test/fixtures/basic.html', | ||
expected: [1, 2, 3, 4, 5, 6], | ||
test: function test(a, b, c) { | ||
if (!test.actual) { test.actual = []; } | ||
test.actual.push(a, b, c); | ||
} | ||
} | ||
}, | ||
inject: { | ||
options: { | ||
url: 'test/fixtures/inject.html', | ||
inject: require('path').resolve('test/fixtures/inject.js'), | ||
expected: 'injected', | ||
test: function test(msg) { | ||
test.actual = msg; | ||
} | ||
} | ||
}, | ||
}, | ||
}); | ||
// The most basic of tests. Not even remotely comprehensive. | ||
grunt.registerMultiTask('test', 'A test, of sorts.', function() { | ||
var options = this.options(); | ||
var phantomjs = require('./lib/phantomjs').init(grunt); | ||
// Do something. | ||
phantomjs.on('test', options.test); | ||
phantomjs.on('done', phantomjs.halt); | ||
// Built-in error handlers. | ||
phantomjs.on('fail.load', function(url) { | ||
phantomjs.halt(); | ||
grunt.verbose.write('Running PhantomJS...').or.write('...'); | ||
grunt.log.error(); | ||
grunt.warn('PhantomJS unable to load "' + url + '" URI.'); | ||
}); | ||
phantomjs.on('fail.timeout', function() { | ||
phantomjs.halt(); | ||
grunt.log.writeln(); | ||
grunt.warn('PhantomJS timed out.'); | ||
}); | ||
// This task is async. | ||
var done = this.async(); | ||
// Spawn phantomjs | ||
phantomjs.spawn(options.url, { | ||
// Additional PhantomJS options. | ||
options: options, | ||
// Complete the task when done. | ||
done: function(err) { | ||
if (err) { done(err); return; } | ||
var assert = require('assert'); | ||
var difflet = require('difflet')({indent: 2, comment: true}); | ||
try { | ||
assert.deepEqual(options.test.actual, options.expected, 'Actual should match expected.'); | ||
grunt.log.writeln('Test passed.'); | ||
done(); | ||
} catch (err) { | ||
grunt.log.subhead('Assertion Failure'); | ||
console.log(difflet.compare(err.expected, err.actual)); | ||
done(err); | ||
} | ||
} | ||
}); | ||
}); | ||
// The jshint plugin is used for linting. | ||
@@ -31,4 +101,4 @@ grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
// By default, lint library. | ||
grunt.registerTask('default', 'jshint'); | ||
grunt.registerTask('default', ['jshint', 'test']); | ||
}; |
{ | ||
"name": "grunt-lib-phantomjs", | ||
"description": "Grunt and PhantomJS, sitting in a tree.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"homepage": "http://github.com/gruntjs/grunt-lib-phantomjs", | ||
@@ -33,9 +33,10 @@ "author": { | ||
"temporary": "~0.0.4", | ||
"phantomjs": "~1.8.1" | ||
"phantomjs": "~1.9.0-1" | ||
}, | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "~0.1.1", | ||
"grunt": "~0.4.0" | ||
"grunt": "~0.4.0", | ||
"difflet": "~0.2.3" | ||
}, | ||
"main": "lib/phantomjs" | ||
} |
@@ -17,3 +17,3 @@ # grunt-lib-phantomjs | ||
grunt.registerTask('mytask', 'Integrate with phantomjs.', function() { | ||
var phantomjs = require('./lib/phantomjs').init(grunt); | ||
var phantomjs = require('grunt-lib-phantomjs').init(grunt); | ||
var errorCount = 0; | ||
@@ -36,2 +36,13 @@ | ||
// Built-in error handlers. | ||
phantomjs.on('fail.load', function(url) { | ||
phantomjs.halt(); | ||
grunt.warn('PhantomJS unable to load URL.'); | ||
}); | ||
phantomjs.on('fail.timeout', function() { | ||
phantomjs.halt(); | ||
grunt.warn('PhantomJS timed out.'); | ||
}); | ||
// This task is async. | ||
@@ -92,3 +103,4 @@ var done = this.async(); | ||
* 2013-02-28 - v0.3.0 - Use PhantomJS 1.9.0-1. | ||
* 2013-02-28 - v0.2.0 - Use PhantomJS 1.8.1. | ||
* 2012-12-21 - v0.1.0 - Use PhantomJS 1.7.0. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18132
13
362
104
3
1
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@0.2.01.0.0(transitive)
+ Addedasync@2.6.4(transitive)
+ Addedaws-sign2@0.6.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbl@1.0.3(transitive)
+ Addedboom@2.10.1(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcaseless@0.11.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconcat-stream@1.5.0(transitive)
+ Addedcore-util-is@1.0.21.0.3(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddebug@0.7.4(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextract-zip@1.5.0(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfd-slicer@1.0.1(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@1.0.1(transitive)
+ Addedfs-extra@0.26.7(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedgenerate-object-property@1.2.0(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhar-validator@2.0.6(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhasha@2.2.0(transitive)
+ Addedhawk@3.1.3(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addedhttp-signature@1.1.1(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-my-ip-valid@1.0.1(transitive)
+ Addedis-my-json-valid@2.20.6(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsonfile@2.4.0(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedkew@0.7.0(transitive)
+ Addedklaw@1.3.1(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@0.0.8(transitive)
+ Addedmkdirp@0.5.0(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedoauth-sign@0.8.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpend@1.2.0(transitive)
+ Addedphantomjs@1.9.20(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedprocess-nextick-args@1.0.7(transitive)
+ Addedprogress@1.1.8(transitive)
+ Addedqs@5.2.1(transitive)
+ Addedreadable-stream@2.0.6(transitive)
+ Addedrequest@2.67.0(transitive)
+ Addedrequest-progress@2.0.1(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsntp@1.0.9(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedstringstream@0.0.6(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedthrottleit@1.0.1(transitive)
+ Addedtough-cookie@2.2.2(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addedtypedarray@0.0.7(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedverror@1.10.0(transitive)
+ Addedwhich@1.2.14(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxtend@4.0.2(transitive)
+ Addedyauzl@2.4.1(transitive)
Updatedphantomjs@~1.9.0-1