Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

feature request: mocha adapter support #35

Closed
steve-baer opened this issue Jul 20, 2013 · 9 comments
Closed

feature request: mocha adapter support #35

steve-baer opened this issue Jul 20, 2013 · 9 comments

Comments

@steve-baer
Copy link

Would love to see this supported. Currently we are experimenting with using protractor as a library for our mocha tests; thank you, included code example ;)

If there is some high-level conceptual understanding that someone could present that would describe how to accomplish this, I would love to fork this and do it myself. Some guidance as to the right direction to head would be awesome, if anyone has any ideas.

@juliemr
Copy link
Member

juliemr commented Jul 22, 2013

Hello,

I assume you saw examples/onMocha.js? It requires a bit more setup (if you look into the test file, you'll see that it has to build its own webdriver).

There are a couple things missing for good mocha integration. First, there's an adapter for Jasmine that allows expectations to be called directly on webdriver promises expect(myPromise).toEqual('foo'). This currently won't work for Mocha, so an adapter for one of Mocha's assertion libraries to work with promises would be nice.

The other missing bit would be a way to run it directly from the command line and with a configuration file (so your tests are separate from the configuration), but I'm not sure if that's what you're asking for.

@steve-baer
Copy link
Author

I did; using that example as a sort of base to model after, and so far so good.

I would like to be able to use the Chai assertion library instead of Jasmine; our unit tests are Mocha/Chai, so having one less library for our developers to learn would be fantastic. The additional setup required in the current implementation (including Protractor and wrapping the driver) isn't an issue right now, but having things abstracted out and being able to use Protractor directly would be highly desired.

@kburson
Copy link

kburson commented Aug 6, 2013

+1 on this.
I am working on integrating protractor with our project. We use grunt with karma, mocha, chai for our unit/integration (midway) tests already. That is working fine. I want to move away from karma-ng-scenario for e2e and use protractor. The bonus is if we could use mocha+chai through all levels of testing.

I have some time this week to work on this if someone is willing to join me.

@jamestalmage
Copy link

As for promise adapters. I've done some preliminary work on one:
https://github.com/promise-testing/promise-testing

It has chai+mocha support built in.

I have been dogfooding it for a few months, and it works.

@rweng
Copy link

rweng commented Oct 28, 2013

nice, +1

@juliemr
Copy link
Member

juliemr commented Dec 27, 2013

Some early work done in 478c00a

Please check it out and see if it works for your project! The big problem is that it does not include an adapter for assertions yet - so you will have to resolve promises manually.

@juliemr
Copy link
Member

juliemr commented Dec 28, 2013

After a little more research, got mocha working using Chai As Promised for assertions. Check out https://github.com/angular/protractor/blob/master/docs/using-mocha.md for info on how-to.

Closing this issue - but please, give it a shot and open others if you find problems!

@juliemr juliemr closed this as completed Dec 28, 2013
@jamestalmage
Copy link

Doh!
jamestalmage@83f1469

@demisx
Copy link

demisx commented Sep 7, 2014

The updated URL for using the awesome Mocha/Chai framework with protractor appears to be https://github.com/angular/protractor/blob/master/docs/frameworks.md#using-mocha

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants