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

Testbed fails to compile #51

Closed
chronospatian opened this issue May 10, 2024 · 1 comment
Closed

Testbed fails to compile #51

chronospatian opened this issue May 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@chronospatian
Copy link

chronospatian commented May 10, 2024

Version: 1.41.2

Tests that use beforeMount to configure TestBed fail to run.

npm run test-ct

> web-component-harness@0.0.0 test-ct
> playwright test -c playwright-ct.config.ts

JIT compilation failed for injectable [class PlatformLocation]
Error: The injectable 'PlatformLocation' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

The injectable is part of a library that has been partially compiled.
However, the Angular Linker has not processed the library such that JIT compilation is used as fallback.

Ideally, the library is processed using the Angular Linker to become fully AOT compiled.
Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server',
or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.

    at getCompilerFacade (<omitted>/packages/core/src/compiler/compiler_facade.ts:52:11)
    at Module.ɵɵngDeclareFactory (<omitted>/packages/core/src/render3/jit/partial.ts:58:20)
    at Function.<static_initializer> (<omitted>/node_modules/@angular/common/fesm2022/common.mjs:64:29)
    at <omitted>/packages/common/src/dom_tokens.ts:18:25

Minimal reproduction

import {test} from "@sand4rt/experimental-ct-angular";
import {beforeMount} from "@sand4rt/experimental-ct-angular/hooks";
import {NoopAnimationsModule} from "@angular/platform-browser/animations";

test.describe('harness', () => {
  beforeMount(async ({ TestBed }) => {
    TestBed.configureTestingModule({
      imports: [NoopAnimationsModule]
    })
  })
})
@chronospatian
Copy link
Author

Adding @analogjs/vite-plugin-angular to playwright config fixed this for me. Copied from https://github.com/sand4rt/playwright/blob/hello-angular-ct/tests/components/ct-angular/playwright.config.mts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant