-
Notifications
You must be signed in to change notification settings - Fork 309
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
WIP to make it compatible with ts-jest 23.10 and remove regexp replacers #201
Conversation
Awesome, waiting for your availability then :) |
So to push this PR a bit(and maybe start helping out) As I see what is still missing, it is just a single transformer has to look for the
Then the transformer has to
I wonder if adding the HTML as |
inline template works in the current preprocessor. Regarding to adding the HTML file I have no idea because the current preprocessor doesn't do that as far as I'm concerned. |
Ok, as @huafu stated in the comments of the PR's preprocessor.js, the inline html part is handled by ts-jest. As far as I understand it, the current preprocessor checks for jest-preset-angular/preprocessor.js Line 2 in abfb339
jest-preset-angular/preprocessor.js Line 11 in abfb339
I will have a try to implement it as an AST transformer. |
I am done with the transformer, but need some instructions:
Implementation Details:
|
hi @wtho, thank you very much for your effort. In my opinion, I think:
|
#204) Closes #195 and closes #201 ### Breaking Change This is a breaking change as Configuration Interface changes ([see ts-jest v23.10 docs](https://kulshekhar.github.io/ts-jest/user/config/#ts-jest-options)) This PR is built upon @huafu's #201, kudos to him for setting up everything and pointing out what was still to be done. Transformer and test are also heavily inspired by his examples in ts-jest. Also see the PR for more information. ### Implementation Details Like the Regex, all the transformer does is transform * `templateUrl: <PATH>` to `template: require(<PATH>)` * `styles: <ANYTHING>` to `styles: []` * `styleUrls <ANYTHING>` to `styleUrls: []` For more information see the comments in the [transformer file](https://github.com/wtho/jest-preset-angular/blob/55bcfdb993d1dc511611553995ff566d64ea6944/src/InlineHtmlStripStylesTransformer.ts) or #201. ### Edge Cases I had to make some decisions on how strict the astTransformer is, I decided for this, but I am open to discussion: **Works** ```ts import { Component as Cmp } from '@angular/core'; @cmp({ templateUrl: './some-path.html' }) class AngularComp { } ``` Caveat - this also gets transformed ```ts @SomeOtherDecorator({ templateUrl: './some-path.html' }) class SomeClass { } ``` **Does not work** ```ts const componentArgs = { templateUrl: './some-path.html' } @component(componentArgs) class AngularComp { } ``` ### Additional Notes * Run unit tests for the transformer with `npm test` * The transformer was written in TypeScript. A `prepare`-script for was added, which compiles it to JS before publishing and after `npm install`. * `preprocessor.js` and its unit tests were removed.
DO NOT MERGE, this is a WIP which I do not have time to continue just right now
see #195