@atls/code-test 2.0.11 → 2.0.14
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 +10 -0
- package/dist/tester.d.ts +3 -1
- package/dist/tester.js +24 -6
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## <small>2.0.14 (2025-01-01)</small>
|
|
2
|
+
|
|
3
|
+
* 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)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## <small>2.0.13 (2025-01-01)</small>
|
|
9
|
+
|
|
10
|
+
- 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,6 +5,7 @@ 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();
|
|
@@ -14,6 +15,7 @@ export declare class Tester extends EventEmitter {
|
|
|
14
15
|
private isRootPath;
|
|
15
16
|
unit(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
|
|
16
17
|
integration(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
|
|
17
|
-
|
|
18
|
+
general(cwd: string, options?: TestOptions): Promise<Array<TestEvent>>;
|
|
19
|
+
protected run(files: Array<string>, timeout: number, concurrency: boolean, watch?: boolean, testReporter?: string): Promise<Array<TestEvent>>;
|
|
18
20
|
}
|
|
19
21
|
export {};
|
package/dist/tester.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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 {
|
|
@@ -10,16 +11,19 @@ export class Tester extends EventEmitter {
|
|
|
10
11
|
return new Tester();
|
|
11
12
|
}
|
|
12
13
|
async collectTestFiles(cwd, type, patterns) {
|
|
13
|
-
|
|
14
|
+
let folderPattern = '*';
|
|
15
|
+
if (type !== undefined) {
|
|
16
|
+
folderPattern = type === 'unit' ? '!(integration)' : 'integration';
|
|
17
|
+
}
|
|
14
18
|
if (!patterns || patterns.length < 1) {
|
|
15
|
-
return
|
|
19
|
+
return globby([`**/${folderPattern}/*.test.{ts,tsx,js,jsx}`], {
|
|
16
20
|
cwd,
|
|
17
21
|
dot: true,
|
|
18
22
|
absolute: true,
|
|
19
23
|
ignore: ['**/node_modules/**', '**/dist/**', '**/.yarn/**'],
|
|
20
24
|
});
|
|
21
25
|
}
|
|
22
|
-
return
|
|
26
|
+
return globby(patterns.map((pattern) => {
|
|
23
27
|
if (this.isFilename(pattern)) {
|
|
24
28
|
return `**/${folderPattern}/*${pattern}*.test.{ts,tsx,js,jsx}`;
|
|
25
29
|
}
|
|
@@ -44,13 +48,27 @@ export class Tester extends EventEmitter {
|
|
|
44
48
|
}
|
|
45
49
|
async unit(cwd, options) {
|
|
46
50
|
const testFiles = await this.collectTestFiles(cwd, 'unit', options?.files);
|
|
47
|
-
return this.run(testFiles, 25_000, true, options?.watch
|
|
51
|
+
return this.run(testFiles, 25_000, true, options?.watch, options?.testReporter);
|
|
48
52
|
}
|
|
49
53
|
async integration(cwd, options) {
|
|
50
54
|
const testFiles = await this.collectTestFiles(cwd, 'integration', options?.files);
|
|
51
|
-
return this.run(testFiles, 240_000, false, options?.watch
|
|
55
|
+
return this.run(testFiles, 240_000, false, options?.watch, options?.testReporter);
|
|
56
|
+
}
|
|
57
|
+
async general(cwd, options) {
|
|
58
|
+
const testFiles = await this.collectTestFiles(cwd, undefined, options?.files);
|
|
59
|
+
return this.run(testFiles, 240_000, true, options?.watch, options?.testReporter);
|
|
52
60
|
}
|
|
53
|
-
async run(files, timeout, concurrency, watch) {
|
|
61
|
+
async run(files, timeout, concurrency, watch = false, testReporter) {
|
|
62
|
+
if (testReporter === 'tap') {
|
|
63
|
+
const result = run({
|
|
64
|
+
files,
|
|
65
|
+
timeout,
|
|
66
|
+
concurrency,
|
|
67
|
+
watch,
|
|
68
|
+
}).compose(tap);
|
|
69
|
+
result.pipe(process.stdout);
|
|
70
|
+
return result.toArray();
|
|
71
|
+
}
|
|
54
72
|
const tests = await Tests.load(files);
|
|
55
73
|
this.emit('start', { tests });
|
|
56
74
|
const testsStream = run({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atls/code-test",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
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.1.
|
|
26
|
+
"@atls/code-runtime": "2.1.2",
|
|
27
27
|
"globby": "13.2.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|