Skip to content

Commit

Permalink
Support nested comment-based tests, used for separate Fixtures with s…
Browse files Browse the repository at this point in the history
…eparate `package.json` dependencies
  • Loading branch information
kebetsi authored and ilia-kebets-sonarsource committed Dec 6, 2023
1 parent ad4e308 commit 607d1be
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
},
testMatch: [
'<rootDir>/packages/*/tests/**/*.test.ts',
'<rootDir>/packages/*/src/rules/*/*.test.ts',
'<rootDir>/packages/*/src/rules/**/*.test.ts',
],
testTimeout: 20000,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"jsxFragmentFactory": "Fragment"
},
"files": [
"unit.fixture.tsx"
"file.tsx"
]
}
12 changes: 6 additions & 6 deletions packages/jsts/src/rules/S1128/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ ruleTesterTS.run('Unnecessary imports should be removed', rule, {
});

const project = path.join(__dirname, 'fixtures', 'tsconfig.fixture.json');
const filename = path.join(__dirname, 'fixtures', 'unit.fixture.tsx');
const filename = path.join(__dirname, 'fixtures', 'file.tsx');

const ruleTesterJsxFactory = new RuleTester({
parserOptions: {
Expand Down Expand Up @@ -416,7 +416,7 @@ ruleTesterVue.run('Unnecessary imports should be removed', rule, {
code: `
<script setup>
import Foo from './Foo.vue'
</script>
</script>
<template>
<Foo />
</template>
Expand All @@ -426,7 +426,7 @@ ruleTesterVue.run('Unnecessary imports should be removed', rule, {
code: `
<script setup>
import MyFoo from './MyFoo.vue'
</script>
</script>
<template>
<my-foo />
</template>
Expand All @@ -436,7 +436,7 @@ ruleTesterVue.run('Unnecessary imports should be removed', rule, {
code: `
<script setup>
import {foo} from './foo'
</script>
</script>
<template>
<div @click="foo()" />
</template>
Expand All @@ -446,7 +446,7 @@ ruleTesterVue.run('Unnecessary imports should be removed', rule, {
code: `
<script setup>
import {isFoo} from './foo'
</script>
</script>
<template>
<div v-if="isFoo" />
</template>
Expand All @@ -468,7 +468,7 @@ ruleTesterVue.run('Unnecessary imports should be removed', rule, {
code: `
<script setup>
import Foo from './Foo.vue'
</script>
</script>
<template>
<div />
</template>
Expand Down
6 changes: 3 additions & 3 deletions packages/jsts/tests/tools/testers/comment-based/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ const ruleTester = new RuleTester({ parser: __filename });
*/
export function check(ruleId: string, ruleModule: Rule.RuleModule, ruleDir: string) {
const fixtures = [];
for (const file of fs.readdirSync(ruleDir)) {
if (/\.fixture\.(js|ts|jsx|tsx|vue)$/.exec(file)) {
const fixture = path.join(ruleDir, file);
for (const file of fs.readdirSync(ruleDir, { recursive: true })) {
if (/\.fixture\.(js|ts|jsx|tsx|vue)$/.exec(file as string)) {
const fixture = path.join(ruleDir, file as string);
fixtures.push(fixture);
}
}
Expand Down

0 comments on commit 607d1be

Please sign in to comment.