nightwatch
nightwatch copied to clipboard
RangeError: Invalid string length for HTML Reporter on large job
Description of the bug/issue
When I have large nwjs job I got: "RangeError: Invalid string length" when using built in HTML Reporter.
JSON.stringify(results)
[object Object]
RangeError: Invalid string length
at JSON.stringify (<anonymous>)
at HtmlReporter.writeReport (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\reporters\html.js:224:16)
at Object.write (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\reporters\html.js:242:22)
at C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\global-reporter.js:206:26
at new Promise (<anonymous>)
at GlobalReporter.writeReport (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\global-reporter.js:205:20)
at C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\global-reporter.js:181:67
at Array.map (<anonymous>)
at GlobalReporter.writeReportToFile (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\global-reporter.js:181:42)
at async Promise.all (index 1)
at DefaultRunner.reportResults (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\runner\test-runners\default.js:115:13)
at DefaultRunner.runConcurrent (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\runner\test-runners\default.js:128:9)
✖ RangeError
Invalid string length
Stack Trace :
at JSON.stringify (<anonymous>)
at HtmlReporter.writeReport (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\reporters\html.js:230:33)
at Object.write (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\reporters\html.js:242:22)
at C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\global-reporter.js:206:26
at new Promise (<anonymous>)
at GlobalReporter.writeReport (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\global-reporter.js:205:20)
at C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\global-reporter.js:181:67
at Array.map (<anonymous>)
at GlobalReporter.writeReportToFile (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\reporter\global-reporter.js:181:42)
at async Promise.all (index 1)
at DefaultRunner.reportResults (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\runner\test-runners\default.js:115:13)
at DefaultRunner.runConcurrent (C:\git\price-optimization-frontend\node_modules\nightwatch\dist\runner\test-runners\default.js:128:9)
Steps to reproduce
- Go to '...'
- Click on '...'
- Scroll down to '...'
- See error
Sample test
Some data from the job
JSON.stringify(results)
[object Object]
{
environments: {
ch_win_bs: { metadata: [Object], stats: [Object], modules: [Object] }
},
stats: { total: 1948, passed: 1948, failed: 0, skipped: 0, time: 2445000 },
metadata: { date: 2023-10-24T15:40:54.542Z }
}
RangeError: Invalid string length
at JSON.stringify (<anonymous>)
### Command to run
_No response_
### Verbose Output
_No response_
### Nightwatch Configuration
_No response_
### Nightwatch.js Version
3.2.1
### Node Version
18.13.0
### Browser
chrome
### Operating System
W10
### Additional Information
_No response_
Hi is this issue workable .. ? So far what I have inspected ..
nightwatch/lib/reporter/reporters/html --> HtmlReporter.writeReport()
const filePath = path.join(destFolder, `${this.getFileName()}.html`);
const jsonString = JSON.stringify(results);
HtmlReact.writeNightwatchHTMLReport(destFolder, fileName, jsonString);
The JSON.stirngify() function has a limit and when it exceeds that the error is thrown as shown... Maybe we can use Bson or Json stream or we can get rid of the exceeded data (which i dont think will be wise)
any suggestions.. Thanks