Can I use CoffeeScript for protractor tests with AngularJS?

angularjs, coffeescript, protractor

Solution

Yes you can. (Thanks @rjferguson21 for the update on `By` being global).

Your main difficulty lies in the fact that `by` (lower-case "B") is a reserved word in CoffeeScript. But `By` (upper-case "B") is a global and is not reserved.

describe 'such and such', ->

    describe 'with protractor', ->
        testElement = element By.model('testElement')
        testElement.clear()
        testElement.sendKeys('123')
        expect(testelement.getAttribute('value')).toEqual '123'

All the protractor tutorials refer to `by` so be mindful to change them to `By` in your CoffeeScript files.

Problem

I'm trying to set up my end-to-end testing and I hear that we should be using `protractor` now, https://docs.angularjs.org/guide/e2e-testing However, my entire project is CoffeeScript based and I'd hate to have just a little bit of JS if I can avoid it. Any way for me to use protractor with CoffeeScript?

Original source