InlineHtmlStripStylesTransformer is not strict enough
See original GitHub issueCurrent 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:
- Created 4 years ago
- Reactions:5
- Comments:15 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, so one more thought I just had,
templateUrl
is actually more important to be transformed thanstyles
to be removed. WithouttemplateUrl
being transformed totemplate
, 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
:Component
gets imported from@angular/core
orTestBed
gets imported from@angular/core/testing
styles
:This would seem more practical to me as
styles
is also used in more contexts thantemplateUrl
.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.