Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
grunt-mocha-phantomjs
Advanced tools
A simple wrapper to run client-side mocha tests using mocha-phantomjs core library
This plugin requires Grunt ~0.4.0
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 with this command:
npm install grunt-mocha-phantomjs --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-mocha-phantomjs');
Run this task with the grunt mocha_phantomjs
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
PhantomJS is installed when installing using NPM.
Type: String
Default: spec
The reporter that should be used. See the supported reporters for more information.
Type: String
The file that the task should output the results to. If output
is specified, the task will always complete and not throw an error code if errors are found. The CI will determine if the build failed or not.
Type: Boolean
Setting failWithOutput
to true when used with the output
option will fail a build along with creating a test artifact. This is useful for CIs (CircleCI) that don't fail a build based on the test artifact.
Type: Boolean
Setting silent
to true will prevent the results from being printed using stdout.
Type: Array
Default: []
Absolute http://
or https://
urls to be passed to PhantomJS. Specified URLs will be merged with any specified src
files first. Note that urls must be served by a web server, and since this task doesn't contain a web server, one will need to be configured separately. The grunt-contrib-connect plugin provides a basic web server.
Additional arguments may be passed. See mocha-phantomjs's usage.
Type: Object
Default: {}
Options to be passed directly to phantomjs. Eg:
{
"--local-storage-path": "my/temp-phantom-files",
"--local-storage-quota": "20480"
}
See phantomjs -h
for more full options list.
Type: Object
Default: { useColors: true }
Options to be passed to mocha-phantomjs. See mocha-phantomjs-core's usage.
// Project configuration.
grunt.initConfig({
mocha_phantomjs: {
all: ['test/**/*.html']
}
});
// Project configuration.
grunt.initConfig({
mocha_phantomjs: {
options: {
reporter: 'xunit',
output: 'tests/results/result.xml'
},
all: ['test/**/*.html']
}
});
// Project configuration.
grunt.initConfig({
mocha_phantomjs: {
options: {
reporter: 'xunit',
output: 'tests/results/result.xml',
config: {
useColors: false,
viewportSize: {
width: 1024,
height: 768
},
grep: 'pattern'
}
},
all: ['test/**/*.html']
}
});
Include the [grunt-contrib-connect plugin][] to run a local server [grunt-contrib-connect plugin]: https://github.com/gruntjs/grunt-contrib-connect
// Project configuration.
grunt.initConfig({
mocha_phantomjs: {
all: {
options: {
urls: [
'http://localhost:8000/test/foo.html',
'http://localhost:8000/test/bar.html'
]
}
}
},
connect: {
server: {
options: {
port: 8000,
base: '.',
}
}
}
});
grunt.registerTask('test', ['connect', 'mocha_phantomjs']);
This is a very basic implementation of mocha-phantomjs. Failed tests and errors do not bubble up for custom reporting. The idea of this is to be mainly used by a CI and let the CI manage the error reporting.
4.0.0
FAQs
Run client-side mocha tests using phantomjs
The npm package grunt-mocha-phantomjs receives a total of 521 weekly downloads. As such, grunt-mocha-phantomjs popularity was classified as not popular.
We found that grunt-mocha-phantomjs 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.