Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(MatListModule): Jest failed "ReferenceError: Cannot access 'MatListBase' before initialization" #25008

Closed
1 task done
elifmeric opened this issue Jun 2, 2022 · 1 comment · Fixed by #25049
Closed
1 task done
Assignees
Labels
area: material/list P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@elifmeric
Copy link

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

12.1.1

Description

   ReferenceError: Cannot access 'MatListBase' before initialization

       9 | } from '@angular/core';
      10 | import { MatDialog } from '@angular/material-experimental/mdc-dialog';
    > 11 | import { MatListOption, MatSelectionList } from '@angular/material-experimental/mdc-list';
         | ^
      12 | import { Router } from '@angular/router';
      13 |
      14 | import {

      at Object.<anonymous> (../../node_modules/@angular/material-experimental/fesm2020/mdc-list.mjs:343:190)

Other modules work as expected. We're using both angular/material and angular/material-experimental in our project and only MatListModule related components failed in test.

MatListModule
MatListOption
MatSelectionList

Similar to Issue #23907 except we're using material-experimental.

Reproduction

Import MatListModule, MatListOption or MatSelectionList to your component or module then run the tests.

Expected Behavior

I guess expected behavior is that Angular partial compilation emit should be work properly as I've paraphrased it from the comment below

#23907 (comment)

Actual Behavior

  ReferenceError: Cannot access 'MatListBase' before initialization

      1 | import { ComponentFixture, TestBed } from '@angular/core/testing';
      2 | import { MAT_DIALOG_DATA } from '@angular/material-experimental/mdc-dialog';
    > 3 | import { MatListModule } from '@angular/material-experimental/mdc-list';
        | ^
      4 |

      at Object.<anonymous> (../../node_modules/@angular/material-experimental/fesm2020/mdc-list.mjs:343:190)

Environment

  • Angular: 13.3.10

  • CDK/Material:13.3.8

  • Material Experimental : 13.3.8

  • Operating System: macOS

  • Jest : 28.1.0

  • jest-preset-angular : 12.0.1

@elifmeric elifmeric added the needs triage This issue needs to be triaged by the team label Jun 2, 2022
@crisbeto crisbeto self-assigned this Jun 10, 2022
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 10, 2022
…lization

Moves the `MatListBase` class up so that it isn't being referenced before it is used which seems to cause issues with Jest.

Fixes angular#25008.
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent has pr area: material/list and removed needs triage This issue needs to be triaged by the team labels Jun 10, 2022
crisbeto added a commit that referenced this issue Jun 10, 2022
…lization (#25049)

Moves the `MatListBase` class up so that it isn't being referenced before it is used which seems to cause issues with Jest.

Fixes #25008.

(cherry picked from commit 503f12f)
crisbeto added a commit that referenced this issue Jun 10, 2022
…lization (#25049)

Moves the `MatListBase` class up so that it isn't being referenced before it is used which seems to cause issues with Jest.

Fixes #25008.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/list P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants