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

[Bug]: Tests fail if component with template literals for styles/styleUrl property are used #2735

Closed
skrtheboss opened this issue Sep 12, 2024 · 2 comments · Fixed by #2736
Closed
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@skrtheboss
Copy link
Contributor

Version

14.2.2

Steps to reproduce

Define a component and use template literals for the styles/styleUrl proeprty:

@Component({
    standalone: true,
    selector: 'bar',
    templateUrl: `./bar.component.html`,
    styleUrl: `./bar.component.scss`,
    // we have to setup styles this way, since simple styles/styleUrs properties will be removed (jest does not unit test styles)
    styles: `
            p {
                color: red;
            }
        `,
})
export class StringStylesBarComponent {
    constructor(@Inject(DATA_TOKEN) public data: ServerError) {}
}

Expected behavior

Should work just like when using strings.

Actual behavior

Component 'StringStylesBarComponent' is not resolved:
     - styleUrl: ./bar.component.scss
    Did you run and wait for 'resolveComponentResources()'?

Additional context

No response

Environment

System:
    OS: Linux 6.10 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    Yarn: 4.4.1 - ~/.nvm/versions/node/v20.17.0/bin/yarn
    npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
  npmPackages:
    jest: ^29.7.0 => 29.7.0
@ahnpnl
Copy link
Collaborator

ahnpnl commented Sep 12, 2024

It works with single quote/double quotes but not backtick right?

skrtheboss added a commit to skrtheboss/jest-preset-angular that referenced this issue Sep 12, 2024
@skrtheboss
Copy link
Contributor Author

Hi @ahnpnl, yes exactly.
I made a PR which should fix this, let me know what you think.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
2 participants