문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top