Skip to content

Commit dbfb2bd

Browse files
committed
feat: migrate to esm modules
1 parent 20bff12 commit dbfb2bd

File tree

12 files changed

+1017
-289
lines changed

12 files changed

+1017
-289
lines changed

CHANGELOG.md

Whitespace-only changes.

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> Convert JUnit reports to CTRF reports
44
5-
This package is useful if there isn't a CTRF reporter available for your test framework.
5+
This package is useful if there isn't a CTRF reporter available for your test framework. It can be used via the CLI or added as a dependency to your project.
66

77
<div align="center">
88
<div style="padding: 1.5rem; border-radius: 8px; margin: 1rem 0; border: 1px solid #30363d;">
@@ -27,7 +27,23 @@ Explore more <a href="https://www.ctrf.io/integrations">integrations</a>
2727
</p>
2828
</div>
2929

30-
## Usage
30+
## Installation
31+
32+
```sh
33+
npm install [email protected]
34+
```
35+
36+
```ts
37+
import { convertJUnitToCTRFReport } from 'junit-to-ctrf';
38+
39+
const report = await convertJUnitToCTRFReport('path/to/junit.xml');
40+
```
41+
42+
## API reference
43+
44+
See [API reference](./docs) for more details.
45+
46+
## CLI Usage
3147

3248
```sh
3349
npx junit-to-ctrf path/to/junit.xml
@@ -98,6 +114,8 @@ Combine all options in a single command:
98114
npx junit-to-ctrf path/to/junit.xml -o path/to/output/ctrf-report.json -t ExampleTool -e appName=MyApp buildName=MyBuild
99115
```
100116

117+
## API reference
118+
101119
## What is CTRF?
102120

103121
CTRF is a universal JSON test report schema that addresses the lack of a standardized format for JSON test reports.

docs/README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
**JUnit to CTRF v0.0.10-next.0**
2+
3+
***
4+
5+
# Convert JUnit XML to CTRF JSON
6+
7+
> Convert JUnit reports to CTRF reports
8+
9+
This package is useful if there isn't a CTRF reporter available for your test framework. It can be used via the CLI or added as a dependency to your project.
10+
11+
<div align="center">
12+
<div style="padding: 1.5rem; border-radius: 8px; margin: 1rem 0; border: 1px solid #30363d;">
13+
<span style="font-size: 23px;">💚</span>
14+
<h3 style="margin: 1rem 0;">CTRF tooling is open source and free to use</h3>
15+
<p style="font-size: 16px;">You can support the project with a follow and a star</p>
16+
17+
<div style="margin-top: 1.5rem;">
18+
<a href="https://github.com/ctrf-io/junit-to-ctrf">
19+
<img src="https://img.shields.io/github/stars/ctrf-io/junit-to-ctrf?style=for-the-badge&color=2ea043" alt="GitHub stars">
20+
</a>
21+
<a href="https://github.com/ctrf-io">
22+
<img src="https://img.shields.io/github/followers/ctrf-io?style=for-the-badge&color=2ea043" alt="GitHub followers">
23+
</a>
24+
</div>
25+
</div>
26+
27+
<p style="font-size: 14px; margin: 1rem 0;">
28+
Maintained by <a href="https://github.com/ma11hewthomas">Matthew Thomas</a><br/>
29+
Contributions are very welcome! <br/>
30+
Explore more <a href="https://www.ctrf.io/integrations">integrations</a>
31+
</p>
32+
</div>
33+
34+
## Installation
35+
36+
As a dependency:
37+
38+
```sh
39+
npm install [email protected]
40+
```
41+
42+
## CLI Usage
43+
44+
```sh
45+
npx junit-to-ctrf path/to/junit.xml
46+
```
47+
48+
or glob pattern:
49+
50+
```sh
51+
npx junit-to-ctrf "test-results/**/*.xml"
52+
```
53+
54+
## Options
55+
56+
`-o`, `--output` <output>: Output directory and filename for the CTRF report. If not provided, defaults to ctrf/ctrf-report.json.
57+
58+
`-t`, `--tool` <toolName>: Tool name to include in the CTRF report.
59+
60+
`-u`, `--use-suite-name` <useSuiteName>: Use suite name in the test name, defaults to true.
61+
62+
`-e`, `--env` <envProperties>: Environment properties to include in the CTRF report. Accepts multiple properties in the format KEY=value.
63+
64+
## Examples
65+
66+
Convert a JUnit XML report to the default CTRF report location (ctrf/ctrf-report.json):
67+
68+
```sh
69+
npx junit-to-ctrf "test-results/**/*.xml"
70+
```
71+
72+
### Specify Output File
73+
74+
Convert a JUnit XML report to a specified output file:
75+
76+
```sh
77+
npx junit-to-ctrf "test-results/**/*.xml" -o ctrf/combined-report.json
78+
```
79+
80+
### Include Tool Name
81+
82+
Convert a JUnit XML report and include a tool name in the CTRF report:
83+
84+
```sh
85+
npx junit-to-ctrf path/to/junit.xml -t ExampleTool
86+
```
87+
88+
### Include Environment Properties
89+
90+
Convert a JUnit XML report and include environment properties in the CTRF report:
91+
92+
```sh
93+
npx junit-to-ctrf path/to/junit.xml -e appName=MyApp buildName=MyBuild
94+
```
95+
96+
See [CTRF schema](https://www.ctrf.io/docs/schema/environment) for possible environment properties
97+
98+
### Exclude Suite Name
99+
100+
```sh
101+
npx junit-to-ctrf path/to/junit.xml -u false
102+
```
103+
104+
### Full Command
105+
106+
Combine all options in a single command:
107+
108+
```sh
109+
npx junit-to-ctrf path/to/junit.xml -o path/to/output/ctrf-report.json -t ExampleTool -e appName=MyApp buildName=MyBuild
110+
```
111+
112+
## API reference
113+
114+
## What is CTRF?
115+
116+
CTRF is a universal JSON test report schema that addresses the lack of a standardized format for JSON test reports.
117+
118+
**Consistency Across Tools:** Different testing tools and frameworks often produce reports in varied formats. CTRF ensures a uniform structure, making it easier to understand and compare reports, regardless of the testing tool used.
119+
120+
**Language and Framework Agnostic:** It provides a universal reporting schema that works seamlessly with any programming language and testing framework.
121+
122+
**Facilitates Better Analysis:** With a standardized format, programatically analyzing test outcomes across multiple platforms becomes more straightforward.
123+
124+
## Support Us
125+
126+
If you find this project useful, consider giving it a GitHub star ⭐ It means a lot to us.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[**JUnit to CTRF v0.0.10-next.0**](../README.md)
2+
3+
***
4+
5+
[JUnit to CTRF](../globals.md) / convertJUnitToCTRFReport
6+
7+
# Function: convertJUnitToCTRFReport()
8+
9+
> **convertJUnitToCTRFReport**(`pattern`, `options`): `Promise`\<`null` \| `Report`\>
10+
11+
Defined in: [convert.ts:24](https://github.com/ctrf-io/junit-to-ctrf/blob/main/src/convert.ts#L24)
12+
13+
Convert JUnit XML report(s) to CTRF
14+
15+
## Parameters
16+
17+
### pattern
18+
19+
`string`
20+
21+
Path to JUnit XML file or glob pattern
22+
23+
### options
24+
25+
[`ConvertOptions`](../interfaces/ConvertOptions.md) = `{}`
26+
27+
Optional options for the conversion
28+
29+
## Returns
30+
31+
`Promise`\<`null` \| `Report`\>
32+
33+
Promise that resolves when the conversion is complete

docs/globals.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[**JUnit to CTRF v0.0.10-next.0**](README.md)
2+
3+
***
4+
5+
# JUnit to CTRF v0.0.10-next.0
6+
7+
## Interfaces
8+
9+
- [ConvertOptions](interfaces/ConvertOptions.md)
10+
11+
## Functions
12+
13+
- [convertJUnitToCTRFReport](functions/convertJUnitToCTRFReport.md)

docs/interfaces/ConvertOptions.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[**JUnit to CTRF v0.0.10-next.0**](../README.md)
2+
3+
***
4+
5+
[JUnit to CTRF](../globals.md) / ConvertOptions
6+
7+
# Interface: ConvertOptions
8+
9+
Defined in: [convert.ts:10](https://github.com/ctrf-io/junit-to-ctrf/blob/main/src/convert.ts#L10)
10+
11+
Options for the conversion
12+
13+
## Properties
14+
15+
### envProps?
16+
17+
> `optional` **envProps**: `string`[]
18+
19+
Defined in: [convert.ts:13](https://github.com/ctrf-io/junit-to-ctrf/blob/main/src/convert.ts#L13)
20+
21+
***
22+
23+
### log?
24+
25+
> `optional` **log**: `boolean`
26+
27+
Defined in: [convert.ts:15](https://github.com/ctrf-io/junit-to-ctrf/blob/main/src/convert.ts#L15)
28+
29+
***
30+
31+
### outputPath?
32+
33+
> `optional` **outputPath**: `string`
34+
35+
Defined in: [convert.ts:11](https://github.com/ctrf-io/junit-to-ctrf/blob/main/src/convert.ts#L11)
36+
37+
***
38+
39+
### toolName?
40+
41+
> `optional` **toolName**: `string`
42+
43+
Defined in: [convert.ts:12](https://github.com/ctrf-io/junit-to-ctrf/blob/main/src/convert.ts#L12)
44+
45+
***
46+
47+
### useSuiteName?
48+
49+
> `optional` **useSuiteName**: `boolean`
50+
51+
Defined in: [convert.ts:14](https://github.com/ctrf-io/junit-to-ctrf/blob/main/src/convert.ts#L14)

0 commit comments

Comments
 (0)