I am a newbie in JavaScript. I have been reading PhantomJS and CasperJS API. All the time I see the following line of code
in CasperJS
var casper = require('casper').create();
in PhantomJS
var webPage = require('webpage').create();
We can replace the above lines with
in CasperJS
var casper = new require('casper').Casper()
in PhantomJS
var WebPage = require('webpage');
var webPage = new WebPage();
Based on what I know, CasperJS is testing utility sit on top of PhantomJS environment. I'm guessing that the require
function has the same underlying implementation for both CasperJS and PhantomJS.
I have been search around for the API reference to the require
function, but I couldn't find any.
Would be nice if someone can guide me to the right path.
What does the
require
function do? (is it similar to the functionality ofusing
keyword in C# .net)Where does PhantomJS reference the "require" function from? (is it using its own implementation or is it referencing another javascript framework?)