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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

File changes not getting picked up in --watch mode (9.0.0-next.8) #803

Closed
johncrim opened this issue Feb 12, 2021 · 10 comments 路 Fixed by #876
Closed

File changes not getting picked up in --watch mode (9.0.0-next.8) #803

johncrim opened this issue Feb 12, 2021 · 10 comments 路 Fixed by #876

Comments

@johncrim
Copy link
Contributor

馃悰 Bug Report

This is almost the same as #764 - it's safe to consider this a regression in the new code, though the behavior is slightly different. I'm submitting a new issue to avoid confusion (since I know it's a different issue in new code).

When using 9.0.0-next.8 with isolatedModules: false, in jest --watch file changes are not being properly incorporated - it appears that the cache trails file changes.

To Reproduce

If I have a test like the following, which fails to compile b/c the commented out line is missing

describe('A directive can be declared in the test file', () => {

  it('and used in a test', () => {
    TestBed.configureTestingModule({
      declarations: [BlockClickBubbleDirective, TestHostComponent]
    });
    //const fixture = TestBed.createComponent(TestHostComponent);

    const directive = fixture.debugElement.children[0].children[0].injector.get(BlockClickBubbleDirective);
    expect(directive).toBeTruthy();
  })

});

then run jest --watch, I receive an error (as expected). If I then uncomment the const fixture line and save, the file is rebuilt and the test is re-run, but it uses the original (erroring) code and I receive the original error. If I then change the code back (to the erroring state) and save, the non-erroring code is run and the test passes.

If I exit jest after any of the changes and restart (or run jest not in watch mode), the current code is compiled and run, resulting in compile error or test success as expected.

Expected behavior

In --watch mode, code changes are compiled and run after the file is saved.

Link to repo

https://github.com/johncrim/repro-ivy-jest-preset-angular/tree/bug/jest-watch-update

git clone git@github.com:johncrim/repro-ivy-jest-preset-angular.git
git checkout  bug/jest-watch-update

yarn
yarn test:watch inline-directive # test failure expected
# uncomment 'const fixture' line; test re-runs and still fails
# exit + restart
yarn jest inline-directive # test passes

envinfo

System:
    OS: Windows

Npm packages:
    jest: 27.0.0-next.2
    jest-preset-angular: 9.0.0-next.8
    typescript: 4.0.5
@johncrim johncrim added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Feb 12, 2021
@ahnpnl ahnpnl added Upstream Bug and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Feb 12, 2021
@johncrim
Copy link
Contributor Author

Note: I did include a test when I submitted a PR for #764, but it looks like it was removed.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 12, 2021

It was removed because now we rely on ts-jest for compilation :) so this bug is for ts-jest actually.

@ahnpnl ahnpnl added 馃悰 Bug Confirmed Bug is confirmed and removed Upstream Bug labels Feb 12, 2021
@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 12, 2021

hmm I found out that it's jest-preset-angular bug because we used the wrong cache key which ts-jest couldn't resolve the correct cached compiler.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 12, 2021

would you please try this build.zip ?

Just need to extract it and replace build folder under jest-preset-angular with the build folder from the zip file. Then clear Jest cache and run test.

@johncrim
Copy link
Contributor Author

Yes! The problem is fixed with this build, given 10+ permutations I couldn't get the test output to mismatch the test code. Thank you!!

@johncrim
Copy link
Contributor Author

Hi @ahnpnl : Any chance of an updated beta release with this fix incorporated? I'm holding off on merging my branch b/c I don't want other devs to waste time on this.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 23, 2021

Hmm I鈥檓 waiting for ts-jest changes to be released first :)

@johncrim
Copy link
Contributor Author

Makes sense - Thanks for the update.

@ahnpnl
Copy link
Collaborator

ahnpnl commented Feb 25, 2021

Some updates: after testing with latest ts-jest next tag, I found out watch mode doesn鈥檛 work properly when changing types in another file which is referenced by test file so we have to wait for another fix.

Related issues: kulshekhar/ts-jest#943 and jestjs/jest#11118

@ahnpnl ahnpnl added Upstream Bug and removed 馃悰 Bug Confirmed Bug is confirmed labels Mar 4, 2021
@ahnpnl
Copy link
Collaborator

ahnpnl commented Mar 12, 2021

I will close this as fixed in next-10 . The other watch mode issue kulshekhar/ts-jest#943 was also for ts-jest to fix which is unrelated to this preset.

@ahnpnl ahnpnl closed this as completed Mar 12, 2021
@ahnpnl ahnpnl linked a pull request Mar 12, 2021 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants