ngbp / ngbp

A sophisticated build management system for web apps (formerly ng-boilerplate). Created by @joshdmiller
http://bit.ly/ngBoilerplate
MIT License
3.93k stars 1.04k forks source link

Warning: Task "karma:continuous" failed. #268

Open csojka-sf opened 10 years ago

csojka-sf commented 10 years ago
Running "karma:continuous" (karma) task
INFO [karma]: Karma v0.12.16 server started at http://localhost:9018/
INFO [launcher]: Starting browser Firefox
WARN [watcher]: Pattern "/Users/myUsername/Documents/code/myProjectName/myProjectName/src/**/*.coffee" does not match any file.
INFO [Firefox 29.0.0 (Mac OS X 10.9)]: Connected on socket 6kSvzGu3Dm8k5VvI0Bkk with id 60595103
Firefox 29.0.0 (Mac OS X 10.9) AppCtrl isCurrentUrl should pass a dummy test FAILED
    minErr/<@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:78
    loadModules/<@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:3810
    forEach@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:323
    loadModules@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:3775
    createInjector@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:3715
    workFn@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular-mocks/angular-mocks.js:2142

    minErr/<@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:78
    loadModules/<@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:3810
    forEach@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:323
    loadModules@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:3775
    createInjector@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular/angular.js:3715
    workFn@/Users/myUsername/Documents/code/myProjectName/myProjectName/vendor/angular-mocks/angular-mocks.js:2142
csojka-sf commented 10 years ago

getting an "Uncaught object" on line 78 in vendor/angular/angular.js:78 when I visit the build/index.html file as well.

4eek commented 10 years ago

I am getting the same error from TravisCI when doing a direct repo copy and Travis build.

Running default grunt task on the the same code on my local OSX system works fine. Push to Travis fails with above error message.

4eek commented 10 years ago

The problem is that "placeholders" in the "vendor" folder is git ignored. As a quick fix I just created a lib folder and moved it there while also updating the build.config.js file and committing to repo.

evanhobbs commented 10 years ago

I'm getting a similar problem after I tried to integrate this with Ionic Framework. It builds and compiles fine it I use --force. But karma fails. I'm basically, not entirely sure how to interpret what the error message is saying? Line 9007 of Ionic is the minErr function from angular (which is included in the file)

Running "karma:continuous" (karma) task
INFO [karma]: Karma v0.12.16 server started at http://localhost:9018/
INFO [launcher]: Starting browser Firefox
WARN [watcher]: Pattern "/Users/evanhobbs/opt/clients/browser/src/mobile/src/**/*.coffee" does not match any file.
connect: res.headerSent: use standard res.headersSent
INFO [Firefox 29.0.0 (Mac OS X 10.9)]: Connected on socket d9bbgewkwSXDech_zPjw with id 74347692
Firefox 29.0.0 (Mac OS X 10.9) AppCtrl isCurrentUrl should pass a dummy test FAILED
  minErr/<@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:9007
  loadModules/<@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12580
  forEach@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:9232
  loadModules@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12545
  createInjector@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12485
  workFn@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/angular-mocks/angular-mocks.js:2144

  minErr/<@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:9007
  loadModules/<@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12580
  forEach@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:9232
  loadModules@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12545
  createInjector@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12485
  workFn@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/angular-mocks/angular-mocks.js:2144

Firefox 29.0.0 (Mac OS X 10.9) about section should have a dummy test FAILED
  minErr/<@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:9007
  loadModules/<@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12580
  forEach@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:9232
  loadModules@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12545
  createInjector@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12485
  workFn@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/angular-mocks/angular-mocks.js:2144

Firefox 29.0.0 (Mac OS X 10.9) home section should have a dummy test FAILED
  minErr/<@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:9007
  loadModules/<@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12580
  forEach@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:9232
  loadModules@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12545
  createInjector@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/ionic/js/ionic.bundle.js:12485
  workFn@/Users/evanhobbs/opt/clients/browser/src/mobile/vendor/angular-mocks/angular-mocks.js:2144

Firefox 29.0.0 (Mac OS X 10.9): Executed 3 of 3 (3 FAILED) ERROR (0.024 secs / 0.014 secs)
Warning: Task "karma:continuous" failed. Used --force, continuing.
dopatraman commented 9 years ago
PhantomJS 1.9.2 (Mac OS X): Executed 0 of 0 ERROR (0.126 secs / 0 secs)
Warning: Task "karma:continuous" failed. Use --force to continue.

None of my tests are passing. Why is this?

joshdmiller commented 9 years ago

@dopatraman This seems unrelated to the current issue as none of your unit tests are even running. Are you sure the jsunit array includes a glob that captures your tests?

dopatraman commented 9 years ago

Is jsunit a property of the karma.conf.js file?

joshdmiller commented 9 years ago

Sorry. It's in build.config.js, which contains all the config for the build. By default, the tests are included, but if you follow another pattern you'll have to change the variable.

dopatraman commented 9 years ago

How is this property accessed by karma?

I've changed the boilerplate considerably, since there are many features i was not using. I still use karma:continuous. Can I add a jsunit property to this task?

joshdmiller commented 9 years ago

The karma config is a template processed by grunt (line 399 and line 620). Basically, grunt determines the files to include dynamically with each new build so you don't have to do it twice.

dopatraman commented 9 years ago

I see. What would help is to know the exact line of code that runs the tests. For example, when i run karma start <config_file> I get this output:

INFO [karma]: Karma v0.9.8 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [launcher]: Starting browser Firefox
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket id wgumaRTd0leEiyNRY8K0
INFO [Firefox 27.0.0 (Mac OS X 10.9)]: Connected on socket id xywbXZoBiSiiPHZsY8K1
INFO [Chrome 38.0.2125 (Mac OS X 10.9.2)]: Connected on socket id kSkshWFl0cAhS7k8Y8K2

But all this does is open a browser window. It does not run any tests. How do I actually run the tests?

dopatraman commented 9 years ago

(I'd like to run this through karma:continuous eventually)

joshdmiller commented 9 years ago

Karma should be started through grunt karma:continuous, but it's done automatically when you call grunt build or grunt watch.

dopatraman commented 9 years ago

karma:continuous throws the errors I mentioned above. I'm starting to think there is something up with my config file since ive changed it considerable. This is what it looks like now:

module.exports = function(karma) {
    karma.set({
        /** 
         * From where to look for files, starting with the location of this file.
         */
        basePath: '../',

        /**
         * This is the list of file patterns to load into the browser during testing.
         */
        files: [ <% scripts.forEach(function(file) { %> '<%= file %>', <%
            }); %>
        ],

        exclude: [
            'src/**/*.fixture.*',
            'src/**/*.scenario.*',
            'src/scenarios/**/*.*',
            'src/scenarios/**/*.*'
        ],

        frameworks: ['jasmine'],
        proxies: {
            '/': 'http://localhost'
        },
        plugins: ['karma-jasmine', 'karma-firefox-launcher', 'karma-chrome-launcher', 'karma-coffee-preprocessor', 'karma-phantomjs-launcher'],
        preprocessors: {
            '**/*.coffee': 'coffee'
        },

        /**
         * How to report, by default.
         */
        reporters: 'dots',

        /**
         * On which port should the browser connect, on which port is the test runner
         * operating, and what is the URL path for the browser to use.
         */
        port: 9018,
        runnerPort: 9100,
        urlRoot: '/',

        /** 
         * Disable file watching by default.
         */
        autoWatch: false,

        /**
         * The list of browsers to launch to test on. This includes only "Firefox" by
         * default, but other browser names include:
         * Chrome, ChromeCanary, Firefox, Opera, Safari, PhantomJS
         *
         * Note that you can also use the executable name of the browser, like "chromium"
         * or "firefox", but that these vary based on your operating system.
         *
         * You may also leave this blank and manually navigate your browser to
         * http://localhost:9018/ when you're running tests. The window/tab can be left
         * open and the tests will automatically occur there during the build. This has
         * the aesthetic advantage of not launching a browser every time you save.
         */
        browsers: [
            'Firefox',
            'PhantomJS'
        ]
    });
};

All files concatenated into the built karma-continuous.js are existing paths.

joshdmiller commented 9 years ago

To make it a little easier, can you throw me a diff?

dopatraman commented 9 years ago

I should rephrase. I've changed the files included in the files:[] array. The actual config file has changed very little. All file paths included are existing paths.

joshdmiller commented 9 years ago

The files array is populated automatically by grunt. You should revert the changes to keep it in that spirit, or else you always be tracking test files in karma.js and gruntfile.js. In addition, your problem would be outside the scope of ngbp.

dopatraman commented 9 years ago

i see. do you have any idea on how karma actually goes about running the tests? I cannot find anything in documentation etc.

dopatraman commented 9 years ago

I found this: http://karma-runner.github.io/0.8/plus/RequireJS.html

At the bottom it says you can run tests manually with the comman

karma run

However, when i do this I get this output:

INFO [karma]: Delaying execution, these browsers are not ready: PhantomJS 1.9.7 (Mac OS X), Firefox 27.0.0 (Mac OS X 10.9), Chrome 38.0.2125 (Mac OS X 10.9.2)
joshdmiller commented 9 years ago

I'm not entirely sure what you mean, but karma is a generic runner that is responsible for spinning up the appropriate teat environment. It start a server on a specified port, creates a basic Jasmine environment (in this case; could be mocha too), and launches a browser to that generated test page. It then reports the results in the console.

This abstraction is managed through the karma.config.js file that is passed to it. That contains everything we need to configure what karma does, but the value proposition of karma is that we don't need to care how it runs the tests.

In ngbp, we have that config file be a template that we can manage dynamically. This is necessary because we package our unit tests with our code and need to tease them out using globbing patterns, and because we want to include vendor files that both the build and karma need to have knowledge of.

You cannot run karma manually with ngbp because of this. In addition, there is no reason you would ever need to do that because we can accomplish the same thing with the existing grunt commands.

Back to the original question, revert the changes to the config file and then ensure your tests are picked up by the build through that jsunit array. If they are, we need to look other places for the problem. If not, that's the issue.

But confirm that first.

dopatraman commented 9 years ago

My config does not have a jsunit array. But this does not seem to have affected how/if the unit tests ran. Can you please walk me through step by step how the unit tests are set up and run in ngbp?

joshdmiller commented 9 years ago

I unfortunately don't have that much time, but the code is very heavily documented.

If you don't have a jsunit array in your build.config.js, then something is very wrong. Here's what I mean.

The Gruntfile.js contains absolutely everything that happens. Here's what the build task does.

You can see that before it runs karma:continues, it runs karmaconfig, which is configured here. This dynamically creates the config file.

The actual karma tasks are configured here.

Everything else that happens is from Karma and the grunt-karma plugin, and ngbp takes them as a given.

I don't know why you need the step by step, but it involves knowledge of Node/NPM, Grunt, Karma, and ngbp, three of the four of which are out of scope for a bug report. ngbp unit tests work out of the box. They will always work if the convention is followed.

Anyway, something in your ngbp is broken and doesn't match the upstream version and I can't see your code. Revert to the build.config.js, Gruntfile.js, and karma/karma-unit.tpl.js from upstream and see if it works. If not, that error message is something I can help with.

PaulL1 commented 9 years ago

You can also try grunt build --verbose, which usually writes out what files karma has been told to run by grunt. If you've broken your grunt config somewhere that will be empty (which is what I deduce from your error message already anyway, since it's run 0 of 0 tests, which means it got no config). But the verbose option may help you to diagnose what's going on.

euasier commented 8 years ago

I had the same problem. I solved it adding vendor/placeholders/angular-placeholders-0.0.1-SNAPSHOT.min.js to my ngBoilerPlate project GitHub repository.

This is a dependency not managed by bower, is not included in bower.json file.