Socket
Socket
Sign inDemoInstall

grunt-lib-phantomjs

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-lib-phantomjs - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

test/fixtures/basic.html

72

Gruntfile.js

@@ -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']);
};

7

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc