computmaxer / karma-jspm

Other
74 stars 52 forks source link

karma v1.0.0: You need to include some adapter that implements __karma__.start method! #162

Closed SerkanSipahi closed 8 years ago

SerkanSipahi commented 8 years ago

After upgrading our project from karma v0.13.22 to v.1.0.0 we get following error: You need to include some adapter that implements __karma__.start method!

package.json:

...
"jspm": "0.17.0-beta.19",
"karma": "1.0.0",
"karma-jspm": "2.1.1",
...

see relate issue: https://github.com/karma-runner/karma/issues/2194

Mobiletainment commented 8 years ago

I've got the very same error using karma v1.0.0, karma-jspm v2.1.1, jspm v0.16.39 and jasmine v2.4.1 on Windows 10.

This is my current karma.conf.js:

        basePath: './',

        // frameworks to use
        // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
        frameworks: ['jspm', 'jasmine'],

        plugins: [
            'karma-jspm',
            'karma-jasmine',
            "karma-coverage",
            'karma-phantomjs-launcher',
            'karma-chrome-launcher'
        ],

        proxies: {
            "/app": "/base/app",
            "/node_modules": "/base/node_modules",
            '/jspm_packages/': '/base/jspm_packages/'
        },

        files: [],

        jspm: {
            serveFiles: [
                "app/**/*.js"
            ],
            loadFiles: ["jspm_packages/system-polyfills.js", "app/**/*.test.js"]
        },

        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {

        },

        // test results reporter to use
        // possible values: 'dots', 'progress'
        // available reporters: https://npmjs.org/browse/keyword/karma-reporter
        reporters: ['progress', "coverage"],

        // web server port
        port: 9876,

        // enable / disable colors in the output (reporters and logs)
        colors: true,

        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_INFO,

        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        // start these browsers
        // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
        browsers: ['Chrome'],

        // Continuous Integration mode
        // if true, Karma captures browsers, runs the tests and exits
        singleRun: false,

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: 

And that's the karma output:

26 06 2016 20:14:48.731:INFO [karma]: Karma v1.0.0 server started at http://localhost:9876/
26 06 2016 20:14:48.734:INFO [launcher]: Launching browser Chrome with unlimited concurrency
26 06 2016 20:14:48.765:INFO [launcher]: Starting browser Chrome
26 06 2016 20:14:49.522:INFO [Chrome 51.0.2704 (Windows 10 0.0.0)]: Connected on socket /#81mT1KQNFgq4aYilAAAA with id 48329600
Chrome 51.0.2704 (Windows 10 0.0.0) ERROR
  You need to include some adapter that implements __karma__.start method!

Any suggestions on how to get it up and running?

togakangaroo commented 8 years ago

Same issue.

I've even gone so far as to place some console.log statments in karma-jspm/src/init.js. It looks like files is getting modified properly but when I look at the generated debug page there's basically nothing being included.

Is there perhaps a change lately in karma where files is cloned before being passed in?

I'm also on win10 but not on jspm 17

 14   "dependencies": {
 15     "express": "^4.13.4",
 16     "jspm": "^0.16.36",
 17     "mocha": "^2.5.3"
 18   },
 19   "jspm": {
 20     "directories": {
 21       "baseURL": "public"
 22     },
 23     "dependencies": {
 24       "moment": "npm:moment@^2.13.0",
 25       "virtual-dom": "npm:virtual-dom@^2.1.1"
 26     },
 27     "devDependencies": {
 28       "babel": "npm:babel-core@^5.8.24",
 29       "babel-runtime": "npm:babel-runtime@^5.8.24",
 30       "core-js": "npm:core-js@^1.1.4"
 31     }
 32   },
 33   "devDependencies": {
 34     "chai": "^3.5.0",
 35     "karma": "^1.0.0",
 36     "karma-chai": "^0.1.0",
 37     "karma-chrome-launcher": "^1.0.1",
 38     "karma-jspm": "^2.1.1",
 39     "karma-mocha": "^1.0.1",
 40     "karma-mocha-reporter": "^2.0.4"
 41   }
Mobiletainment commented 8 years ago

just updated to karma v1.1.0, same error here...

togakangaroo commented 8 years ago

Odd....I put in the files that we wanted manually into the files array and...same issue.

If I leave the files array populated manually and then remove the jspm plugin it works (sort of, there's a different error but the right files are loaded)

So definitely some issue with what karma-jspm does to files

I'm thinking karma 1.0 changed its DI structure. Here's what karma-requirejs looks like currently

Whereas here is karma-jspm. Note we're not doing any $Inject properties

togakangaroo commented 8 years ago

Ok, nevermind that, I do see the $inject confusingly in the separate index.js file. No clue what whats going on then.

RIAstar commented 8 years ago

The problem seems to be related to the duplicate referencing of system[.src].js and system-polyfills[.src].js files.

I patched init.js like below and it works as expected.

Replace

var jspmPattern = createServedPattern(packagesPath + '**/*', {nocache: jspm.cachePackages !== true});
    jspmPattern.watched = false;
files.push(jspmPattern);

with

  ['github/**/*', 'npm/**/*', 'system-polyfills.js'].forEach(function (pattern) {
    var jspmPattern = createServedPattern(packagesPath + pattern, jspm.cachePackages !== true);
    jspmPattern.watched = false;
    files.push(jspmPattern);
  });

That's a bit too ugly to make into a PR though. Also I'm not exactly sure what's going on under the hood yet.

m-a-r-c-e-l-i-n-o commented 8 years ago

Similar to @RIAstar 's line of thinking, I believe that the root issue is that the current implementation overwrites the system-polyfills.src.js and system.src.js "included" attribute which is set here, which is a necessary attribute that tells Karma to include files in script tags as appose to just serving them. If this is true, then an internal error in adapter.js is likely happening because system.src.js was never "included" just "served". We don't see this error because it is likely being swallowed by Karma, and propagating itself as a missing adapter, even though the adapter itself has no fault. I can't prove this yet (although I did spent an hour or so trying just now), it this requires more time — crawling the internals of Karma. At any rate, I just submitted a pr, it's a bit cleaner than the implementation above. I don't see why this shouldn't be merged.

rolandjitsu commented 8 years ago

What is the status on this?

maxwellpeterson-wf commented 8 years ago

Fixed in #167, released in karma-jspm 2.2.0.

Sorry, this issue should have gotten closed!

tamird commented 8 years ago

This still reproduces with karma 1.1.1 and karma-jspm 2.2.0:

karma start
13 07 2016 11:17:50.303:INFO [karma]: Karma v1.1.1 server started at http://localhost:9876/
13 07 2016 11:17:50.306:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
13 07 2016 11:17:50.315:INFO [launcher]: Starting browser PhantomJS
13 07 2016 11:17:50.828:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#JUEZe94l54U6Mzd6AAAA with id 26557043
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  You need to include some adapter that implements __karma__.start method!
rolandjitsu commented 8 years ago

Same here, that is why I asked. But I have other plugins and I though one of those may be cause that.

m-a-r-c-e-l-i-n-o commented 8 years ago

@rolandjitsu @tamird There are other plugins that might be causing this issue (i.e. chai). I suspect that PhantomJS might be adding to the mix as well. What happens when you run it without PhantomJS (perhaps try it with the chrome launcher only) or chai plugins? Is the issue still there? I was the one that submitted the pr for this, and as far as I can tell, karma-jspm is in the clear.

rolandjitsu commented 8 years ago

My only karma plugins are:

{
    "karma-chrome-launcher": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jspm": "^2.2.0",
    "karma-sauce-launcher": "^1.0.0",
    "karma-spec-reporter": "^0.0.26"
}

It can be either of sauce, spec-reporter or jasmine. I will try to see if I remove them I still get the error.

rolandjitsu commented 8 years ago

I think there is still an issue with this plugin. I removed it and tried to run karma and it works without karma-jspm.

Actually none of the other plugins cause this kind of error message, it is only when I leave this plugin enabled that I get the error.

m-a-r-c-e-l-i-n-o commented 8 years ago

@rolandjitsu Thank you for the feedback. Upon further investigation, it does appear that the pr I submitted for this issue is accurate. However, I did identify a related bug inside Karma and submitted a pr to them accordingly. Knowing what I know now, I think it's safe to say that your issue is likely do to your file patterns amounting to duplicates, which (I speculate) is only present when you have karma-jspm on, since that's when those files get attached. But it's not karma-jspm's fault (even though it was initially triggering the symptom by including duplicate files) or yours, Karma should be able to handle that without issues. To verify if this is the case or not, please install my fork of Karma and see what happens. At the very least, you should see another error other than "You need to include some adapter that implements __karma__.start method!" and if that is the case, kindly post the new error!

@tamird Install my fork of Karma and let me know if you see anything different.

tamird commented 8 years ago

Tried it, and got:

karma start
13 07 2016 17:10:39.053:INFO [karma]: Karma v1.1.1 server started at http://localhost:9876/
13 07 2016 17:10:39.056:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
13 07 2016 17:10:39.069:INFO [launcher]: Starting browser PhantomJS
13 07 2016 17:10:39.493:WARN [web-server]: 404: /Users/tamird/src/go/src/github.com/cockroachdb/cockroach/ui/node_modules/karma/static/karma.js
m-a-r-c-e-l-i-n-o commented 8 years ago

@tamird You have to build the karma project, cd into its directory and do npm run build. If you have further issues on that end, just install Karma as you normally would from npm or something, and replace this line with if (other && byPath(other, p) < 0) return.

tamird commented 8 years ago

OK, I applied the patch locally and things worked (mostly):

karma start
13 07 2016 17:55:04.013:INFO [karma]: Karma v1.1.1 server started at http://localhost:9876/
13 07 2016 17:55:04.016:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
13 07 2016 17:55:04.030:INFO [launcher]: Starting browser PhantomJS
13 07 2016 17:55:04.494:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#CIS5lu6wtMRV_FfVAAAA with id 46941066
13 07 2016 17:55:04.591:WARN [web-server]: 404: /base/jspm_packages/system-polyfills.js
PhantomJS 2.1.1 (Mac OS X 0.0.0) WARN: 'TypeScript', 'transpiling to CommonJS, consider setting module: "system" in typescriptOptions to transpile directly to System.register format'

PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 140 of 140 SUCCESS (0.532 secs / 0.335 secs)

Note the 404 warning which is a bit concerning.

m-a-r-c-e-l-i-n-o commented 8 years ago

@tamird Not sure why your setup is requesting system-polyfills.js instead of system-polyfills.src.js, but either way, it might be an unrelated configuration issue, see #91. If you still can't figure it out after reading that, open up another issue. Best of luck!

tamird commented 8 years ago

@m-a-r-c-e-l-i-n-o indeed, that warning is emitted even in the earlier version of karma, so that's unrelated. In any case, your patch upstream fixes karma 1.1.1 for me.

rolandjitsu commented 8 years ago

@m-a-r-c-e-l-i-n-o I still think this issue should still be opened. As I stated before, once I enable karma-jspm, I still get:

16 07 2016 12:35:21.399:INFO [karma]: Karma v1.1.1 server started at http://localhost:9876/
16 07 2016 12:35:21.401:INFO [launcher]: Launching browser Chrome with unlimited concurrency
16 07 2016 12:35:21.407:INFO [launcher]: Starting browser Chrome
16 07 2016 12:35:22.421:INFO [Chrome 52.0.2743 (Mac OS X 10.11.5)]: Connected on socket /#IVdPwbkz9LroSpojAAAA with id 67492651
Chrome 52.0.2743 (Mac OS X 10.11.5) ERROR
  You need to include some adapter that implements __karma__.start method!

Chrome 52.0.2743 (Mac OS X 10.11.5): Executed 0 of 0 ERROR (0.041 secs / 0 secs)

And I have checked that none of the other plugins I use cause this. As for duplicate files, I do not have any, I barely have 3 files.

tamird commented 8 years ago

@rolandjitsu https://github.com/karma-runner/karma/pull/2255