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

Refactor lexer tests to expose test function #24

Closed
1 task done
darylwright opened this issue Apr 16, 2024 · 4 comments
Closed
1 task done

Refactor lexer tests to expose test function #24

darylwright opened this issue Apr 16, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request released

Comments

@darylwright
Copy link
Member

darylwright commented Apr 16, 2024

Summary

Use the example herehere to refactor the lexer tests so that the test function is exposed in those suites. This allows the IDE to detect tests for better integration and runnability. Also determine if Ava has native support for repeating tests on different data.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@darylwright darylwright added the enhancement New feature or request label Apr 16, 2024
@darylwright
Copy link
Member Author

darylwright commented Apr 17, 2024

A major drawback of the approach in the struck through link is that all lexer assertions would be consolidated into a single test function, making it difficult to diagnose multiple lexer issues simultaneously. To that end, do not use the above example.

@darylwright
Copy link
Member Author

It seems that using Ava's macros is the ideal approach here. We have the benefit of both reusing test implementation logic and being able to execute an individual test via the IDE.

@darylwright
Copy link
Member Author

darylwright commented Apr 17, 2024

The following find and replace regex can be used (in WebStorm at least) to quickly convert the existing lexer test data to test declarations referencing a 'macro' function:

Find: \{\n\s+pattern:\s+('[^\n]+'|`[\w\s.;\\]*`),\n\s+expected:\s+(\[([\s\w{}',:$.]*)\]),\n\s+title:\s+('[^\n]+')\n\s+}
Replace: test($4, macro, $1, $2);

Some minor clean up will be necessary afterwards.

Edit: The regex may need to be updated as necessary.

@darylwright darylwright self-assigned this Apr 19, 2024
@darylwright
Copy link
Member Author

🎉 This issue has been resolved in version 2.3.0 🎉

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
enhancement New feature or request released
Projects
None yet
Development

No branches or pull requests

1 participant