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

feat: add support for @marko/testing-library #572

Merged
merged 22 commits into from
May 11, 2022

Conversation

PrashantAshok
Copy link
Contributor

@PrashantAshok PrashantAshok commented Apr 28, 2022

Checks

  • I have read the contributing guidelines.
  • If some rule is added/updated/removed, I've regenerated the rules list.
  • If some rule meta info is changed, I've regenerated the plugin shared configs.

Changes

  • Add @marko/testing-library to the list of supported testing library frameworks

Context

As suggested in #80

@MichaelDeBoey MichaelDeBoey changed the title feat: add support for @marko/testing-library feat: add support for @marko/testing-library Apr 29, 2022
@MichaelDeBoey MichaelDeBoey marked this pull request as draft April 29, 2022 10:36
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @PrashantAshok! Thanks for your contribution. There are a few things missing tho:

  • Update the README with a new label for Marko testing framework
  • Since rules meta have changed, the plugin shared configs must be regenerated
  • We should add some tests to the fake-rule.ts to make sure that @marko/testing-library is correctly reported as a Testing Library framework

@MichaelDeBoey
Copy link
Member

@PrashantAshok Can you please add extra test cases for each rule, so we can see that all rules are still working?

@PrashantAshok
Copy link
Contributor Author

PrashantAshok commented Apr 29, 2022

@Belco90 @MichaelDeBoey - thanks for the review. I missed updating README, let me update that along with the tests.

Since rules meta have changed, the plugin shared configs must be regenerated

Sorry, I didn't get this point. How do I generate one? Did you mean the files under config? I already generated one for marko

We should add some tests to the fake-rule.ts to make sure that @marko/testing-library is correctly reported as a Testing Library framework

Sorry, any pointers on how would I go about verifying it? And is it some other file, since fake-rule.ts is not a test file.

@PrashantAshok
Copy link
Contributor Author

@PrashantAshok Can you please add extra test cases for each rule, so we can see that all rules are still working?

Do I need to add tests for every rule or just the ones that is specific to Marko, e.g. await-fire-event.ts? (comparing the current tests with other frameworks like Angular, Vue etc)

@MichaelDeBoey
Copy link
Member

@PrashantAshok Each rule should have some basic framework-specific tests to see that the rule works as expected, even if it's not doing anything "special".

Not all rules have them currently, but it would be good to start doing it anyways.

@Belco90
Copy link
Member

Belco90 commented Apr 30, 2022

Writing tests for Marko on each rule shouldn't be necessary! We actually haven't read a test for each testing framework on each rule. Adding some tests in create-testing-library-rule.test.ts (not fake-rule, sorry) should be enough.

@MichaelDeBoey
Copy link
Member

Adding some tests in create-testing-library-rule.test.ts should be enough.

How would we even know 100% certain that all rules are actually working properly for the plugin?

@Belco90
Copy link
Member

Belco90 commented May 1, 2022

How would we even know 100% certain that all rules are actually working properly for the plugin?

In the same way as we do with the rest of the testing frameworks: assuming it works as expected by testing the core utils fromcreate-testing-library-rules.

@MichaelDeBoey
Copy link
Member

assuming it works as expected

@Belco90 Well, that's what I think we should stop doing: assuming.

Supporting a new testing framework is the perfect opportunity to start really testing that all rules work on this framework.
We'll probably have some "unnecessary" tests, but confidence is at 100% for a very low cost imo.

@Belco90
Copy link
Member

Belco90 commented May 1, 2022

assuming it works as expected

@Belco90 Well, that's what I think we should stop doing: assuming.

Supporting a new testing framework is the perfect opportunity to start really testing that all rules work on this framework. We'll probably have some "unnecessary" tests, but confidence is at 100% for a very low cost imo.

Ok, let's cover the rules that are specific for Marko then.

Sorry, I didn't get this point. How do I generate one? Did you mean the files under config? I already generated one for marko

Sorry @PrashantAshok, I thought this was covered in the CONTRIBUTING.md, but it's not! You can regenerate this with npm run generate:configs, and the rules list with npm run generate:rules-list.


To summarize the changes needed:

  • Update the README with a new label for Marko testing framework
  • Regenerate the plugin shared configs
  • Add an extra test for @marko/testing-library to create-testing-library-rule.test.ts
  • Add an extra valid test and invalid test for those rules compatibles with @marko/testing-library (duplicating a basic existing test changing the Testing Library module imported should be fine).

@PrashantAshok
Copy link
Contributor Author

Thanks @Belco90 for detailed suggestions. Points 1, 2 and 3 are done and pushed. Please have a look. (Currently there is no icon for Marko in simple-icons repo, have created an issue. Have 2 options for now - either we can render the icon without the logo Or I can create link with the entire svg file, but this would be too long. Let me know and I can update the draft PR accordingly)

Sure, I can add them. But sorry, I maybe missing something, are the current rule related tests dependent on any framework? For e.g. for this test case, the tests still pass if I pass in a random name

function createTestCode({ code, isAsync = true }: TestCode) {
  return `
    import { render } from '@testing-library/some-random-name'
    test("An example test",${isAsync ? ' async ' : ' '}() => {
      ${code}
    })
  `;
}

@Belco90
Copy link
Member

Belco90 commented May 2, 2022

Have 2 options for now - either we can render the icon without the logo Or I can create link with the entire svg file, but this would be too long. Let me know and I can update the draft PR accordingly)

Let's do it without logo, that's fine.

are the current rule related tests dependent on any framework? For e.g. for this test case, the tests still pass if I pass in a random name

There are some in specific rules, but we usually use just '@testing-library/{whatever}' because the core utils of the plugin will assume everything from @testing-library scope belongs to Testing Library. The problem with the Marko one is that it belongs to the @marko scope, so we need to make sure the rules will report things related to it as expected, since doesn't follow the same pattern.

@PrashantAshok
Copy link
Contributor Author

@Belco90 - added a test, can you please check this commit - If it's good, I will go ahead and add for the rest of the relevant rules as well.

@Belco90
Copy link
Member

Belco90 commented May 3, 2022

@Belco90 - added a test, can you please check this commit - If it's good, I will go ahead and add for the rest of the relevant rules as well.

That's perfect! 👌

@PrashantAshok
Copy link
Contributor Author

@Belco90 @MichaelDeBoey - all the suggested changed done and pushed.

tests/lib/rules/await-fire-event.test.ts Show resolved Hide resolved
tests/lib/rules/no-dom-import.test.ts Outdated Show resolved Hide resolved
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good at first sight, but I want to review it later again, just in case.

lib/rules/no-dom-import.ts Show resolved Hide resolved
tests/create-testing-library-rule.test.ts Show resolved Hide resolved
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just detected 2 tests files missing an invalid test for Marko. When that's done, it should be ready to go!

tests/lib/rules/no-container.test.ts Show resolved Hide resolved
Belco90
Belco90 previously approved these changes May 7, 2022
Copy link
Member

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@PrashantAshok PrashantAshok marked this pull request as ready for review May 10, 2022 01:25
@Belco90 Belco90 requested a review from MichaelDeBoey May 10, 2022 16:54
@Belco90 Belco90 dismissed MichaelDeBoey’s stale review May 11, 2022 10:41

All requests sorted out.

@Belco90 Belco90 merged commit e332173 into testing-library:main May 11, 2022
@github-actions
Copy link

🎉 This PR is included in version 5.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Belco90
Copy link
Member

Belco90 commented May 11, 2022

@all-contributors please add @PrashantAshok for code, tests

@allcontributors
Copy link
Contributor

@Belco90

I've put up a pull request to add @PrashantAshok! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants