@atls/code-test 2.0.4 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tester.d.ts CHANGED
@@ -2,10 +2,16 @@ import type { TestEvent } from 'node:test/reporters';
2
2
  import EventEmitter from 'node:events';
3
3
  import { run } from 'node:test';
4
4
  export type TestsStream = ReturnType<typeof run>;
5
+ type TestOptions = {
6
+ files?: Array<string>;
7
+ watch?: boolean;
8
+ };
5
9
  export declare class Tester extends EventEmitter {
6
10
  constructor();
7
11
  static initialize(): Promise<Tester>;
8
- unit(cwd: string): Promise<Array<TestEvent>>;
9
- integration(cwd: string): Promise<Array<TestEvent>>;
10
- protected run(files: Array<string>, timeout: number, concurrency: boolean): Promise<Array<TestEvent>>;
12
+ private collectTestFiles;
13
+ unit(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
14
+ integration(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
15
+ protected run(files: Array<string>, timeout: number, concurrency: boolean, watch: boolean): Promise<Array<TestEvent>>;
11
16
  }
17
+ export {};
package/dist/tester.js CHANGED
@@ -9,29 +9,41 @@ export class Tester extends EventEmitter {
9
9
  static async initialize() {
10
10
  return new Tester();
11
11
  }
12
- async unit(cwd) {
13
- return this.run(await globby(['**/!(integration)/*.test.{ts,tsx,js,jsx}'], {
12
+ async collectTestFiles(cwd, type, patterns) {
13
+ const folderPattern = type === 'unit' ? '!(integration)' : 'integration';
14
+ if (!patterns || patterns.length < 1) {
15
+ return await globby([`**/${folderPattern}/*.test.{ts,tsx,js,jsx}`], {
16
+ cwd,
17
+ dot: true,
18
+ absolute: true,
19
+ ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'],
20
+ });
21
+ }
22
+ return await globby(patterns.map((pattern) => {
23
+ return `**/${folderPattern}/*${pattern}*.test.{ts,tsx,js,jsx}`;
24
+ }), {
14
25
  cwd,
15
26
  dot: true,
16
27
  absolute: true,
17
- ignore: ['**/node_modules/**', '**/dist/**'],
18
- }), 25_000, true);
28
+ ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'],
29
+ });
19
30
  }
20
- async integration(cwd) {
21
- return this.run(await globby(['**/integration/**/*.test.{ts,tsx,js,jsx}'], {
22
- cwd,
23
- dot: true,
24
- absolute: true,
25
- ignore: ['**/node_modules/**', '**/dist/**'],
26
- }), 240_000, false);
31
+ async unit(cwd, options) {
32
+ const testFiles = await this.collectTestFiles(cwd, 'unit', options?.files);
33
+ return this.run(testFiles, 25_000, true, options?.watch ?? false);
34
+ }
35
+ async integration(cwd, options) {
36
+ const testFiles = await this.collectTestFiles(cwd, 'integration', options?.files);
37
+ return this.run(testFiles, 240_000, false, options?.watch ?? false);
27
38
  }
28
- async run(files, timeout, concurrency) {
39
+ async run(files, timeout, concurrency, watch) {
29
40
  const tests = await Tests.load(files);
30
41
  this.emit('start', { tests });
31
42
  const testsStream = run({
32
43
  files,
33
44
  timeout,
34
45
  concurrency,
46
+ watch,
35
47
  });
36
48
  const onPass = (data) => {
37
49
  this.emit('test:pass', data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atls/code-test",
3
- "version": "2.0.4",
3
+ "version": "2.0.7",
4
4
  "license": "BSD-3-Clause",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,7 +23,7 @@
23
23
  "postpack": "rm -rf dist"
24
24
  },
25
25
  "dependencies": {
26
- "@atls/code-runtime": "2.0.4",
26
+ "@atls/code-runtime": "2.0.7",
27
27
  "globby": "13.2.2"
28
28
  },
29
29
  "devDependencies": {