Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
karma-phantomjs-launcher
Advanced tools
The karma-phantomjs-launcher is an npm package that allows you to use PhantomJS, a headless WebKit scriptable with a JavaScript API, as a browser for running tests with the Karma test runner. This is particularly useful for running tests in a continuous integration environment where you may not have access to a graphical browser.
Running Tests in a Headless Browser
This configuration file for Karma sets up PhantomJS as the browser for running tests. It uses the Jasmine framework and includes the necessary plugins for both Jasmine and PhantomJS.
module.exports = function(config) {
config.set({
browsers: ['PhantomJS'],
frameworks: ['jasmine'],
files: [
'src/**/*.js',
'test/**/*.spec.js'
],
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher'
]
});
};
Continuous Integration Setup
This configuration is tailored for continuous integration environments. It uses the Mocha framework and sets the singleRun option to true, ensuring that Karma will run the tests once and then exit.
module.exports = function(config) {
config.set({
browsers: ['PhantomJS'],
frameworks: ['mocha'],
files: [
'src/**/*.js',
'test/**/*.spec.js'
],
plugins: [
'karma-mocha',
'karma-phantomjs-launcher'
],
singleRun: true
});
};
The karma-chrome-launcher package allows you to use Google Chrome or Chromium as a browser for running tests with Karma. Unlike PhantomJS, Chrome provides a full browser environment, which can be useful for testing features that require a more complete browser implementation.
The karma-firefox-launcher package enables you to use Mozilla Firefox as a browser for running tests with Karma. Similar to the Chrome launcher, it provides a full browser environment, which can be beneficial for testing compatibility with Firefox-specific features.
The karma-safari-launcher package allows you to use Safari as a browser for running tests with Karma. This is particularly useful for testing on macOS environments where Safari is the default browser.
Launcher for PhantomJS.
The easiest way is to keep karma-phantomjs-launcher
as a devDependency in your package.json
,
by running
$ npm install --save-dev karma-phantomjs-launcher
// karma.conf.js
module.exports = function(config) {
config.set({
browsers: ['PhantomJS', 'PhantomJS_custom'],
// you can define custom flags
customLaunchers: {
'PhantomJS_custom': {
base: 'PhantomJS',
options: {
windowName: 'my-window',
settings: {
webSecurityEnabled: false
},
},
flags: ['--load-images=true'],
debug: true
}
},
phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
exitOnResourceError: true
}
})
}
The options
attribute allows you to initialize properties on
the phantomjs page
object, so
options: {
windowName: 'my-window',
settings: {
webSecurityEnabled: false
},
}
is equivalent to:
var webPage = require('webpage')
var page = webPage.create()
page.windowName = 'my-window'
page.settings.webSecurityEnabled = false
You can pass list of browsers as a CLI argument too:
$ karma start --browsers PhantomJS_custom
If you set the debug
option to true
, you will be instructed to launch a web browser to
bring up the debugger. Note that you will want to put debugger;
statements in your JavaScript
to hit breakpoints. You should be able to put breakpoints in both your test code and your client
code. Note that the debug
option automatically adds the --remote-debugger-port=9000
and
--remote-debugger-autorun=yes
switches to PhantomJS.
For more information on Karma see the homepage.
FAQs
A Karma plugin. Launcher for PhantomJS.
The npm package karma-phantomjs-launcher receives a total of 51,504 weekly downloads. As such, karma-phantomjs-launcher popularity was classified as popular.
We found that karma-phantomjs-launcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.