Question

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?

Was it helpful?

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.

OTHER TIPS

Support for CoffeeScript should work out of the box for both configuration files, as well as your spec files.

I am running version 0.20.1 of protractor with CoffeeScript 1.7.1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top