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

test: cleanup tests #588

Merged
merged 1 commit into from
May 17, 2022
Merged

test: cleanup tests #588

merged 1 commit into from
May 17, 2022

Conversation

MichaelDeBoey
Copy link
Member

@MichaelDeBoey MichaelDeBoey commented May 17, 2022

Follow-up of #582, #583, #584, #585 & #587

@MichaelDeBoey MichaelDeBoey self-assigned this May 17, 2022
Base automatically changed from update-vue-tests to main May 17, 2022 16:36
@MichaelDeBoey MichaelDeBoey marked this pull request as ready for review May 17, 2022 16:36
@Belco90
Copy link
Member

Belco90 commented May 17, 2022

Thinking about all the changes we did to test all rules for the corresponding Testing Library frameworks, I think it makes sense to add some improvements to our TestingLibraryRuleMeta and createRuleTester to automatically generate the test cases variations for indicated frameworks.

In my mind, it could look like this:

// rules/foo.js
export default createTestingLibraryRule({
  // ...
  meta: {
    // ...
    supportedFrameworks: ['react', 'vue']
    // ^ we extend our TestingLibraryRuleMeta so it has this new required property,
    // which can be used also to autogenerate a table of compatible frameworks for each rule doc
  }
})

// test/lib/rules/foo.js
ruleTester.run(RULE_NAME, rule, {
  valid: [
    {
      code: `
      import { fireEvent } from '{TESTING_LIBRARY_FRAMEWORK}'
      //                                          ^ this placeholder gets replaced automatically,
      //                                             iterating over each value from supportedFrameworks
    
      await fireEvent.click(element)
      `
    }
  ]
})

I don't want to hijack the PR, so if you think this could be useful to avoid repetition, improve test maintenance, and make it easier to contribute in the future, I'll move the discussion to a new issue.

@MichaelDeBoey
Copy link
Member Author

@Belco90 We could even derive supportedFrameworks from the recommendedConfig meta.

We should even be able to run all rules on all testing frameworks though.
I currently only did this when the rule is available in the config for that specific testing framework.

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!

@MichaelDeBoey MichaelDeBoey merged commit 4cf81de into main May 17, 2022
@MichaelDeBoey MichaelDeBoey deleted the cleanup-tests branch May 17, 2022 20:09
@github-actions
Copy link

🎉 This PR is included in version 5.5.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

None yet

3 participants