ngx-drag-drop - Cannot access 'DndDraggableDirective' before initialization

532 Views Asked by At

I'm updating angular and it's dependencies to 13th version and encountered an issue with ngx-drap-drop package in jest tests. Previously it was on 2.0.0 version and now on 13.0.0. So I have a component which uses some directives from ngx-drag-drop package in component's html file.

When I run jest tests(v27.4) I see this error:

ReferenceError: Cannot access 'DndDraggableDirective' before initialization

which points to DndModule import in my test file:

import { DndModule } from 'ngx-drag-drop'

I import DndModule into TestBed.configureTestingModule, so this is not the case(BTW ngx-drag-drop v2.0.0 been throwing the error Unexpected value 'DndModule' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation.

Any help appreciated.

1

There are 1 best solutions below

0
Артем Ильин On BEST ANSWER

Looks like it's angular compiler issue (or not, I'm not sure) so for now I fixed it by mocking DndDraggableDirective and DndDropZoneDirective in my code.

Also I cloned ngx-drag-drop repo to try to fix the issue and I wasn't able to compile project on master branch. So, working on it.