ckeditor / ckeditor4-angular

Official CKEditor 4 Angular component.
Other
55 stars 32 forks source link

Jest test: Unexpected value 'CKEditorModule' imported by the module MyModule'. Please add an @NgModule annotation. #246

Closed corentingosselin closed 1 year ago

corentingosselin commented 1 year ago

Bug

MyModule ✕ should create the module (188 ms)

● MyModule › should create the module

Unexpected value 'CKEditorModule' imported by the module 'CommonUtilModule'. Please add an @NgModule annotation.

  13 |
  14 |   it('should create the module', () => {
> 15 |     const module: MyModule = TestBed.inject(MyModule);
     |                                                         ^
  16 |     expect(module).toBeTruthy();
  17 |   });
  18 | });

Provide detailed reproduction steps (if any)

The module MyModule:

@NgModule({ imports: [ CommonUtilModule ], declarations: [], exports: [], }) export class MyModule {}

The CommonUtilModule:

@NgModule({ imports: [CommonModule, CKEditorModule], declarations: [], exports: [], }) export class CommonUtilModule{}

Writing a simple test:

import { TestBed } from '@angular/core/testing';
import { MyModule } from './my-module.module';

describe('MyModule', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MyModule],
})
.compileComponents();
});

it('should create the module', () => {
const module: MyModule = TestBed.inject(MyModule);
expect(module).toBeTruthy();
});
});

When running the test, it fails and I get this error:

Unexpected value 'CKEditorModule' imported by the module 'CommonUtilModule'. Please add an @NgModule annotation.

Interesting thing, if I use npm i, to isntall dependencies, there is no error and the test pass. but using pnpm i, I get this error.

this is a screen of the not working (pnpm installed) ckeditorModule: image

and the screen using npm i: image

on the screenshots i'm using 2.3.0 version, however I get the same behaviour using the latest

Expected result

it should works for unit test using pnpm

Actual result

the test is not passing using pnpm

Other details

Comandeer commented 1 year ago

Could you provide the version of Angular you are using and check if the same is used when installed via npm and pnpm?

corentingosselin commented 1 year ago

Could you provide the version of Angular you are using and check if the same is used when installed via npm and pnpm?

oh yep sorry: angular 15.0.1 and yes both are using 15.0.1

Comandeer commented 1 year ago

The CKEditor 4 Angular integration does not support Angular 12+ yet, please see https://github.com/ckeditor/ckeditor4-angular/issues/244#issuecomment-1580926181 for more details.

As the issue seems to be connected with the Angular 12+ support, I'm going to close it. However, if the issue wouldn't be resolved by the new version of the package, feel free to ping me and I'll reopen the issue.