I am trying to write the following Protractor test in CoffeeScript:
describe "tests", ->
browser.get "/"
it "should display Login page", ->
expect(element(by.css("h1")).getText()).toBe "Login"
However, CoffeeScript spits out this error:
SyntaxError: unexpected by
Solutions?
I am trying to write the following Protractor test in CoffeeScript:
describe "tests", ->
browser.get "/"
it "should display Login page", ->
expect(element(by.css("h1")).getText()).toBe "Login"
However, CoffeeScript spits out this error:
SyntaxError: unexpected by
Solutions?
Share Improve this question asked Jun 7, 2014 at 14:52 XåpplI'-I0llwlg'I -XåpplI'-I0llwlg'I - 22.4k28 gold badges107 silver badges154 bronze badges2 Answers
Reset to default 12Like @meagar said it is reserved, you can alias it in your protractor config in the onPrepare
block:
require('coffee-script/register');
exports.config = {
....
// by is reserved in coffee script
onPrepare: function() {
global.By = global.by;
}
}
then
expect(element(By.css("h1")).getText()).toBe "Login"
by
is a reserved word in CoffeeScript, used in specifying loop increments:
evens = (x for x in [0..10] by 2)
Use a different variable name.