use crate::plugins::registry::FrameworkDetector;
pub struct JestDetector;
impl JestDetector {
pub fn new() -> Self {
Self
}
}
impl Default for JestDetector {
fn default() -> Self {
Self::new()
}
}
impl FrameworkDetector for JestDetector {
fn name(&self) -> &'static str {
"jest"
}
fn get_entry_patterns(&self) -> Vec<String> {
vec![
"**/*.test.ts".to_string(),
"**/*.test.tsx".to_string(),
"**/*.test.js".to_string(),
"**/*.test.jsx".to_string(),
"**/*.spec.ts".to_string(),
"**/*.spec.tsx".to_string(),
"**/*.spec.js".to_string(),
"**/*.spec.jsx".to_string(),
"**/__tests__/**/*.ts".to_string(),
"**/__tests__/**/*.tsx".to_string(),
"**/__tests__/**/*.js".to_string(),
"**/__tests__/**/*.jsx".to_string(),
"jest.config.js".to_string(),
"jest.config.ts".to_string(),
"jest.config.mjs".to_string(),
"jest.setup.js".to_string(),
"jest.setup.ts".to_string(),
"setupTests.js".to_string(),
"setupTests.ts".to_string(),
]
}
fn get_special_exports(&self) -> Vec<&'static str> {
vec![
"describe",
"it",
"test",
"expect",
"beforeAll",
"afterAll",
"beforeEach",
"afterEach",
"setup",
"teardown",
"toMatchSnapshot",
"default",
]
}
fn detect_from_dependencies(&self, deps: &[String]) -> bool {
deps.iter().any(|d| d == "jest" || d == "@jest/core")
}
}