Angular-calendar: Unit tests breaking

Created on 3 Mar 2021  路  13Comments  路  Source: mattlewis92/angular-calendar

Describe the bug

Our unit tests (using Jest) started breaking after adding this package. Seems like module exports are not done in an expected way.

The errors I get when running on node 14.16.0 are:

  • Unexpected value 'DragAndDropModule' imported by the module 'CalendarMonthModule'. Please add an @NgModule annotation.
  • Importing DragAndDropModule which does not have a 傻mod property

Versions

  • @angular/core: 10.2.3
  • angular-calendar: 0.28.22
has PR

Most helpful comment

I just shipped a new version of the next version of the calendar and can confirm that it fixes the issue on the sample repo provided! 馃コ

Instructions on how to install and migrate on the PR here! https://github.com/mattlewis92/angular-calendar/pull/1249

All 13 comments

Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider sponsoring me

Hey there! Please could you provide a minimal runnable repro on github that reproduces the issue and I'll take a look into it 馃槃

Hi @mattlewis92 ! Managed to create a small repo now, let me know if it is enough for you to reproduce the issue or need more info: https://github.com/Nostrus/angular-calendar-test

Did you have a chance to check it out @mattlewis92 ?

Hey, sorry about the late reply, I did some digging and couldn't figure out a solution, no matter what I tried I always seem to get that which does not have a 傻mod property error

@Nostrus Do you really need to import CalendarModule in your tests ? I assume not. I just took a look at your Repository and i could fix your tests by removing the Module import from spec file.

describe('AppComponent', () => {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [AppComponent],
      imports: [
        // CalendarModule.forRoot({
        //   provide: DateAdapter,
        //   useFactory: momentAdapterFactory,
        // }),
      ],
      schemas: [
        NO_ERRORS_SCHEMA
      ]
    }).compileComponents();
  });

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@Nostrus Do you really need to import CalendarModule in your tests ? I assume not. I just took a look at your Repository and i could fix your tests by removing the Module import from spec file.

describe('AppComponent', () => {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [AppComponent],
      imports: [
        // CalendarModule.forRoot({
        //   provide: DateAdapter,
        //   useFactory: momentAdapterFactory,
        // }),
      ],
      schemas: [
        NO_ERRORS_SCHEMA
      ]
    }).compileComponents();
  });

Well, my example repo's only purpose was to show the error, but it's not really a real-life scenario. In our production app CalendarModule was part of a bigger shared module, so couldn't just remove it without restructuring the app. Even if that works (thanks for the suggestion, could be one way to go), feels like a workaround rather than an actual solution to the error.

I was running into this same issue recently. On my fork of the drag and drop library I have upgraded its angular version to 11 and removed rollup from the build step. This resolved the issue and I can now run my tests again when using my local build of the library. I'm not entirely sure what part of the upgrade process fixed the issue.

I can open a pull request for angular-draggable-droppable if you want to use my fixes.

I was running into this same issue recently. On my fork of the drag and drop library I have upgraded its angular version to 11 and removed rollup from the build step. This resolved the issue and I can now run my tests again when using my local build of the library. I'm not entirely sure what part of the upgrade process fixed the issue.

I can open a pull request for angular-draggable-droppable if you want to use my fixes.

Oh interesting, that's good to know that just upgrading angular + dropping rollup fixes the issue. The calendar and its dependencies are loooong overdue an angular upgrade, a PR that does this would be very welcome!

I just shipped a new version of the next version of the calendar and can confirm that it fixes the issue on the sample repo provided! 馃コ

Instructions on how to install and migrate on the PR here! https://github.com/mattlewis92/angular-calendar/pull/1249

I just shipped a new version of the next version of the calendar and can confirm that it fixes the issue on the sample repo provided! 馃コ

Instructions on how to install and migrate on the PR here! #1249

I updated and that fixed my testing problems!

Closing this out now that 0.29.0 is released as stable 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sushma-tiwari picture Sushma-tiwari  路  3Comments

arvind-das picture arvind-das  路  3Comments

Herb-sh picture Herb-sh  路  4Comments

AstRonin picture AstRonin  路  4Comments

teodoramalec picture teodoramalec  路  4Comments