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.
phantomjs-test-starter
Advanced tools
Starter Template for testing PhantomJS ‘Applications’ with Jasmine, Grunt, and Istanbul
A boilerplate / starter template for testing PhantomJS ‘Applications’ with Jasmine, Grunt and Istanbul.
There are many resources on how to run tests in PhantomJS, but none on testing Applications written in PhantomJS itself. Non-Trivial Applications such as Data Mining Web Crawlers or Web Page Automation Tools for example.
Conceptually I find it helps to think of PhantomJS as having a server-side and a client-side. The client-side is what happens over in a remote page (inside calls to WebPage.evaluate etc) and the server side is everything else.
This project is concerned with how you test the so-called server side of a PhantomJS Application.
npm install phantomjs-test-starter
git clone git@github.com:JamieMason/phantomjs-test-starter.git
cd phantomjs-test-starter
npm install
Local dependencies are installed by npm install
but you will also need $ phantomjs
(of course) and npm install -g grunt-cli
.
Running grunt test
will run the tests and generate a coverage report at ./spec/build/reports/index.html.
By optional convention, tests are located at ./spec/unit/ at the same relative path as the file being tested.
For example, tests for the following files:
Would be located at:
All test files added to ./spec/unit/unit.runner.js will run, (I hope to generate this file to avoid this manual step).
A slightly modified version of jasmine-standalone-1.3.1 is needed as that does not run in PhantomJS (outside of a page.evaluate that is, which is not relevant to our use case).
This is due to a perfectly reasonable assumption that any JavaScript environment will have either module.exports or window and not both — which is the case in PhantomJS.
The core Jasmine library is identical, only how it's exposed has been modified.
They've been left unignored for this example so can see what gets generated during tests, but in a real application you will want to ignore:
Please fork and pull request or raise an issue if you can help improve this resource in any way.
FAQs
Starter Template for testing PhantomJS ‘Applications’ with Jasmine, Grunt, and Istanbul
We found that phantomjs-test-starter 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.
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.