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

no-standalone-expect: False positive when there are multiple describe blocks #291

Closed
michaelfaith opened this issue May 7, 2024 · 8 comments
Labels
bug Something isn't working need more info This issue is missing details or reproduction steps

Comments

@michaelfaith
Copy link

michaelfaith commented May 7, 2024

If using nested describe blocks to organize multiple sets of tests, the expect calls within the it tests in the describe blocks after the first, are causing no-standalone-expect to flag them incorrectly.

describe('base', () => {
  it('top level test', async () => {
    expect... // << this one doesn't flag
  });

  describe('nested', () => {
    it('nested test', async () => {
      expect... // << this one flags no-standalone-expect (false positive)
    });
  });
});

Note: if the test function is test instead of it, then it also doesn't flag. It only seems to impact tests that use it

@mskelton
Copy link
Member

mskelton commented May 7, 2024

Interesting, sounds like an issue with the aliases not applying in all instances for some reason.

@mskelton mskelton added the bug Something isn't working label May 7, 2024
@mskelton
Copy link
Member

mskelton commented Jun 9, 2024

@michaelfaith I was unable to reproduce this. Could you create a reproduction code sandbox?

@mskelton mskelton added the need more info This issue is missing details or reproduction steps label Jun 9, 2024
@mskelton
Copy link
Member

Closing due to lack of reproduction steps

@mskelton mskelton closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2024
@michaelfaith
Copy link
Author

michaelfaith commented Jun 28, 2024

@mskelton Sorry for not responding sooner. I can upload a reproduction, but a really simple recreation that might help shows how simply aliasing the test import breaks this test:

image

This isn't exactly the same as our issue; I still need to dig into our set up to see what we're doing in terms of aliasing, but this is a simple recreation.

@michaelfaith
Copy link
Author

It's also worth noting that it broke the expect-expect test too. That "basic test without expect" it should have a violation that it didn't report here.

@mskelton mskelton reopened this Jun 29, 2024
@mskelton
Copy link
Member

mskelton commented Jul 1, 2024

@michaelfaith I'm guessing you didn't configure global aliases in your config.

https://github.com/playwright-community/eslint-plugin-playwright#aliased-playwright-globals

@michaelfaith
Copy link
Author

@michaelfaith I'm guessing you didn't configure global aliases in your config.

https://github.com/playwright-community/eslint-plugin-playwright#aliased-playwright-globals

I did not. Is that necessary even for local import aliases, like this? I confirmed that if I add the following, it works as expected.

settings: {
  playwright: {
    globalAliases: {
      test: ['it'],
    },
  },
},

@mskelton
Copy link
Member

mskelton commented Jul 2, 2024

@michaelfaith Yes, it's necessary even with import aliases. The primary reason for this is that imports often can come from files which define fixtures, so the import source isn't always just @playwright/test, so auto-detecting it is not something that can always be done.

@mskelton mskelton closed this as completed Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need more info This issue is missing details or reproduction steps
Projects
None yet
Development

No branches or pull requests

2 participants