@atls/code-test 2.0.12 → 2.0.16

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/CHANGELOG.md ADDED
@@ -0,0 +1,37 @@
1
+
2
+
3
+ ## [2.0.16](https://github.com/atls/raijin/compare/@atls/code-test@2.0.15...@atls/code-test@2.0.16) (2025-03-09)
4
+
5
+
6
+ ### Features
7
+
8
+
9
+ * **common:** bump ([#494](https://github.com/atls/raijin/issues/494)) ([381d535](https://github.com/atls/raijin/commit/381d5357c2818e157330933edb9256936d251ca3))
10
+
11
+
12
+
13
+ ## [2.0.15](https://github.com/atls/raijin/compare/@atls/code-test@2.0.15...@atls/code-test@2.0.15) (2025-03-09)
14
+
15
+ ### Features
16
+
17
+ - **common:** bump ([#494](https://github.com/atls/raijin/issues/494)) ([381d535](https://github.com/atls/raijin/commit/381d5357c2818e157330933edb9256936d251ca3))
18
+
19
+ ## [2.0.15](https://github.com/atls/raijin/compare/@atls/code-test@2.0.14...@atls/code-test@2.0.15) (2025-02-24)
20
+
21
+ ### Bug Fixes
22
+
23
+ - **common:** yarn check ([#485](https://github.com/atls/raijin/issues/485)) ([b0c3cfa](https://github.com/atls/raijin/commit/b0c3cfad8f559c55691ca733c7a3a7b3cd00c4d8))
24
+
25
+ ## [2.0.14](https://github.com/atls/raijin/compare/@atls/code-test@2.0.14...@atls/code-test@2.0.14) (2025-01-30)
26
+
27
+ ### Bug Fixes
28
+
29
+ - **common:** yarn check ([#485](https://github.com/atls/raijin/issues/485)) ([b0c3cfa](https://github.com/atls/raijin/commit/b0c3cfad8f559c55691ca733c7a3a7b3cd00c4d8))
30
+
31
+ ## <small>2.0.14 (2025-01-01)</small>
32
+
33
+ - Merge pull request #475 from atls/fix/release ([a578cda](https://github.com/atls/raijin/commit/a578cda)), closes [#475](https://github.com/atls/raijin/issues/475)
34
+
35
+ ## <small>2.0.13 (2025-01-01)</small>
36
+
37
+ - feat(code-test): general test command, tap output (#473) ([995776b](https://github.com/atls/raijin/commit/995776b)), closes [#473](https://github.com/atls/raijin/issues/473)
package/dist/tester.d.ts CHANGED
@@ -5,15 +5,17 @@ export type TestsStream = ReturnType<typeof run>;
5
5
  type TestOptions = {
6
6
  files?: Array<string>;
7
7
  watch?: boolean;
8
+ testReporter?: string;
8
9
  };
9
10
  export declare class Tester extends EventEmitter {
10
11
  constructor();
12
+ protected run(files: Array<string>, timeout: number, concurrency: boolean, watch?: boolean, testReporter?: string): Promise<Array<TestEvent>>;
11
13
  static initialize(): Promise<Tester>;
14
+ unit(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
15
+ integration(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
16
+ general(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
12
17
  private collectTestFiles;
13
18
  private isFilename;
14
19
  private isRootPath;
15
- unit(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
16
- integration(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
17
- protected run(files: Array<string>, timeout: number, concurrency: boolean, watch: boolean): Promise<Array<TestEvent>>;
18
20
  }
19
21
  export {};
package/dist/tester.js CHANGED
@@ -1,56 +1,23 @@
1
1
  import EventEmitter from 'node:events';
2
2
  import { run } from 'node:test';
3
+ import { tap } from 'node:test/reporters';
3
4
  import { globby } from 'globby';
4
5
  import { Tests } from './tests.js';
5
6
  export class Tester extends EventEmitter {
6
7
  constructor() {
7
8
  super();
8
9
  }
9
- static async initialize() {
10
- return new Tester();
11
- }
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
- });
10
+ async run(files, timeout, concurrency, watch = false, testReporter) {
11
+ if (testReporter === 'tap') {
12
+ const result = run({
13
+ files,
14
+ timeout,
15
+ concurrency,
16
+ watch,
17
+ }).compose(tap);
18
+ result.pipe(process.stdout);
19
+ return result.toArray();
21
20
  }
22
- return await globby(patterns.map((pattern) => {
23
- if (this.isFilename(pattern)) {
24
- return `**/${folderPattern}/*${pattern}*.test.{ts,tsx,js,jsx}`;
25
- }
26
- if (this.isRootPath(pattern)) {
27
- return pattern;
28
- }
29
- return `**/${pattern}`;
30
- }), {
31
- cwd,
32
- dot: true,
33
- absolute: true,
34
- ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'],
35
- });
36
- }
37
- isFilename(pattern) {
38
- const hasPathSeparator = pattern.includes('/') || pattern.includes('\\');
39
- const hasValidExtension = /\.(js|jsx|ts|tsx)$/.test(pattern);
40
- return !hasPathSeparator && !hasValidExtension;
41
- }
42
- isRootPath(pattern) {
43
- return pattern.startsWith('/') || pattern.startsWith('\\');
44
- }
45
- async unit(cwd, options) {
46
- const testFiles = await this.collectTestFiles(cwd, 'unit', options?.files);
47
- return this.run(testFiles, 25_000, true, options?.watch ?? false);
48
- }
49
- async integration(cwd, options) {
50
- const testFiles = await this.collectTestFiles(cwd, 'integration', options?.files);
51
- return this.run(testFiles, 240_000, false, options?.watch ?? false);
52
- }
53
- async run(files, timeout, concurrency, watch) {
54
21
  const tests = await Tests.load(files);
55
22
  this.emit('start', { tests });
56
23
  const testsStream = run({
@@ -86,4 +53,55 @@ export class Tester extends EventEmitter {
86
53
  testsStream.off('test:stderr', onStderr);
87
54
  }
88
55
  }
56
+ static async initialize() {
57
+ return new Tester();
58
+ }
59
+ async unit(cwd, options) {
60
+ const testFiles = await this.collectTestFiles(cwd, 'unit', options?.files);
61
+ return this.run(testFiles, 25_000, true, options?.watch, options?.testReporter);
62
+ }
63
+ async integration(cwd, options) {
64
+ const testFiles = await this.collectTestFiles(cwd, 'integration', options?.files);
65
+ return this.run(testFiles, 240_000, false, options?.watch, options?.testReporter);
66
+ }
67
+ async general(cwd, options) {
68
+ const testFiles = await this.collectTestFiles(cwd, undefined, options?.files);
69
+ return this.run(testFiles, 240_000, true, options?.watch, options?.testReporter);
70
+ }
71
+ async collectTestFiles(cwd, type, patterns) {
72
+ let folderPattern = '*';
73
+ if (type !== undefined) {
74
+ folderPattern = type === 'unit' ? '!(integration)' : 'integration';
75
+ }
76
+ if (!patterns || patterns.length < 1) {
77
+ return globby([`**/${folderPattern}/*.test.{ts,tsx,js,jsx}`], {
78
+ cwd,
79
+ dot: true,
80
+ absolute: true,
81
+ ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'],
82
+ });
83
+ }
84
+ return globby(patterns.map((pattern) => {
85
+ if (this.isFilename(pattern)) {
86
+ return `**/${folderPattern}/*${pattern}*.test.{ts,tsx,js,jsx}`;
87
+ }
88
+ if (this.isRootPath(pattern)) {
89
+ return pattern;
90
+ }
91
+ return `**/${pattern}`;
92
+ }), {
93
+ cwd,
94
+ dot: true,
95
+ absolute: true,
96
+ ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'],
97
+ });
98
+ }
99
+ isFilename(pattern) {
100
+ const hasPathSeparator = pattern.includes('/') || pattern.includes('\\');
101
+ const hasValidExtension = /\.(js|jsx|ts|tsx)$/.test(pattern);
102
+ return !hasPathSeparator && !hasValidExtension;
103
+ }
104
+ isRootPath(pattern) {
105
+ return pattern.startsWith('/') || pattern.startsWith('\\');
106
+ }
89
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atls/code-test",
3
- "version": "2.0.12",
3
+ "version": "2.0.16",
4
4
  "license": "BSD-3-Clause",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,11 +23,11 @@
23
23
  "postpack": "rm -rf dist"
24
24
  },
25
25
  "dependencies": {
26
- "@atls/code-runtime": "2.1.2",
26
+ "@atls/code-runtime": "2.1.7",
27
27
  "globby": "13.2.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@types/node": "22.9.0"
30
+ "@types/node": "22.13.10"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public",