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

Shallow-render fails to bind @Input properties with required option in Angular 16 #255

Open
lucaspaties opened this issue Jun 6, 2024 · 1 comment

Comments

@lucaspaties
Copy link

Hello,
I've encountered an issue when using shallow-render with Angular 16.

In Angular 16, @input properties can have a required option. However, when I try to bind these properties in my tests, I get this:
InvalidCharacterError: Failed to execute 'setAttribute' on 'Element': '[[object' is not a valid attribute name.

Ex:


import { Component, Input } from "@angular/core";

@Component({
    selector: "my-component",
    templateUrl: "./my-component.component.html"
})

export class MyComponent {
    @Input({ required: true }) myInput1: any;

}}

Then on the test file:

 const render = async () =>
     shallow
         .provideMock({ provide: Service, useValue: ServiceMock })
         .provideMock({ provide: Toastr, useValue: ToastrMock })
         .render({ bind: { myInput1: objectMock } });

Can you look into it?

@angheladrian
Copy link

We have the same error when using signal inputs.

import {Component, input} from "@angular/core";

@Component({
    selector: "my-component",
    templateUrl: "./my-component.component.html"
})
export class MyComponent {

    readOnly = input<boolean|null>(false);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants