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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run test-unit:watch no longer supports focused tests #36067

Closed
talldan opened this issue Oct 29, 2021 · 7 comments
Closed

npm run test-unit:watch no longer supports focused tests #36067

talldan opened this issue Oct 29, 2021 · 7 comments
Labels
[Package] Scripts /packages/scripts [Type] Bug An existing feature does not function as intended

Comments

@talldan
Copy link
Contributor

talldan commented Oct 29, 2021

The test runner no longer seems to support changing a test to describe.only or it.only.

To reproduce:

  1. Run npm run test-unit:watch
  2. Change a unit test to it.only.
  3. Observe that the focused test is ignored. (this might depend on which test is set to only, I noticed this while trying it on describe( 'undo' - https://github.com/WordPress/gutenberg/blob/trunk/packages/core-data/src/test/reducer.js#L144)
@talldan talldan added [Type] Bug An existing feature does not function as intended [Package] Scripts /packages/scripts labels Oct 29, 2021
@talldan talldan changed the title npm run test-unit:watch no longer allows focus tests npm run test-unit:watch no longer supports focus tests Oct 29, 2021
@talldan talldan changed the title npm run test-unit:watch no longer supports focus tests npm run test-unit:watch no longer supports focused tests Oct 29, 2021
@gziolo
Copy link
Member

gziolo commented Nov 2, 2021

Isn't it related to the different test runner – Jest Circus – that is used with unit tests for some time? It's a new default starting from Jest 27 that we are going to update to quite soon anyway. Maybe this issue doesn't exist in Jest 27 anymore. We can test against #33287. I doubt it's anything on the @wordpress/scripts side.

@simonhammes
Copy link
Contributor

I tried to reproduce this, following the outlined steps:

  1. Run npm run test-unit:watch
  2. Change a unit test to it.only.
  3. Observe that the focused test is ignored. (this might depend on which test is set to only, I noticed this while trying it on describe( 'undo' - https://github.com/WordPress/gutenberg/blob/trunk/packages/core-data/src/test/reducer.js#L144)

But it works for me (on trunk, using npm ci).
I modified the exact line in reducer.js to describe.only and Jest only executed this section.

@kevin940726
Copy link
Member

I can't reproduce this either. For me, it's correctly running only the tests I specified. @talldan Could you provide more info or maybe try it with a different setup?

@gziolo gziolo added the [Status] Needs More Info Follow-up required in order to be actionable. label Nov 10, 2021
@talldan
Copy link
Contributor Author

talldan commented Nov 11, 2021

It still doesn't work for me. Here's a screenshot:
Screenshot 2021-11-11 at 10 25 00 am

To reproduce this:

  1. Run npm run test-unit:watch
  2. Add a focus test in the reducer file
  3. Change the name of a test in the selectors file.

Expected - only the reducer test executes because it's focused
Actual - the test runner runs the focused test in addition to the other modified tests

@talldan talldan removed the [Status] Needs More Info Follow-up required in order to be actionable. label Nov 11, 2021
@kevin940726
Copy link
Member

Oh, I think this is expected? only only focuses tests in the same file, it doesn't prevent tests in other files from running.

@talldan
Copy link
Contributor Author

talldan commented Nov 11, 2021

Ah, ok, fair enough, didn't realise that. Seems like a bit of a useless feature, and I don't think it previously worked that way.

@talldan talldan closed this as completed Nov 11, 2021
@kevin940726
Copy link
Member

I believe it always works that way though 😅 , or at least suppose to. I normally filter the files in watch mode if I only want to focus some of the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Scripts /packages/scripts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants