Open elado opened 6 years ago
@elado why the tests,__tests__,__test__
to handle differently named test folders?
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.