Skip to content

how to test components that use import (dinamic import) inside component ? #41

@AlonsoK28

Description

@AlonsoK28

you can provide to make the test for components using import inside a component? (no router module)

example:

async loadImportXlsx(){

    // avoid user throttling
    if (this.isLoadingImportXlsx) return;

    this.isLoadingImportXlsx = true;

    const config: MatDialogConfig = {
      width: '85%',
      height: '95%',
      disableClose: true,
      data: {
        currentDomain: this.selectedDomain
      } 
    };
    
    // how test this line?
    const lazyComponent = await import('@pages/import/import.component');

    const dialogRef = this.dialog.open(lazyComponent.ImportComponent, config);
    dialogRef
    .beforeClosed()
    .subscribe(data => this.title.setTitle(this.dashboardTitle));

    setTimeout(() => {
      this.isLoadingImportXlsx = false;
    }, 1300);
  }

this code gets a ngModule using lazy load (with import) and then open it inside a new Material Dialog

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions