Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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 125,577 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.