Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use CoffeeScript for protractor tests with AngularJS?

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?

like image 250
Shamoon Avatar asked Dec 19 '25 04:12

Shamoon


1 Answers

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.

like image 126
Paul Oliver Avatar answered Dec 20 '25 20:12

Paul Oliver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!