Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid split on undefined #258

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Conversation

cazou
Copy link
Contributor

@cazou cazou commented Aug 9, 2023

Some reports don't include a stack trace or details on the failure.
This can happen, for example, for junit reports that are used with non Java tests or when subtests are used. See #256 #241 or #239 (there may be others)

Just ignore the stacktrace if it is not defined.

@acpbm
Copy link

acpbm commented Aug 16, 2023

Will this PR be merged any time soon?

@cazou
Copy link
Contributor Author

cazou commented Aug 16, 2023

@acpbm From what I see, @dorny hasn't been maintaining this since November 2022. So not sure about the status

@acpbm
Copy link

acpbm commented Aug 25, 2023

@cazou I tried out your solution (which was very reasonable) but I'm still getting the "Cannot read property 'split' of undefined" error message.

The parser the test reporter is using is java-junit (as you already mentioned), and it appears the error happens as soon as the TestReporter object calls the "this.createReport()" on line 295 on index.js file. When I use the github action in my workflow, it prints "Creating test report .." and then immediately errors out (even after avoiding split on undefined at the locations you fixed).

Any idea of any other location it may be calling split on undefined?

@acpbm
Copy link

acpbm commented Aug 25, 2023

@cazou I was finally able to get it to work.

Here is what I changed:

https://github.com/dorny/test-reporter/blob/daece3018b33d4c6311cfde77ced40c4c42effa6/dist/index.js#L1063C49-L1063C49

changed to this () based on your example:

 const lines = stackTrace === null || stackTrace === void 0? void 0 : stackTrace.split(/\r?\n/);

Added this before the for loop found here:
https://github.com/dorny/test-reporter/blob/daece3018b33d4c6311cfde77ced40c4c42effa6/dist/index.js#L1064

if (!lines) return void 0;

This worked for me but it would be nice to have the logic reviewed by a typescript/js developer.

@j-catania j-catania added the bug Something isn't working label Sep 21, 2023
@j-catania j-catania merged commit f3a6ff2 into dorny:main Oct 9, 2023
github-merge-queue bot referenced this pull request in AmadeusITGroup/otter Mar 8, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [dorny/test-reporter](https://togithub.com/dorny/test-reporter) |
action | minor | `v1` -> `v1.8.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>dorny/test-reporter (dorny/test-reporter)</summary>

###
[`v1.8.0`](https://togithub.com/dorny/test-reporter/releases/tag/v1.8.0)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.7.0...v1.8.0)

#### What's Changed

- CHANGELOG.md by [@&#8203;j-catania](https://togithub.com/j-catania) in
[https://github.com/dorny/test-reporter/pull/297](https://togithub.com/dorny/test-reporter/pull/297)
- Bump [@&#8203;babel/traverse](https://togithub.com/babel/traverse)
from 7.12.1 to 7.23.2 in /reports/jest by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/303](https://togithub.com/dorny/test-reporter/pull/303)
- Bump [@&#8203;babel/traverse](https://togithub.com/babel/traverse)
from 7.22.20 to 7.23.2 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/304](https://togithub.com/dorny/test-reporter/pull/304)
- Add `SwiftXunitParser` class based on `JavaJunitParser` for
`swift-xunit` reporter by
[@&#8203;jozefizso](https://togithub.com/jozefizso) in
[https://github.com/dorny/test-reporter/pull/317](https://togithub.com/dorny/test-reporter/pull/317)
- Update to Node20 by
[@&#8203;j-catania](https://togithub.com/j-catania) in
[https://github.com/dorny/test-reporter/pull/315](https://togithub.com/dorny/test-reporter/pull/315)
- Fix build error by [@&#8203;dorny](https://togithub.com/dorny) in
[https://github.com/dorny/test-reporter/pull/331](https://togithub.com/dorny/test-reporter/pull/331)
- Use NodeJS 18 LTS as default runtime by
[@&#8203;jozefizso](https://togithub.com/jozefizso) in
[https://github.com/dorny/test-reporter/pull/332](https://togithub.com/dorny/test-reporter/pull/332)
- Update all packages by
[@&#8203;jozefizso](https://togithub.com/jozefizso) in
[https://github.com/dorny/test-reporter/pull/333](https://togithub.com/dorny/test-reporter/pull/333)
- Escape <> characters in suite name by
[@&#8203;wingyplus](https://togithub.com/wingyplus) in
[https://github.com/dorny/test-reporter/pull/236](https://togithub.com/dorny/test-reporter/pull/236)
- Adding feature and bug template by
[@&#8203;j-catania](https://togithub.com/j-catania) in
[https://github.com/dorny/test-reporter/pull/341](https://togithub.com/dorny/test-reporter/pull/341)
- Update check title and remove icon by
[@&#8203;ldaneliukas](https://togithub.com/ldaneliukas) in
[https://github.com/dorny/test-reporter/pull/144](https://togithub.com/dorny/test-reporter/pull/144)
- `test-reporter` release v1.8.0 by
[@&#8203;jozefizso](https://togithub.com/jozefizso) in
[https://github.com/dorny/test-reporter/pull/370](https://togithub.com/dorny/test-reporter/pull/370)

#### New Contributors

- [@&#8203;jozefizso](https://togithub.com/jozefizso) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/317](https://togithub.com/dorny/test-reporter/pull/317)
- [@&#8203;wingyplus](https://togithub.com/wingyplus) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/236](https://togithub.com/dorny/test-reporter/pull/236)
- [@&#8203;ldaneliukas](https://togithub.com/ldaneliukas) made their
first contribution in
[https://github.com/dorny/test-reporter/pull/144](https://togithub.com/dorny/test-reporter/pull/144)

**Full Changelog**:
dorny/test-reporter@v1.7.0...v1.8.0

###
[`v1.7.0`](https://togithub.com/dorny/test-reporter/releases/tag/v1.7.0)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.6.0...v1.7.0)

#### What's Changed

- Fix
[#&#8203;199](https://togithub.com/dorny/test-reporter/issues/199): Use
✅ instead of ✔️ for better cross platform look by
[@&#8203;petrdvorak](https://togithub.com/petrdvorak) in
[https://github.com/dorny/test-reporter/pull/200](https://togithub.com/dorny/test-reporter/pull/200)
- Verify content of dist/ folder matches build output by
[@&#8203;dorny](https://togithub.com/dorny) in
[https://github.com/dorny/test-reporter/pull/207](https://togithub.com/dorny/test-reporter/pull/207)
- Gracefully handle empty nested testsuite elements for JUnit. by
[@&#8203;rvdlaarschot](https://togithub.com/rvdlaarschot) in
[https://github.com/dorny/test-reporter/pull/193](https://togithub.com/dorny/test-reporter/pull/193)
- Gracefully handle empty failure tags by
[@&#8203;haudren-woven](https://togithub.com/haudren-woven) in
[https://github.com/dorny/test-reporter/pull/213](https://togithub.com/dorny/test-reporter/pull/213)
- Fix [#&#8203;208](https://togithub.com/dorny/test-reporter/issues/208)
- java-junit: show annotations on PR changed files by
[@&#8203;atsu85](https://togithub.com/atsu85) in
[https://github.com/dorny/test-reporter/pull/209](https://togithub.com/dorny/test-reporter/pull/209)
- Only report failure if fail-on-error is set by
[@&#8203;trond-snekvik](https://togithub.com/trond-snekvik) in
[https://github.com/dorny/test-reporter/pull/214](https://togithub.com/dorny/test-reporter/pull/214)
- Improve clarity on configuring for forkable repos by
[@&#8203;abelbraaksma](https://togithub.com/abelbraaksma) in
[https://github.com/dorny/test-reporter/pull/211](https://togithub.com/dorny/test-reporter/pull/211)
- Suppress "Processing test results from" log by
[@&#8203;vasanthdharmaraj](https://togithub.com/vasanthdharmaraj) in
[https://github.com/dorny/test-reporter/pull/179](https://togithub.com/dorny/test-reporter/pull/179)
- Skip listing of files if error parsing is disabled by
[@&#8203;dorny](https://togithub.com/dorny) in
[https://github.com/dorny/test-reporter/pull/216](https://togithub.com/dorny/test-reporter/pull/216)
- Correct typo in docs by
[@&#8203;tangowithfoxtrot](https://togithub.com/tangowithfoxtrot) in
[https://github.com/dorny/test-reporter/pull/254](https://togithub.com/dorny/test-reporter/pull/254)
- update dependencies by
[@&#8203;j-catania](https://togithub.com/j-catania) in
[https://github.com/dorny/test-reporter/pull/269](https://togithub.com/dorny/test-reporter/pull/269)
- Add permissions to example yml files by
[@&#8203;TurnrDev](https://togithub.com/TurnrDev) in
[https://github.com/dorny/test-reporter/pull/263](https://togithub.com/dorny/test-reporter/pull/263)
- add feature fail-on-empty by
[@&#8203;gdams](https://togithub.com/gdams) in
[https://github.com/dorny/test-reporter/pull/243](https://togithub.com/dorny/test-reporter/pull/243)
- Add dependabot configuration by
[@&#8203;yeikel](https://togithub.com/yeikel) in
[https://github.com/dorny/test-reporter/pull/228](https://togithub.com/dorny/test-reporter/pull/228)
- Bump ws from 7.3.1 to 7.5.9 in /reports/jest by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/265](https://togithub.com/dorny/test-reporter/pull/265)
- Bump actions/checkout from 2 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/279](https://togithub.com/dorny/test-reporter/pull/279)
- Add new output for url url html by
[@&#8203;luisito666](https://togithub.com/luisito666) in
[https://github.com/dorny/test-reporter/pull/242](https://togithub.com/dorny/test-reporter/pull/242)
- Update README.md by
[@&#8203;IanMoroney](https://togithub.com/IanMoroney) in
[https://github.com/dorny/test-reporter/pull/158](https://togithub.com/dorny/test-reporter/pull/158)
- Update jest-Junit part of Readme by
[@&#8203;ryancasburn-KAI](https://togithub.com/ryancasburn-KAI) in
[https://github.com/dorny/test-reporter/pull/176](https://togithub.com/dorny/test-reporter/pull/176)
- fix: default-valued fields are not mandatory by
[@&#8203;TomerFi](https://togithub.com/TomerFi) in
[https://github.com/dorny/test-reporter/pull/172](https://togithub.com/dorny/test-reporter/pull/172)
- Bump ansi-regex from 4.1.0 to 4.1.1 in /reports/jest by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/278](https://togithub.com/dorny/test-reporter/pull/278)
- Bump decode-uri-component from 0.2.0 to 0.2.2 in /reports/jest by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/276](https://togithub.com/dorny/test-reporter/pull/276)
- Bump minimist from 1.2.5 to 1.2.8 in /reports/jest by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/275](https://togithub.com/dorny/test-reporter/pull/275)
- Bump qs from 6.5.2 to 6.5.3 in /reports/jest by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/272](https://togithub.com/dorny/test-reporter/pull/272)
- Bump json5 from 2.1.3 to 2.2.3 in /reports/jest by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/271](https://togithub.com/dorny/test-reporter/pull/271)
- Bump ansi-regex from 3.0.0 to 3.0.1 in /reports/mocha by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/dorny/test-reporter/pull/270](https://togithub.com/dorny/test-reporter/pull/270)
- declare 'url' and 'url_html' as action outputs by
[@&#8203;micha-one](https://togithub.com/micha-one) in
[https://github.com/dorny/test-reporter/pull/287](https://togithub.com/dorny/test-reporter/pull/287)
- Avoid split on undefined by
[@&#8203;cazou](https://togithub.com/cazou) in
[https://github.com/dorny/test-reporter/pull/258](https://togithub.com/dorny/test-reporter/pull/258)

#### New Contributors

- [@&#8203;petrdvorak](https://togithub.com/petrdvorak) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/200](https://togithub.com/dorny/test-reporter/pull/200)
- [@&#8203;rvdlaarschot](https://togithub.com/rvdlaarschot) made their
first contribution in
[https://github.com/dorny/test-reporter/pull/193](https://togithub.com/dorny/test-reporter/pull/193)
- [@&#8203;haudren-woven](https://togithub.com/haudren-woven) made their
first contribution in
[https://github.com/dorny/test-reporter/pull/213](https://togithub.com/dorny/test-reporter/pull/213)
- [@&#8203;atsu85](https://togithub.com/atsu85) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/209](https://togithub.com/dorny/test-reporter/pull/209)
- [@&#8203;trond-snekvik](https://togithub.com/trond-snekvik) made their
first contribution in
[https://github.com/dorny/test-reporter/pull/214](https://togithub.com/dorny/test-reporter/pull/214)
- [@&#8203;abelbraaksma](https://togithub.com/abelbraaksma) made their
first contribution in
[https://github.com/dorny/test-reporter/pull/211](https://togithub.com/dorny/test-reporter/pull/211)
- [@&#8203;vasanthdharmaraj](https://togithub.com/vasanthdharmaraj) made
their first contribution in
[https://github.com/dorny/test-reporter/pull/179](https://togithub.com/dorny/test-reporter/pull/179)
- [@&#8203;tangowithfoxtrot](https://togithub.com/tangowithfoxtrot) made
their first contribution in
[https://github.com/dorny/test-reporter/pull/254](https://togithub.com/dorny/test-reporter/pull/254)
- [@&#8203;TurnrDev](https://togithub.com/TurnrDev) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/263](https://togithub.com/dorny/test-reporter/pull/263)
- [@&#8203;gdams](https://togithub.com/gdams) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/243](https://togithub.com/dorny/test-reporter/pull/243)
- [@&#8203;yeikel](https://togithub.com/yeikel) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/228](https://togithub.com/dorny/test-reporter/pull/228)
- [@&#8203;luisito666](https://togithub.com/luisito666) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/242](https://togithub.com/dorny/test-reporter/pull/242)
- [@&#8203;IanMoroney](https://togithub.com/IanMoroney) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/158](https://togithub.com/dorny/test-reporter/pull/158)
- [@&#8203;ryancasburn-KAI](https://togithub.com/ryancasburn-KAI) made
their first contribution in
[https://github.com/dorny/test-reporter/pull/176](https://togithub.com/dorny/test-reporter/pull/176)
- [@&#8203;TomerFi](https://togithub.com/TomerFi) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/172](https://togithub.com/dorny/test-reporter/pull/172)
- [@&#8203;micha-one](https://togithub.com/micha-one) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/287](https://togithub.com/dorny/test-reporter/pull/287)
- [@&#8203;cazou](https://togithub.com/cazou) made their first
contribution in
[https://github.com/dorny/test-reporter/pull/258](https://togithub.com/dorny/test-reporter/pull/258)

**Full Changelog**:
dorny/test-reporter@v1.6.0...v1.7.0

###
[`v1.6.0`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v160)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.5.0...v1.6.0)

- [Update to node16 + recent versions of core and exec
packages](https://togithub.com/dorny/test-reporter/pull/203)
- [Update all dependencies to latest
versions](https://togithub.com/dorny/test-reporter/pull/186)
- [Fix tests on non us-EN local
env](https://togithub.com/dorny/test-reporter/pull/185)

###
[`v1.5.0`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v150)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.4.3...v1.5.0)

- [Add option to convert backslashes in path pattern to forward
slashes](https://togithub.com/dorny/test-reporter/pull/128)
- [Add option to generate only the summary from processed test results
files](https://togithub.com/dorny/test-reporter/pull/123)

###
[`v1.4.3`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v143)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.4.2...v1.4.3)

- [Patch java-junit to handle missing time
field](https://togithub.com/dorny/test-reporter/pull/115)
- [Fix dart-json parsing broken by print
message](https://togithub.com/dorny/test-reporter/pull/114)

###
[`v1.4.2`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v142)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.4.1...v1.4.2)

- [Fix dotnet-trx parsing of passed tests with non-empty error
info](https://togithub.com/dorny/test-reporter/commit/43d89d5ee509bcef7bd0287aacc0c4a4fb9c1657)

###
[`v1.4.1`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v141)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.4.0...v1.4.1)

- [Fix dotnet-trx parsing of tests with custom display
names](https://togithub.com/dorny/test-reporter/pull/105)

###
[`v1.4.0`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v140)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.3.1...v1.4.0)

- [Add support for
mocha-json](https://togithub.com/dorny/test-reporter/pull/90)
- [Use full URL to fix navigation from summary to suite
details](https://togithub.com/dorny/test-reporter/pull/89)
- [New report rendering with code blocks instead of
tables](https://togithub.com/dorny/test-reporter/pull/88)
- [Improve test error messages from
flutter](https://togithub.com/dorny/test-reporter/pull/87)

###
[`v1.3.1`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v131)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.3.0...v1.3.1)

- [Fix: parsing of .NET duration string without
milliseconds](https://togithub.com/dorny/test-reporter/pull/84)
- [Fix: dart-json - remove group name from test case
names](https://togithub.com/dorny/test-reporter/pull/85)
- [Fix: net-trx parser crashing on missing duration
attribute](https://togithub.com/dorny/test-reporter/pull/86)

###
[`v1.3.0`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v130)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.2.0...v1.3.0)

- [Add support for
java-junit](https://togithub.com/dorny/test-reporter/pull/80)
- [Fix: Handle test reports with no test
cases](https://togithub.com/dorny/test-reporter/pull/70)
- [Fix: Reduce number of API calls to get list of files tracked by
GitHub](https://togithub.com/dorny/test-reporter/pull/69)

###
[`v1.2.0`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v120)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.1.0...v1.2.0)

- [Set `listTests` and `listSuites` to lower detail if report is too
big](https://togithub.com/dorny/test-reporter/pull/60)

###
[`v1.1.0`](https://togithub.com/dorny/test-reporter/blob/HEAD/CHANGELOG.md#v110)

[Compare
Source](https://togithub.com/dorny/test-reporter/compare/v1.0.0...v1.1.0)

- [Support public repo PR
workflow](https://togithub.com/dorny/test-reporter/pull/56)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am
every weekday,every weekend" in timezone Europe/Paris, Automerge - At
any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/AmadeusITGroup/otter).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIzMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants