capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

Device cause Injector Error

Open shifenis opened this issue 3 years ago • 0 comments

Bug Report

Plugin(s)

@capacitor/device

Capacitor Version

Latest Dependencies:
  @capacitor/cli: 3.4.1
  @capacitor/core: 3.4.1
  @capacitor/android: 3.4.1
  @capacitor/ios: 3.4.1

Installed Dependencies:

  @capacitor/core: 3.4.0
  @capacitor/ios: 3.4.0
  @capacitor/cli: 3.4.0
  @capacitor/android: 3.4.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Platform(s)

ng test

Current Behavior

By retrieving language from Device in a service, declared in root, and trying to test a component that uses that service, 2 times on 3 the test cause an Injector error If I remove the methods that use Device the test just runs fine. I would add that the unit test hasn't to check the service but just the component's logic; The exact error I'm that let my test fail is: Unhandled promise rejection: Error: Injector has already been destroyed.

Expected Behavior

The test has to run.

Code Reproduction

Service A

async init() {
 await Device.getLanguageCode();
}} 

Component

constructor() {
  serviceA.init();
}

Other Technical Details

I'm having this issue with:

Angular CLI: 13.0.4
Node: 14.17.2
Package Manager: npm 6.14.13
OS: darwin x64

Angular: 13.0.3
... common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.4
@angular-devkit/build-angular   13.2.2
@angular-devkit/core            13.0.4
@angular-devkit/schematics      13.0.4
@angular/cli                    13.0.4
@schematics/angular             13.0.4
rxjs                            6.6.7
typescript                      4.4.4

But even with pipeline on azure

shifenis avatar Feb 11 '22 16:02 shifenis