![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
grunt-phantomcss-slevomat-fork
Advanced tools
Plugin to do CSS regression testing via PhantomCSS.
Automate CSS regression testing with PhantomCSS
This is a fork of the original grunt-phantomcss, with the following updates and enhancements:
Currently this fork is not available on npm, however, you can install and use this version by following the steps below.
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin through the following steps.
Install from the command line:
$ npm install @micahgodbolt/grunt-phantomcss --save-dev
Or add the following line to your package.json
:
"@micahgodbolt/grunt-phantomcss": "^0.4.0"
Then, once the plugin has been installed via npm install
, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-phantomcss');
In your project's Gruntfile, add a section named phantomcss
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
phantomcss: {
options: {
screenshots: 'test/visual/screenshots/',
results: 'results/visual/',
viewportSize: [1280, 800],
mismatchTolerance: 0.05,
rootUrl: 'http://localhost:3000/' // Optional
phantomjsArgs: [
// optional, array of phantomJS CLI options
]
},
src: [
'test/visual/**/*.js'
]
}
});
Type: String|Array
The test files to run.
Type: Number
Default: 0.05
The change percentange tolerated between screenshots (for instance to match anti-aliasing bugs).
Type: String
Default: './screenshots'
The screenshots directory, relative to the src file, where test fixtures (comparison screenshots) are stored. Baseline screenshots will be stored here on the first run if they're not present.
Type: String
Default: './results'
The directory, relative to the src file, to store source, diff, and failure screenshots after tests.
Type: Array
Default: [1280, 800]
The viewport size to test the site in [width, height]
format. Useful when testing responsive layouts.
Type: String
Default: error
The CasperJS log level. See CasperJS: Logging for details.
Type: String
Default: ``
Optional parameter passed to testfiles for prepending to relative URL's. Useful when testing against multiple environments.
Type: Array
Default: []
Optional array of CLI arguments passed when running phantomJS. See PhantomJS Command-line Options for details.
// Example PhantomJS Command-line Options
phantomcss: {
options: {
[...]
phantomjsArgs: [
'--ssl-protocol=tlsv1',
'--ignore-ssl-errors=true',
]
}
}
Run tests in test/visual/
against comparison screenshots stored in test/visual/screenshots/
, and put the resulting screenshots in results/visual/
grunt.initConfig({
phantomcss: {
options: {
screenshots: 'test/visual/screenshots/',
results: 'results/visual/'
},
src: [
'test/visual/**/*.js'
]
}
});
Run tests in test/visual/
against comparison screenshots for destop and mobile. Pass rootUrl option to specify testing against http://localhost:3000/
.
grunt.initConfig({
phantomcss: {
desktop: {
options: {
screenshots: 'test/visual/desktop/',
results: 'results/visual/desktop',
viewportSize: [1024, 768],
rootUrl: 'http://localhost:3000/'
},
src: [
'test/visual/**.js'
]
},
mobile: {
options: {
screenshots: 'test/visual/mobile/',
results: 'results/visual/mobile',
viewportSize: [320, 480],
rootUrl: 'http://localhost:3000/mobile/'
},
src: [
'test/visual/**.js'
]
}
},
});
Test files should do the following:
casper.start()
when it begins, so all test files need to start with casper.thenOpen
.casper.thenOpen('http://localhost:3000/todo')
.then(function() {
this.evaluate(function() {
$('*').css('font-family', 'arial, sans-serif');
});
})
.then(function() {
phantomcss.screenshot('#todo-app', 'Main app');
})
.then(function() {
casper.fill('form.todo-form', {
todo: 'Item1'
}, true);
phantomcss.screenshot('#todo-app', 'Item added');
})
.then(function() {
casper.click('.todo-done');
phantomcss.screenshot('#todo-app', 'Item checked off');
});
You can also make URL's relative, prepending the rootUrl to them:
casper.thenOpen(phantom.rootUrl + 'todo')
.then(function() {
jQuery('*').css('font-family', 'arial, sans-serif');
})
.then(function() {
phantomcss.screenshot('#todo-app', 'Main app');
});
See the CasperJS documentation and the PhantomCSS documentation for more information on using CasperJS and PhantomCSS.
For further examples, refer to the following posts:
FAQs
Plugin to do CSS regression testing via PhantomCSS.
The npm package grunt-phantomcss-slevomat-fork receives a total of 2 weekly downloads. As such, grunt-phantomcss-slevomat-fork popularity was classified as not popular.
We found that grunt-phantomcss-slevomat-fork demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.