lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

You need to include some adapter that implements __karma__.start method! #267

Closed mcanfield closed 6 years ago

mcanfield commented 6 years ago

Hiya @lathonez,

I've followed your blog article for adding unit testing to a pre-existing Ionic project. I've copied the configurations and dependencies verbatim from the repo. When I try to npm test I get the following output:

> become@0.0.1 test /Users/mcanfield/projects/bcc/ionic
> ng test

 10% building modules 1/1 modules 0 active16 09 2017 22:21:57.829:WARN [karma]: No captured browser, open http://localhost:9876/
16 09 2017 22:21:57.847:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
16 09 2017 22:21:57.847:INFO [launcher]: Launching browser ChromeNoSandbox with unlimited concurrency
16 09 2017 22:21:57.867:INFO [launcher]: Starting browser Chrome
[../../../../../src recursive \.spec\.ts$] ./src \.spec\.ts$ 320 bytes {main} [built]
[../../../../../src/polyfills.ts] ./src/polyfills.ts 2.66 kB {polyfills} [built]
[../../../../../src/test.ts] ./src/test.ts 2.92 kB {main} [built]
[../../../../ionic-angular/index.js] ./node_modules/ionic-angular/index.js 8.53 kB {vendor} [built]
[../../../../ionic-mocks/dist/index.js] ./node_modules/ionic-mocks/dist/index.js 308 bytes {vendor} [built]
[../../../../zone.js/dist/async-test.js] ./node_modules/zone.js/dist/async-test.js 3.23 kB {vendor} [built]
[../../../../zone.js/dist/fake-async-test.js] ./node_modules/zone.js/dist/fake-async-test.js 14 kB {vendor} [built]
[../../../../zone.js/dist/jasmine-patch.js] ./node_modules/zone.js/dist/jasmine-patch.js 6.36 kB {vendor} [built]
[../../../../zone.js/dist/long-stack-trace-zone.js] ./node_modules/zone.js/dist/long-stack-trace-zone.js 6.22 kB {vendor} [built]
[../../../../zone.js/dist/proxy.js] ./node_modules/zone.js/dist/proxy.js 5.6 kB {vendor} [built]
[../../../../zone.js/dist/sync-test.js] ./node_modules/zone.js/dist/sync-test.js 1.41 kB {vendor} [built]
[../../../core/@angular/core/testing.es5.js] ./node_modules/@angular/core/@angular/core/testing.es5.js 36.8 kB {vendor} [built]
[../../../forms/@angular/forms.es5.js] ./node_modules/@angular/forms/@angular/forms.es5.js 203 kB {vendor} [built]
[../../../platform-browser-dynamic/@angular/platform-browser-dynamic/testing.es5.js] ./node_modules/@angular/platform-browser-dynamic/@angular/platform-browser-dynamic/testing.es5.js 3.82 kB {vendor} [built]
   [0] multi ./src/polyfills.ts 28 bytes {polyfills} [built]
    + 693 hidden modules

WARNING in ./node_modules/ionic-angular/util/ng-module-loader.js
54:11-36 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/ionic-angular/util/ng-module-loader.js
69:11-36 Critical dependency: the request of a dependency is an expression
16 09 2017 22:22:07.664:WARN [karma]: No captured browser, open http://localhost:9876/
16 09 2017 22:22:07.887:INFO [Chrome 60.0.3112 (Mac OS X 10.12.5)]: Connected on socket Whc25WWvOvh5W_sjAAAA with id 37765520
Chrome 60.0.3112 (Mac OS X 10.12.5) ERROR
  You need to include some adapter that implements __karma__.start method!
Chrome 60.0.3112 (Mac OS X 10.12.5) ERROR
  You need to include some adapter that implements __karma__.start method!

My package.json only differs in the additional dependencies my project requires. I've reinstalled everything multiple times. I've tried debugging to spot any noticeable issues. No luck thus far.

Do you have any troubleshooting tips for helping me solve this? Thanks!

mcanfield commented 6 years ago

Here is a debug log: https://gist.github.com/mcanfield/39ef9a0dec1fe6fca2e6a948789455a7

lathonez commented 6 years ago

Hey,

Unfortunately it's a very generic error. Most probably you've named karma.conf.js incorrectly or the contents of that file are incorrect.

Suggest the general debug advice:

Let me know how you go.

Thanks

mcanfield commented 6 years ago

Hi @lathonez thanks for the reply. Unfortunately I did go through the general debug advice before posting the issue. I copy/pasted all the config files verbatim (only removing references to clicker). The above gist has 2 log outputs, the first is from my setup the second is from lathonez/clicker. Yours works, mine doesn't.

My general project structure is the same. All my template url's contain ./<template>.html. To reduce complexity I've removed all specs from the suite except one. The only project config differences are in package.json, but those are product dependencies so the differences are as to be expected. I do have a custom ionic webpack.config.js, that shouldn't matter but I removed it temporarily anyway.

The Chrome instance that is launched contains my project file and specs under the webpack:// source. So karma is working up to that point. The only difference between mine and clicker is that clicker has its files successfully being served under the source ng://.

lathonez/clicker files screen shot 2017-09-18 at 9 21 50 am

mcanfield/project files screen shot 2017-09-18 at 10 04 28 am

Google also came back with the lamenting reply that this is a generic error. From looking through the karma source code it's clear that the jasmine framework isn't overriding the default __karma__.start global reference, causes the default function to spit out You need to include some adapter that implements __karma__.start method!.

Since nothing jumps out at you I'll rinse and repeat a couple times and explore the track of why jasmine's karma.start function isn't overriding the default karma.start. Worse case, I'll start porting my app piece by piece into a working unit test setup.

Thanks again!

lathonez commented 6 years ago

@mcanfield - can I pull clone the project and have a look or is it closed source?

mcanfield commented 6 years ago

@lathonez it is private source currently, but will one day be open source. If you have a gitlab account I can give you access, or email you a tarball. Sorry, been super busy last couple days. Thanks for offering.

lathonez commented 6 years ago

Sorry I didn't get back to you. My (free) time only contributes to FOSS.

Happy to discuss contracting.

lathonez commented 6 years ago

If you ended up solving this somehow, please share the solution!

mcanfield commented 6 years ago

Heya @lathonez no worries. It's only private right now due to how the agency develops software, it will by necessity be FOSS. If you knew who, you'd understand better. In any case, I did not find a resolution and have put the project on the back burner. Maybe things will magically start working once I fire it back up, or Ionic will finally treat testing as a first class citizen... now that's a thought 😃 ! In any case, thank you so much for the triage and follow up!