question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't resolve all parameters for LocalStorageService: (?).

See original GitHub issue

@PillowPillow, apologies, if this has been solved in another ticket - I looked through them but couldn’t find an answer.

Versions (please complete the following information):

  • NgxWebstorage: [e.g. 3.0.0-beta.14]
  • Angular: [e.g. 7.1.1]

Describe the bug I cannot create tests for components which import my project’s StorageService (which internally imports LocalStorageService and SessionStorageService). Angular dependency injection needs them to be imported into the spec file or else it throws a ‘missing providers’ error. However, I end up with the following error when I do import them:

Failed: Can't resolve all parameters for LocalStorageService: (?).
        error properties: Object({ ngSyntaxError: true })
        Error: Can't resolve all parameters for LocalStorageService: (?).
            at syntaxError (dist/vendor/@angular/compiler/bundles/compiler.umd.js:2497:21)
            at CompileMetadataResolver._getDependenciesMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18746:39)
            at CompileMetadataResolver._getTypeMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18639:30)
            at CompileMetadataResolver._getInjectableTypeMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18861:25)
            at CompileMetadataResolver.getProviderMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18870:26)
            at eval (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18808:53)
            at <Jasmine>
            at CompileMetadataResolver._getProvidersMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18768:23)
            at CompileMetadataResolver.getNonNormalizedDirectiveMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18245:34)
            at CompileMetadataResolver._getEntryComponentMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18842:32)
            at eval (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18833:35)
            at <Jasmine>
            at CompileMetadataResolver._getEntryComponentsFromProvider (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18832:34)
            at eval (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18805:96)
            at <Jasmine>
            at CompileMetadataResolver._getProvidersMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18768:23)
            at eval (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18770:27)
            at <Jasmine>
            at CompileMetadataResolver._getProvidersMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18768:23)
            at eval (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18391:76)
            at <Jasmine>
            at CompileMetadataResolver.getNgModuleMetadata (dist/vendor/@angular/compiler/bundles/compiler.umd.js:18382:53)
            at JitCompiler._loadModules (dist/vendor/@angular/compiler/bundles/compiler.umd.js:25771:55)
            at JitCompiler._compileModuleAndAllComponents (dist/vendor/@angular/compiler/bundles/compiler.umd.js:25759:40)
            at JitCompiler.compileModuleAndAllComponentsAsync (dist/vendor/@angular/compiler/bundles/compiler.umd.js:25718:41)
            at CompilerImpl.compileModuleAndAllComponentsAsync (dist/vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js:212:35)
            at TestingCompilerImpl.compileModuleAndAllComponentsAsync (dist/vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js:148:35)
            at TestBedViewEngine.compileComponents (dist/vendor/@angular/core/bundles/core-testing.umd.js:1724:35)
            at Function.TestBedViewEngine.compileComponents (dist/vendor/@angular/core/bundles/core-testing.umd.js:1583:81)
            at UserContext.testing_1.async (dist/@xtip/components/betslip/betslip.spec.js:195:27)
            at ZoneDelegate.invoke (dist/vendor/zone.js/dist/zone.js:388:26)
            at AsyncTestZoneSpec.onInvoke (dist/vendor/zone.js/dist/async-test.js:106:39)
            at ProxyZoneSpec.onInvoke (dist/vendor/zone.js/dist/proxy.js:125:39)
            at ZoneDelegate.invoke (dist/vendor/zone.js/dist/zone.js:387:32)
            at Zone.runGuarded (dist/vendor/zone.js/dist/zone.js:151:47)
            at runInTestZone (dist/vendor/zone.js/dist/async-test.js:234:29)
            at UserContext.<anonymous> (dist/vendor/zone.js/dist/async-test.js:168:17)
            at ZoneDelegate.invoke (dist/vendor/zone.js/dist/zone.js:388:26)
            at ProxyZoneSpec.onInvoke (dist/vendor/zone.js/dist/proxy.js:128:39)
            at ZoneDelegate.invoke (dist/vendor/zone.js/dist/zone.js:387:32)
            at Zone.run (dist/vendor/zone.js/dist/zone.js:138:43)
            at runInTestZone (dist/vendor/zone.js/dist/jasmine-patch.js:142:34)
            at UserContext.<anonymous> (dist/vendor/zone.js/dist/jasmine-patch.js:158:20)
            at <Jasmine>
            at ZoneDelegate.invokeTask (dist/vendor/zone.js/dist/zone.js:421:31)
            at Zone.runTask (dist/vendor/zone.js/dist/zone.js:188:47)
            at drainMicroTaskQueue (dist/vendor/zone.js/dist/zone.js:595:35)

Example code:

import { LocalStorageService, SessionStorageService} from 'ngx-webstorage';
import { StorageService } from '@app/common/services';

...

TestBed.configureTestingModule({
      imports: [...],
      declarations: [...],
      providers: [
        LocalStorageService,
        SessionStorageService,
        StorageService,
      ]
    });

This looks like quite a common use case to me, and maybe I’m missing something. Any help would be appreciated.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
TheElegantDevcommented, Dec 11, 2018

@nexaddo, in most cases, importing NgxWebstorageModule.forRoot() and removing the imported SessionStorageService and LocalStorageService fixes the issue. In several of my specs I had to use the mock approach. Just my two cents.

1reaction
TheElegantDevcommented, Nov 30, 2018

@PillowPillow, thanks for you help! I’ll try out your suggestions soon (and the second is sure to work) - but you can go ahead and close the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Can't resolve all parameters for LocalStorageService ...
Your LocalStorageService has a dependency that is unmet. You will need to add that dependency to your login.module .
Read more >
Can't resolve all parameters for LocalStorageService ... - GitHub
Started an AOT build and got this message. ERROR in : Can't resolve all parameters for LocalStorageService in node_m...
Read more >
Fixing the “can't resolve all parameters” exception with ...
Here's what the error looked like: Can't resolve all parameters for QuillConfigurationDirective: [object Object], (?). The (?) indicates that Angular couldn't ...
Read more >
'Can't resolve all parameters for LoginPage' when injecting ...
I have an app just about finished, but I need to store a few things in local storage.
Read more >
Dependency injection in action - Angular
Dependencies can be registered at any level in the component hierarchy. ... Angular throws an error if it can't find the dependency during...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found