This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
Mocha/Chai Promise Adapter -- Proof of Concept #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #35
I put this together fairly quickly, but I wanted to run it by the protractor team before I invested more time. It makes use of my promise-testing library to provide a Chai.js adapter for expectations on webdriver promises, very similar to the existing Jasmine implementation.
All the relevant files are in the
mochachaiwd
directory.onMocha.js
andindex.js
are modified copies of files with the same name elsewhere in the project. I recommend using a file comparison tool to see what I actually changed (it's really only a few lines).After cloning, switch to the
mocha-proof-of-concept
branch and then:Once selenium is up and running, then:
This is not ready for primetime yet. To get there it needs:
mochachaiwd/index.js
is a hacked copy ofjasminewd/index.js
. There is plenty of duplicate code that could easily be eliminated.expect(promiseA).to.equal(promiseB)
). This will be harder to patch in Chai than it was Jasmine, since Chai allows such long promise chains (expect({a:10}).property('a').to.be.at.least(6)
). I will add the feature there (possibly include a hook for customizing how promises are detected - which protractor could use to detect webdriver promises).Thanks for for a great tool guys!