Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate test cases into mocha test runner #1545

Merged
merged 3 commits into from
Mar 29, 2016

Conversation

kwonoj
Copy link
Member

@kwonoj kwonoj commented Mar 29, 2016

Description:

This PR's effort to track #1460, migrate test runner from jasmine to mocha (https://mochajs.org/) with chai for assertion suite, sinon for mocking.

PR contains amount of file changes, major changes are below.

  • use mocha as test runner
  • migrate global assertion patching in test-helper into mocha's custom interface by mocha's designed behavior of having separate global context per test suite
  • update test coverage, marble diagram test accordingly
  • now test coverage execution on CI is moved into optional phase completely, will make bit faster build turnaround time
  • fixes couple of tests similar to Fix a few tests #1536

Related issue (if exists):
#1460

NOTE

: This PR doesn't migrate browser test. Current test environment using mocha with custom interfaces makes bit hard to easier migration of karma test configuration, haven't found simple solution yet.

/cc @staltz for visibility & comment.

- migrate global assertion patch into mocha custom interface
: mocha creates global context per each test suite, simple global patching won't work
expect(Notification).toBeDefined();
expect(typeof Notification).toBe('function');
expect(Notification).exist;
expect(Notification).to.be.a('function');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, I'm sorry you had to go through each of these assertions. Could have used something like https://github.com/crysalead-js/chai-jasmine. Did you try that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was aware but didn't tempted quite especially given repo is somewhat inactive state. Updating assertion actually wasn't that hard, just simple replace.

@benlesh
Copy link
Member

benlesh commented Mar 29, 2016

Holy crap! Nice work.


const diagramFunction = global.asDiagram;

//mocha creates own global context per each test suite, simple patching to global won't deliver its context into test cases.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If mocha is creating it's own global context, should we be adding rxTestScheduler, hot, cold, etc to this context? Or are you doing this already and I'm not seeing it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rxTestscheduler is set up in https://github.com/ReactiveX/rxjs/pull/1545/files#diff-044a0fafe3ba4e4178acb8de9fb82252R90. Actually that's interesting question, what I found of mocha's global context is it doesn't allow patching existing interfaces (i.e, it, etcs..) cause its interface constructs it everytime per test suite, as you can see in this implementation. Other global instance seems not being affected. Maybe my word on comment is somewhat misleading that all global contexts are completely ignored..

@benlesh
Copy link
Member

benlesh commented Mar 29, 2016

Looks good overall, just left a note to spur discussion about where rxTestScheduler should live (don't take my comments and run with them, I just want to discuss it).

As far as I'm concerned, :shipit: ship it. I couldn't be happier to get rid of Jasmine.

@kwonoj
Copy link
Member Author

kwonoj commented Mar 29, 2016

As far as I'm concerned, :shipit: ship it. I couldn't be happier to get rid of Jasmine.

: Cool. Let me do this in this way then - check in this change first, then refactor custom interface per suggestion. It's bit hard to play with this PR since it contains too many files. :) Thanks for reviewing!

@kwonoj
Copy link
Member Author

kwonoj commented Mar 29, 2016

Merged with a1687c3, say goodbye to jasmine and have ☕ .

@Blesh , @staltz , @david-driscoll , @saneyuki , @trxcllnt ... this requires npm install once again to trigger. test. Just fyi, test execution time hasn't been changed and nearly identical.

@lock
Copy link

lock bot commented Jun 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants