Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Unit test broken after: git checkout -f step-7 #203

Closed
pfee opened this issue Oct 9, 2014 · 4 comments
Closed

Unit test broken after: git checkout -f step-7 #203

pfee opened this issue Oct 9, 2014 · 4 comments

Comments

@pfee
Copy link

pfee commented Oct 9, 2014

I adjusted the browsers line in karma.conf.js to use Firefox rather than Chrome.

I'm following the Angular phonecat tutorial using Fedora 20.
https://code.angularjs.org/1.2.26/docs/tutorial/step_07

Running the unit tests with "npm test" and leaving Firefox open shows the effect of each git checkout step. The tests pass for steps 1 to 6, but start failing at step 7.

Error message:
Error: [ng:areq] Argument 'PhoneListCtrl' is not a function, got undefined

Proposed one line fix for controllersSpec.js:

diff --git a/test/unit/controllersSpec.js b/test/unit/controllersSpec.js
index a755e4a..a929b3f 100644
--- a/test/unit/controllersSpec.js
+++ b/test/unit/controllersSpec.js
@@ -6,7 +6,7 @@ describe('PhoneCat controllers', function() {
describe('PhoneListCtrl', function(){
var scope, ctrl, $httpBackend;

  • beforeEach(module('phonecatApp'));
  • beforeEach(module('phonecatControllers'));
    beforeEach(inject(function($httpBackend, $rootScope, $controller) {
    $httpBackend = $httpBackend;
    $httpBackend.expectGET('phones/phones.json').

There are additional failures in further steps - but let's start by fixing this step before tackling others.

Firefox version: 32.0.2
$ node_modules/bower/bin/bower list
bower check-new Checking for new versions of the project dependencies..
angular-phonecat#0.0.0 /angular-phonecat
├── #1.2.26 (1.2.27-build.512+sha.e713f36 available, latest is 1.3.0-rc.5)
├─┬ angular-animate#1.2.26 extraneous (1.2.27-build.512+sha.e713f36 available, latest is 1.3.0-rc.5)
│ └── #1.2.26 (latest is 1.3.0-rc.5)
├─┬ angular-mocks#1.2.26 (1.2.27-build.512+sha.e713f36 available, latest is 1.3.0-rc.5)
│ └── #1.2.26
├─┬ angular-resource#1.2.26 extraneous (1.2.27-build.512+sha.e713f36 available, latest is 1.3.0-rc.5)
│ └── #1.2.26
├─┬ angular-route#1.2.26 (1.2.27-build.512+sha.e713f36 available, latest is 1.3.0-rc.5)
│ └── #1.2.26
├─┬ bootstrap#3.1.1 (latest is 3.2.0)
│ └── jquery#1.10.2 (2.1.1 available)
└── jquery#1.10.2 (latest is 2.1.1)

@pfee
Copy link
Author

pfee commented Oct 9, 2014

Diff got mangled by markdown, second attempt:

diff --git a/test/unit/controllersSpec.js b/test/unit/controllersSpec.js
index a755e4a..a929b3f 100644
--- a/test/unit/controllersSpec.js
+++ b/test/unit/controllersSpec.js
@@ -6,7 +6,7 @@ describe('PhoneCat controllers', function() {
   describe('PhoneListCtrl', function(){
     var scope, ctrl, $httpBackend;

-    beforeEach(module('phonecatApp'));
+    beforeEach(module('phonecatControllers'));
     beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) {
       $httpBackend = _$httpBackend_;
       $httpBackend.expectGET('phones/phones.json').

@pfee
Copy link
Author

pfee commented Oct 9, 2014

Clearing out the entire project and fetching again from github, the test works again.

Could Firefox be caching old files? When running unit tests, file changes are detected and the tests repeated. However if clearing the project and starting again from scratch has an impact, perhaps caching is leading to false failures.

Has this been seen before?

@pfee
Copy link
Author

pfee commented Oct 10, 2014

Having looked at karma setup, could this issue have been caused by the order in which JavaScript files were pushed to the browser?

The "files" section includes:

      'app/js/**/*.js',
      'test/unit/**/*.js'

This should load files in alphabetic order. Perhaps the karma.conf.js file should list files in a specific order, so that app.js is loaded before controllers.js.

@pfee pfee closed this as completed Oct 27, 2014
@pfee
Copy link
Author

pfee commented Oct 27, 2014

Closed issue, since starting from a fresh git checkout worked. Blaming this on cache side effects.

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

No branches or pull requests

1 participant