question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InlineHtmlStripStylesTransformer is not strict enough

See original GitHub issue

Current Behavior

Any object literals have their property assignments transformed thus causing source code such as:

console.log({
  styles: ['styles.css']
})

to print out

{
  styles: []
}

Expected Behavior

Only object literals passed to @angular/core’s @Component decorator should have it’s property assignments transformed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
wthocommented, Apr 3, 2019

Ok, so one more thought I just had, templateUrl is actually more important to be transformed than styles to be removed. Without templateUrl being transformed to template, it will not even load.

styles on the other hand is just removed for performance issues (correct me if I’m wrong), as we assume styles are usually not tested in jest, that is better done in e2e frameworks.

Proposal

We could also think about handling them differently, although this might complicate the code unnecessarily.

templateUrl:

  • replaced everywhere
  • alternatively only (as suggested by @FrozenPandaz) in files where Component gets imported from @angular/core or TestBed gets imported from @angular/core/testing

styles:

  • replaced only if declared directly inside component decorators

This would seem more practical to me as styles is also used in more contexts than templateUrl.

2reactions
wthocommented, Jun 5, 2019

Yeah, I am almost done with the PR, will submit it this weekend.

It’s not really an error, it is an intrusive caveat that kept the transformer simple, but can create side-effects.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File not found: jest-preset-angular ... - GitHub
I got the following error running ng test: File not found: jest-preset-angular/InlineHtmlStripStylesTransformer.js (resolved as: ...
Read more >
Angular 8 and jest - File not found: jest-preset ... - Stack Overflow
So change in your package.json the lines from: "astTransformers": [ "jest-preset-angular/InlineHtmlStripStylesTransformer.js" ].
Read more >
preset ts-jest not found. - You.com | The search engine you control.
I was getting the error Preset ../../jest.preset.ts not found so I found the jest.preset.ts file in my project and set the working directory...
Read more >
angular-builders | Command Line Interface library
Implement angular-builders with how-to, Q&A, fixes, code snippets. kandi ratings - Medium support, No Bugs, No Vulnerabilities.
Read more >
jest-preset-angular/inlinehtmlstripstylestransformer.js ...
So change in your package.json the lines from:. File not found: jest-preset-angular/InlineHtmlStripStylesTransformer.js (resolved as: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found