Skip to content

Fixes error where app module fails to load in testing #4

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

Merged
merged 5 commits into from
Jun 7, 2016

Conversation

kanhirun
Copy link
Contributor

@kanhirun kanhirun commented Jun 4, 2016

Summary

  • Fixes a known compatibility issue where the app module fails to load in the testing environment (5fa1324, 1.5.0-rc.1 fails to load in PhantomJS 1.x + Karma environment angular/angular.js#13794)
  • Fixes an existing test to be more robust: previously, the assertion would pass on every error which is undesirable. [LOC]
  • Because Karma doesn't officially support PhantomJS, this PR removes its support in favor of Chrome (5ad7664) If you strongly prefer PhantomJS, we can alternatively fix the issue by upgrading to PhantomJS 2.x. [Review]. I'll leave it to you to decide.

Tasks

  • Comment below if you prefer upgrading PhantomJS
  • If this PR is merged, delete the alternative branch: git push origin --delete fixes_ng_module_error_phantomjs_upgrade

Testing

  • Run ./node_modules/.bin/gulp test-src. Is the test passing?
  • Change the assertion message to purposely fail the test , run the test, and observe that it fails with the correct feedback

@kanhirun
Copy link
Contributor Author

kanhirun commented Jun 4, 2016

@bsouthga Ready for review. I've included checkboxes on the PR to test on your machine.

@kanhirun kanhirun changed the title Fixes error where app module cannot be imported Fixes error where app module cannot be imported in testing Jun 6, 2016
@kanhirun kanhirun changed the title Fixes error where app module cannot be imported in testing Fixes error where app module fails to load in testing Jun 6, 2016
@bsouthga
Copy link
Contributor

bsouthga commented Jun 6, 2016

Hey kel, thanks for the PR! really appreciate your detailed description of the issue + your fix. I merged in a travis hook to test this with our CI setup and it seems to fail (as there is no headless chrome available, the one advantage of Phantom) -- any thoughts on a fix for this? We would love to keep the ability to run the automated tests if possible.

@kanhirun kanhirun force-pushed the fixes_ng_module_error branch from 2f0ebba to a813859 Compare June 6, 2016 20:25
@kanhirun
Copy link
Contributor Author

kanhirun commented Jun 6, 2016

New Changes

@bsouthga I've added two commits recently:

  • Fixes existing tests to run as both concatenated and minified (a813859)
  • Because managing competing test frameworks is complex, I've removed support for Mocha in favor of Jasmine. This is preferable because—although the two frameworks have very similar DSL—there are still many possible leaks. For example, toThrowError() is a matcher only valid in Jasmine. (a9da0fc)

Additional Testing

  • ./node_modules/bin/gulp test-dist-concatenated is now passing when previously it had not (see: dfee8b2)
  • ./node_modules/bin/gulp test-dist-minified is now passing as well

I'll look into configuring TravisCI for running Chrome. Thanks for bringing this up. 👍

@kanhirun kanhirun force-pushed the fixes_ng_module_error branch 2 times, most recently from 57389ff to 6a3c5e0 Compare June 7, 2016 01:15
@kanhirun
Copy link
Contributor Author

kanhirun commented Jun 7, 2016

@bsouthga 🎱 says that it's now passing. I squashed those changes on .travis.yml into 470a8e8 (the first commit) so that git-bisect stays effective.

kanhirun added 5 commits June 6, 2016 21:40
When calling `module()` with `inject()`, an error is thrown:
```
Error: [$injector:modulerr] Failed to instantiate module ng due to:
TypeError: 'undefined' is not an object (evaluating
'Function.prototype.bind.apply')
```

PhantomJS is not amongst Karma's officially supported browsers.
In 1.x, `Function.prototype.bind` isn't defined. Instead of polyfilling,
or using Phantom 2.x, it is better to stick with supported browsers.

(In addition, TravisCI has been reconfigured to run Chrome.)

READ MORE:
http://blog.500tech.com/setting-up-travis-ci-to-run-tests-on-latest-google-chrome-version/
The matcher, `toThrowError()` is valid only in Jasmine, and not Mocha.
Managing multiple competing test frameworks is not ideal. Therefore, I
have configured all karma config files to use Jasmine only.
@bsouthga
Copy link
Contributor

bsouthga commented Jun 7, 2016

Looks good to me!

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

Successfully merging this pull request may close these issues.

2 participants