feat(jest) update Jest builder to use jest-preset-angular v7#246
Conversation
|
I see the build failed, but I'm not sure it's related to this code. Here's the error from Travis: |
|
First of all thanks for your contribution! The error is related to your change. |
Thanks, I will take a look at the e2e test. |
|
The node 10 build failed, but looks like due to timeout. Can you confirm? The node 8 build did succeed. |
|
I restarted the |
I'm not exactly sure how to accomplish checking the installed Jest version, but I will dig in and let you know what I find! Thanks. |
|
@wesleygrimes Gave it a second thought. Seems that it's not possible to support both versions of Jest in a single version of the builder, because the builder is tied to a specific version of |
|
Thanks! I will take a look and get this PR updated.
…-Wes
On Mar 11, 2019, at 6:32 PM, Evgeny Barabanov ***@***.***> wrote:
@wesleygrimes Gave it a second thought. Seems that it's not possible to support both versions of Jest in a single version of the builder, because the builder is tied to a specific version of jest-preset-angular which, in turn, works with specific version of Jest.
Btw, I've just noticed that in this PR you've changed the version of Jest for the builders project, instead of changing the versions of preset in Jest builder package.
Check out this issue for the proper changes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@wesleygrimes Unfortunately, I don't found how to fix them. I didn't succeed to compile AppComponent during test because its template html file can't be load. I encountered next error: I wondered if zone-patch works well because We removed some option about html but to remain compatible with latest jest-preset-angular version. |
|
Yeah same here. Maybe @meltedspark can point us in the right direction?
…-Wes
On Mar 13, 2019, at 5:17 PM, Steven Enten ***@***.***> wrote:
@wesleygrimes
I tried to investigate why multiple-app and single-app tests failed.
Unfortunately, I don't found how to fix them.
I didn't succeed to compile AppComponent during test because its template html file can't be load. I encountered next error: Failed: "Failed to load app.component.html".
I wondered if zone-patch works well because beforeEach function doesn't seem to succeed. Eventually due to a silent error (about template html which can't be load).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
The projects use lock files ( |
|
Oh duh! That makes sense! Thanks. I will run yarn when I get to my desk this morning and push a new commit.
Is there a contributing readme somewhere? If not maybe we can put one together and put down some notes on how to pull down the repo and test, etc..
Thanks!
-Wes
… On Mar 14, 2019, at 4:11 AM, JeB ***@***.***> wrote:
The projects use lock files (yarn lock), so it's not enough to change the dependency version in package.json. In order to apply it correctly you have to run yarn add [-D] ***@***.***
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
That's a great idea, definitely need to have one! |
@enten can you speak to why we removed the |
|
@wesleygrimes @meltedspark Previously we override According to jest-preset-angular v7.0.1 migration guide:
Initially, I thought that we don't need to override Finally, after that @meltedspark reminded me the purpose of Jest builder, I think that we need to override --- a/packages/jest/src/default-config.resolver.ts
+++ b/packages/jest/src/default-config.resolver.ts
@@ -12,6 +12,9 @@ export class DefaultConfigResolver {
resolveGlobal(workspaceRoot: Path): any {
const jestPresetFullPath = join(workspaceRoot, jestPresetRootPath);
return {...defaultConfig,
+ transform: {
+ '^.+\\.(ts|js|html)$': 'ts-jest'
+ },
snapshotSerializers: [
getSystemPath(join(jestPresetFullPath, snapshotSerializer)),
getSystemPath(join(jestPresetFullPath, htmlCommentSerializer))-- On another side, I wonder if our issue may is related to the preprocessor. Because it was responsive to fix
Now ts-node Conclusion: we need to investigate to ensure that the ast transformer works as expected. |
|
@wesleygrimes @meltedspark Sadly, that doesn't fix issue Even with add @wesleygrimes --- a/packages/jest/src/default-config.resolver.ts
+++ b/packages/jest/src/default-config.resolver.ts
@@ -12,6 +12,9 @@ export class DefaultConfigResolver {
resolveGlobal(workspaceRoot: Path): any {
const jestPresetFullPath = join(workspaceRoot, jestPresetRootPath);
return {...defaultConfig,
+ transform: {
+ '^.+\\.(ts|js|html)$': 'ts-jest'
+ },
snapshotSerializers: [
getSystemPath(join(jestPresetFullPath, snapshotSerializer)),
getSystemPath(join(jestPresetFullPath, htmlCommentSerializer))
@@ -23,7 +26,10 @@ export class DefaultConfigResolver {
return {
globals: {
'ts-jest': {
- tsConfig: getSystemPath(join(projectRoot, tsConfigName))
+ tsConfig: getSystemPath(join(projectRoot, tsConfigName)),
+ stringifyContentPathRegex: '\\.html$',
+ astTransformer: [ require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer') ]
}
},
testMatch: [ |
|
Hi guys. Thanks for your efforts. I almost forgot, but there actually is a version of builder that incorporates the necessary changes (it existed when the preset was |
|
Related issue: #182 |
|
I created a pull request for you to highlight the changes that should be made. |
|
@wesleygrimes @meltedspark |
|
I'd rather merge this PR and delete the other for a few reasons:
I created the other PR for a reference to make things in this PR work. |
|
I haven't had time, but I hope to look at this, this week and get this PR
updated. Anyone else is free to jump in and update this as well if you have
time.
Thanks,
Wes
…On Sun, Mar 17, 2019 at 6:07 AM JeB ***@***.***> wrote:
I'd rather merge this PR and delete the other for a few reasons:
- Keep the work you've done
- The other PR is created from a branch that wasn't meant to be merged
to master but released as an alpha (it also depends on alpha version of the
preset).
On the other hand this PR is supposed to be more mature and handle all
the stuff like updating the tests dependencies etc.
I created the other PR for a reference to make things in this PR work.
So you guys can make the necessary changes and we'll merge this PR. Or
I'll make the changes when I have time.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#246 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AATy1IVi4zOEgDCD7R_jHKEqkdKsMbpVks5vXhPRgaJpZM4bCCHo>
.
--
Thanks,
Wes
|
|
OK best I could tell from the PR #269 the only thing needing changed was updating |
|
@meltedspark looks like the build passed this time. Want to have a look and see if we can get this merged? |
|
Looks like we're almost there, the only thing that is missing (according to this comment) is adding to the config. Since it doesn't involve any path calculation it can be added right to the default config ( Also, looks like |
Thanks, |
|
Sure, in order to update "yarn.lock" you have to run "yarn add -D
jest-preset-angular" (D for dev).
…On Wed, Mar 20, 2019, 17:30 Wes Grimes ***@***.***> wrote:
Looks like we're almost there, the only thing that is missing (according
to this comment
<#246 (comment)>)
is adding
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest'
},
to the config. Since it doesn't involve any path calculation it can be
added right to the default config (
packages\jest\src\jest-config\default-config.ts).
Also, looks like packages/jest/yarn.lock is not updated (it should be).
It shouldn't matter for the final version as yarn.lock is not is not
published, but for the local development it is better to be in sync.
- Pushed a commit adding the transform property
- Regarding the yarn.lock file, this should have been updated
previously when I updated the package.json to jest-preset-angular 7.0.0
? I normally just use npm so I am not as familiar with updating yarn
files. Can you help me with next steps on that?
Thanks,
Wes
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#246 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJXjb1hsG5pVK6_rFyubNeskZtNuw8Piks5vYlQegaJpZM4bCCHo>
.
|
Ok, all set, it did update |
|
@all-contributors please add @wesleygrimes for code |
|
I've put up a pull request to add @wesleygrimes! 🎉 |
This PR replaces the deprecated
setupTestFrameworkScriptFilewith the newsetupFilesAfterEnvoption. I also updated the schema.json with the new option and details per the Jest documentation.This closes #239 and potentially #193
This is my first PR on your project, so feel free to let me know if things should be done differently, or if I should follow a different naming convention.