Cannot use Mocha to write angular2 tests #5395

Closed
rosendi opened this Issue Nov 19, 2015 · 15 comments

Comments

Projects
None yet
9 participants
@rosendi

rosendi commented Nov 19, 2015

If I use Mocha as a testing framework I'm getting the error message:

/Projects/firebase-pipes/node_modules/angular2/typings/jasmine/jasmine.d.ts(13,18): error TS2300: Duplicate identifier 'it'.
/Projects/firebase-pipes/node_modules/angular2/typings/jasmine/jasmine.d.ts(14,18): error TS2300: Duplicate identifier 'it'.
/Projects/firebase-pipes/node_modules/angular2/typings/jasmine/jasmine.d.ts(17,18): error TS2300: Duplicate identifier 'xit'.
/Projects/firebase-pipes/node_modules/angular2/typings/jasmine/jasmine.d.ts(18,18): error TS2300: Duplicate identifier 'xit'.
typings/mocha/mocha.d.ts(37,13): error TS2300: Duplicate identifier 'describe'.
typings/mocha/mocha.d.ts(38,13): error TS2300: Duplicate identifier 'xdescribe'.
typings/mocha/mocha.d.ts(43,13): error TS2300: Duplicate identifier 'it'.
typings/mocha/mocha.d.ts(44,13): error TS2300: Duplicate identifier 'xit'.

Is it necessary to propagate Angular with Jasmine typings?

https://github.com/angular/angular/blob/master/modules/angular2/manual_typings/globals-es6.d.ts#L9.

@dsebastien

This comment has been minimized.

Show comment
Hide comment
@dsebastien

dsebastien Nov 22, 2015

+1, it would be nice to be able to choose between mocha and jasmine :)

+1, it would be nice to be able to choose between mocha and jasmine :)

@dsebastien dsebastien referenced this issue in dsebastien/modernWebDevBuild Nov 22, 2015

Closed

Add support for unit testing #14

9 of 9 tasks complete
@manland

This comment has been minimized.

Show comment
Hide comment

manland commented Nov 22, 2015

👍

@yizhan

This comment has been minimized.

Show comment
Hide comment
@yizhan

yizhan Dec 4, 2015

:+1
We are running Angular 1 and Angular 2 at same time, but we can not do testing at same time.

We started Angular 1 with Jasmine1 testing, and now Angular 2 has built in with Jasmine 2 testing right?
It seems have same typing issue.

yizhan commented Dec 4, 2015

:+1
We are running Angular 1 and Angular 2 at same time, but we can not do testing at same time.

We started Angular 1 with Jasmine1 testing, and now Angular 2 has built in with Jasmine 2 testing right?
It seems have same typing issue.

@dsebastien

This comment has been minimized.

Show comment
Hide comment
@dsebastien

dsebastien Dec 8, 2015

@robwormald Any idea how we could move forward without having to fiddle with typings files manually? Or is this resolved by a48 or going to be with a49?

@robwormald Any idea how we could move forward without having to fiddle with typings files manually? Or is this resolved by a48 or going to be with a49?

@rosendi

This comment has been minimized.

Show comment
Hide comment
@rosendi

rosendi Dec 8, 2015

@dsebastien Can you confirm that mocha plays nicely with angular 2 (I switched to jasmine)? Testing library wraps jasmine methods and in the angularconnect session @juliemr said that currently it doesn't support mocha and other testing frameworks.

rosendi commented Dec 8, 2015

@dsebastien Can you confirm that mocha plays nicely with angular 2 (I switched to jasmine)? Testing library wraps jasmine methods and in the angularconnect session @juliemr said that currently it doesn't support mocha and other testing frameworks.

@juliemr

This comment has been minimized.

Show comment
Hide comment
@juliemr

juliemr Dec 8, 2015

Member

That's correct, currently, only Jasmine 2 is fully supported. I'll be working on making this more generic once testing works great with Jasmine 2.

Member

juliemr commented Dec 8, 2015

That's correct, currently, only Jasmine 2 is fully supported. I'll be working on making this more generic once testing works great with Jasmine 2.

@dsebastien

This comment has been minimized.

Show comment
Hide comment
@dsebastien

dsebastien Dec 8, 2015

No I can't, I was just about to try it out. Good to know that it does not work, thanks for the info! ;-)

No I can't, I was just about to try it out. Good to know that it does not work, thanks for the info! ;-)

@lacolaco

This comment has been minimized.

Show comment
Hide comment
@lacolaco

lacolaco Jan 7, 2016

Contributor

👍

Contributor

lacolaco commented Jan 7, 2016

👍

@japhar81

This comment has been minimized.

Show comment
Hide comment
@japhar81

japhar81 Jan 22, 2016

I'm sure @juliemr will let us know when this is officially supported, but in the meantime, I've found two ways to make it work pretty well -- writeup here: http://www.codeitall.com/?p=144

I'm sure @juliemr will let us know when this is officially supported, but in the meantime, I've found two ways to make it work pretty well -- writeup here: http://www.codeitall.com/?p=144

@lacolaco

This comment has been minimized.

Show comment
Hide comment
@lacolaco

lacolaco Jan 29, 2016

Contributor

In beta.2, this issue looks solved to me.

a4b5cb8

Contributor

lacolaco commented Jan 29, 2016

In beta.2, this issue looks solved to me.

a4b5cb8

@japhar81

This comment has been minimized.

Show comment
Hide comment
@japhar81

japhar81 Jan 29, 2016

Typings do appear fixed, but the tests still fail under mocha -- i guess that's expected :)

Typings do appear fixed, but the tests still fail under mocha -- i guess that's expected :)

@alexeagle alexeagle changed the title from Conflict between Mocha and Jasmine typings. to Cannot use Mocha to write angular2 tests Feb 12, 2016

@lacolaco

This comment has been minimized.

Show comment
Hide comment
@lacolaco

lacolaco Apr 27, 2016

Contributor

@juliemr Do you have any plans to enable to use Mocha or other testing frameworks with "angular2/testing" ?

I'll be happy if that module will separate to "angular2/testing/common" and "angualr2/testing/jasmine"

Contributor

lacolaco commented Apr 27, 2016

@juliemr Do you have any plans to enable to use Mocha or other testing frameworks with "angular2/testing" ?

I'll be happy if that module will separate to "angular2/testing/common" and "angualr2/testing/jasmine"

@wesleycho

This comment has been minimized.

Show comment
Hide comment
@wesleycho

wesleycho Jun 8, 2016

Contributor

This should be fairly easy to create separate adapters - basically one would need to duplicate the logic in https://github.com/angular/angular/blob/master/modules/%40angular/core/testing/testing.ts but for the specific platform one chooses. The logic is thin, so this is a pretty accessible task IMO.

Contributor

wesleycho commented Jun 8, 2016

This should be fairly easy to create separate adapters - basically one would need to duplicate the logic in https://github.com/angular/angular/blob/master/modules/%40angular/core/testing/testing.ts but for the specific platform one chooses. The logic is thin, so this is a pretty accessible task IMO.

@juliemr

This comment has been minimized.

Show comment
Hide comment
@juliemr

juliemr Jul 1, 2016

Member

This is now possible in RC4.

Member

juliemr commented Jul 1, 2016

This is now possible in RC4.

@juliemr juliemr closed this Jul 1, 2016

@jakeNiemiec

This comment has been minimized.

Show comment
Hide comment

👌 #9562

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment