Reputation: 63
I'm trying to run my existing Protractor script using Serenity-JS.
In order to do so, I followed the internet's instructions and added the following to my config after installing Serenity-JS ('npm install -g serenity-js', plus the required 'npm install -g mocha --save-dev');
exports.config = {
framework: 'custom',
frameworkPath: require.resolve('serenity-js'),
// ...
}
The framework is attempting to run my test but does not seem to recognize my beforeAll().
I get the following error:
ReferenceError: beforeAll is not defined
My Protractor script which is referenced by my conf file contains the following code at the start:
var generic = require('./generic.js');
var tools = new generic.Tools();
describe('Testscript 1', function () {
beforeAll( function () {
//Open none angular site
browser.driver.get('http://localhost/');
browser.driver.findElement(by.xpath('//*[@id="url"]/option[4]')).click();
browser.driver.findElement(by.xpath('//*[@id="submit"]')).click();
});
beforeEach(function () {
browser.refresh();
});
I'm totally new to a framework around Protractor, so I have no idea where to look.
Can someone please point me in the right direction?
Thanks in advance!
Upvotes: 0
Views: 7047
Reputation: 4536
Even though on the surface Mocha and Jasmine's syntax might look similar, they're in fact two completely different frameworks with slightly different semantics.
For example, while in Jasmine you'd use beforeAll()
, in Mocha you have before()
.
To make your test work with Mocha you need to make sure that you're using the correct syntax:
describe('Testscript 1', function () {
before( function () {
//Open none angular site
browser.driver.get('http://localhost/');
browser.driver.findElement(by.xpath('//*[@id="url"]/option[4]')).click();
browser.driver.findElement(by.xpath('//*[@id="submit"]')).click();
});
beforeEach(function () {
browser.refresh();
});
Now regarding, the Serenity/JS part :-)
You don't need to install serenity-js
, mocha
or protractor
globally (the -g
switch). In fact, in my view, that's an anti-pattern.
Have a look at the Installation section of the Serenity/JS Handbook to find out more about the dependencies you need.
I hope this helps!
Best,
Jan
Upvotes: 4