bahmutov / cypress-angular-unit-test

Trying to load and bootstrap Angular component dynamically inside Cypress
160 stars 32 forks source link

Critical dependency: the request of a dependency is an expression #590

Open LeBeatle opened 3 years ago

LeBeatle commented 3 years ago

Current behavior

After npx cypress open-ct I get a lot of warnings like this:

WARNING in ./node_modules/@angular/core/fesm2015/core.js 29858:15-102
Critical dependency: the request of a dependency is an expression

and this:

WARNING in ./node_modules/@angular/core/fesm2015/core.js 29858:15-102
System.import() is deprecated and will be removed soon. Use import() instead.

Be use Angular 12.1 with webpack 5.47 and typescript 4.3. Screenshot 2021-09-02 at 08 52 56

After the built finished with warnings I get an "Root element not found" error in the Component Test. Screenshot 2021-09-02 at 08 55 31 s.

Desired behavior

A build without warnings and working Component Test without error

Test code to reproduce

` import 'zone.js/dist/zone'; import 'zone.js/dist/long-stack-trace-zone'; import 'zone.js/dist/proxy';

import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/dist/zone-testing';
import { initEnv, mount } from 'cypress-angular-unit-test';
import { LoadingIndicatorComponent } from './loading-indicator.component';

describe('LoadingIndicatorComponent', () => {
    beforeEach(() => {
        initEnv(LoadingIndicatorComponent);
    });

    it('shows the input', () => {
        mount(LoadingIndicatorComponent, {});

        cy.contains('Welcome to World!');
    });
});`

Versions

Cypress package version: 7.7.0 Cypress binary version: 7.7.0 Electron version: 12.0.0-beta.14 Bundled Node version: 14.15.1

@angular-devkit/architect 0.1201.1 @angular-devkit/build-angular 12.1.1 @angular-devkit/core 12.1.1 @angular-devkit/schematics 12.1.1 @angular/elements 12.1.3 @angular/flex-layout 12.0.0-beta.34 @schematics/angular 12.1.1 rxjs 6.6.7 typescript 4.3.5 webpack 5.47.0

4ern commented 2 years ago

@LeBeatle, were you able to solve the problem?