Description
angularFire 6.0.2
Angular 10.0.4
Angular cli: 10.0.3
firebase: 7.16.1
Other (e.g. Ionic/Cordova, Node, browser, operating system):
Tested with node 12, 13 and 14
OS: Windows
How to reproduce these conditions
So when upgrading from angularFire 6.0.0 to angularFire 6.0.2, the following jest unit test will start to fail. Nothing else is being touched, so I'm pretty sure it has something to do with the upgrade of angularFire.
Failing test unit
See also these issues when I thought it had something to do with jest:
thymikee/jest-preset-angular#421
jestjs/jest#10251 (comment)
This test will fail with jest:
'
import { async, TestBed } from '@angular/core/testing';
import { AngularFireModule } from '@angular/fire';
import { environment } from '../../../src/environments/environment';
import { Authentication } from '../../../src/app/core/services/authentication.service';
import { FirestoreService } from '../../../src/app/core/services/firestore-service';
import { MatDialogModule } from '@angular/material/dialog';
import { database } from 'firebase';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import DataSnapshot = firebase.database.DataSnapshot;
describe('Test Dynamic Calculation', () => {
const resetTestingModule = TestBed.resetTestingModule,
preventAngularFromResetting = () => (TestBed.resetTestingModule = () => TestBed);
beforeAll(async(async () => {
resetTestingModule();
preventAngularFromResetting();
TestBed.configureTestingModule({
imports: [
AngularFireModule.initializeApp(environment.firebaseConfig),
MatDialogModule,
],
declarations: [
],
providers: [
FirestoreService,
Authentication,
],
schemas: [NO_ERRORS_SCHEMA],
});
await TestBed.compileComponents();
}));
afterAll(() => resetTestingModule());
beforeEach(async () => {
//we need to inject something it seems otherwise firebase complains the app has not been initialized
ed = TestBed.inject(FirestoreService);
let result: DataSnapshot = await database().ref('/data').once('value');
});
let ed: FirestoreService;
it('Example 0', () => {
});
});
'
Debug output
Error: Uncaught [TypeError: A dynamic import callback was not specified.] at reportException (C:\Users\Rubenn\AC\acro-companion\node_modules\jest-environment-jsdom\node_modules\jsdom\lib\jsdom\living\helpers\runtime-script-errors.js:62:24) at Timeout.task [as _onTimeout] (C:\Users\Rubenn\AC\acro-companion\node_modules\jest-environment-jsdom\node_modules\jsdom\lib\jsdom\browser\Window.js:396:9) at listOnTimeout (internal/timers.js:551:17) at processTimers (internal/timers.js:494:7) TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified. at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:31:9) at C:\Users\Rubenn\AC\acro-companion\node_modules\src\auth\auth.ts:58:52 at ZoneDelegate.invoke (C:\Users\Rubenn\AC\acro-companion\node_modules\zone.js\dist\zone.js:386:30) at ProxyZoneSpec.onInvoke (C:\Users\Rubenn\AC\acro-companion\node_modules\zone.js\dist\proxy.js:117:43) at ZoneDelegate.invoke (C:\Users\Rubenn\AC\acro-companion\node_modules\zone.js\dist\zone.js:385:36) at Zone.run (C:\Users\Rubenn\AC\acro-companion\node_modules\zone.js\dist\zone.js:143:47) at NgZone.runOutsideAngular (C:\Users\Rubenn\AC\packages\core\src\zone\ng_zone.ts:227:50) at SwitchMapSubscriber.project (C:\Users\Rubenn\AC\acro-companion\node_modules\src\auth\auth.ts:58:28) at SwitchMapSubscriber._next (C:\Users\Rubenn\AC\acro-companion\node_modules\rxjs\src\internal\operators\switchMap.ts:123:21) at SwitchMapSubscriber.Subscriber.next (C:\Users\Rubenn\AC\acro-companion\node_modules\rxjs\src\internal\Subscriber.ts:99:12) { code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING' }