First: I have looked at a number of tickets that address similar issues, but I feel that mine is different is a particular respect: I have just installed the Chutzpah test runner in Visual Studio 2015, and I don't know what to expect from that test runner in terms of PhantomJS and RequireJS. I don't know what is already configured for me within the plugin, and what I need to configure myself.
I have just begun to use the Chutzpah test runner within Visual Studio 2015.
I am writing tests within the Jasmine framework.
Here is my current chutzpah.json configuration:
I have successfully run some throwaway Jasmine tests that do not leverage any additional libraries:
It was my understanding that the Chutzpah test runner makes use of PhantomJS, so I attempted to write a test to verify that PhantomJS is available.
I copied the first line of the tutorial on the PhantomJS landing page:
var page = require('webpage').create();
I interpolated this into the following unit test:
describe('PhantomJS', function () {
it('can create a web page', function () {
var page = require('webpage').create();
expect(page).toBeDefined();
});
});
After running this test, I receive the following error:
Message:ReferenceError:Can't find variable:require in ... {pointer to test file}
My understanding is that Chutzpah already makes use of RequireJS.
My question is:
Should I expect PhantomJS and RequireJS to be natively supported by the Chutzpah test runner in Visual Studio 2015, or do I need to add and configure additional modules?
Thank you for your attention. Clarifying questions are welcome.
Chutzpah uses PhantomJS but you can't directly access its built in require function. If you want to invoke a phantom webpage level api you can use the following code:
window.callPhantom(
{
Type:"Eval",
Data: "phantom.pagesize(100,200);"
});
As for RequireJS, Chutzpah supports working with it but does not come bundled with it. You must reference it yourself. Please check out the samples in the Chutzpah repo. These can help you get started.