Skip to content

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

Closed
@elifmeric

Description

@elifmeric

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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/list

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions