-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
JS/TS default rules #8
Comments
@elado why the |
yeah, they cover different common patterns for the defaults used by javascript test runners (i typically use ava and jest). I modified the rules to: "rules": [
{
"pattern": "(.+)\/([^\/]+?)\\.([tj]sx?)$",
"locators": [
"$1/{test,tests,__tests__,__test__}/$2{.spec,.test,}.$3"
]
},
{
"pattern": "src/(.+)\/([^\/]+?)\\.([tj]sx?)$",
"locators": [
"src/$1/{test,tests,__tests__,__test__}/$2{.spec,.test,}.$3",
"{test,tests,__tests__,__test__}/$1/$2{.spec,.test,}.$3",
]
},
{
"pattern": "(.+)\/(?:tests?|__tests?__)\/((?:.+?/)?(?:[^\/]+?))(?:\\.spec|\\.test)?\\.([tj]sx?)$",
"locators": [
"$1/$2.$3",
"src/$1/$2.$3"
]
},
{
"pattern": "(?:tests?|__tests?__)\/((?:.+?/)?(?:[^\/]+?))(?:\\.spec|\\.test)?\\.([tj]sx?)$",
"locators": [
"$1.$2",
"src/$1.$2"
]
}
] |
This new ruleset should also handle the common pattern of including spec files in the same directory as the code under test. This is pattern is widely followed in the Angular community (see here for an example). I'm using the following ruleset for javascript files in my Angular projects: {
"name": "javascript",
"rules": [
{
"pattern": "(.*)\\.spec\\.([tj]sx?)$",
"locators": [
"$1.$2",
]
},
{
"pattern": "(.*)\\.([tj]sx?)$",
"locators": [
"$1.spec.$2",
]
}
]
} Also I'm no regex wizard but the patterns mentioned before look like they might be more complicated than they need to be. |
This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks! |
this is what I use:
works for my projects, can probably be improved, but a good start.
The text was updated successfully, but these errors were encountered: