Repository: artusjs/core
Pull request #224 (2022-12-21 07:42:32)

fix: correct test dir
将原来配置的 `test/` 改成 `test`，因为匹配的都是文件夹名和文件名，有 `/` 会导致匹配不到 test 目录。

codecov-commenter: # [Codecov](https://codecov.io/gh/artusjs/core/pull/224?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
Base: **92.66**% // Head: **92.66**% // No change to project coverage :thumbsup:
> Coverage data is based on head [(`6b7e6c1`)](https://codecov.io/gh/artusjs/core/pull/224?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) compared to base [(`595946b`)](https://codecov.io/gh/artusjs/core/commit/595946bc49d8cfe7930f86519336ae52ed449833?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).
> Patch has no changes to coverable lines.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master     #224   +/-   ##
=======================================
  Coverage   92.66%   92.66%           
=======================================
  Files          55       55           
  Lines        1296     1296           
  Branches      218      218           
=======================================
  Hits         1201     1201           
  Misses         95       95           
```


| [Impacted Files](https://codecov.io/gh/artusjs/core/pull/224?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [src/constant.ts](https://codecov.io/gh/artusjs/core/pull/224/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2NvbnN0YW50LnRz) | `100.00% <ø> (ø)` | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/artusjs/core/pull/224?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None).


Patch:
diff --git a/src/constant.ts b/src/constant.ts
index b4bf105..12acee3 100644
--- a/src/constant.ts
+++ b/src/constant.ts
@@ -33,7 +33,7 @@ export const HOOK_FILE_LOADER = 'appHook:fileLoader';
 export const HOOK_CONFIG_HANDLE = 'appHook:configHandle::';
 
 export const DEFAULT_EXCLUDES = [
-  'test/',
+  'test',
   'node_modules',
   '.*',
   'tsconfig*.json',


Test patch:
diff --git a/test/fixtures/app_with_lifecycle/test/throw.ts b/test/fixtures/app_with_lifecycle/test/throw.ts
new file mode 100644
index 0000000..87af525
--- /dev/null
+++ b/test/fixtures/app_with_lifecycle/test/throw.ts
@@ -0,0 +1,1 @@
+throw new Error('should not scan me');
diff --git a/test/scanner.test.ts b/test/scanner.test.ts
index dbb487d..489f665 100644
--- a/test/scanner.test.ts
+++ b/test/scanner.test.ts
@@ -49,6 +49,14 @@ describe('test/scanner.test.ts', () => {
     });
   });
 
+  it('should not scan test dir', async () => {
+    const scanner = new Scanner({ needWriteFile: false, extensions: ['.ts', '.js', '.json'] });
+    const scanResults = await scanner.scan(path.resolve(__dirname, './fixtures/app_with_lifecycle'));
+    const { default: manifest } = scanResults;
+    expect(manifest.items).toBeDefined();
+    expect(manifest.items.find(item => item.filename === 'throw.ts')).toBeUndefined();
+  });
+
   it('should scan module with custom loader', async () => {
     // TODO: allow scan custom loader
     const { default: TestCustomLoader } = await import('./fixtures/module_with_custom_loader/src/loader/test_custom_loader');