Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

lint-translation-reporter.js 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  1. const chalk = require('chalk')
  2. const stripAnsi = require('strip-ansi')
  3. const { groupBy } = require('lodash')
  4. // we don't want to print all the stack traces
  5. const stackTraceRegExp = /^\s+at\s.+/img
  6. class TranslationReporter {
  7. constructor (globalConfig, options) {
  8. this._globalConfig = globalConfig
  9. this._options = options
  10. }
  11. onRunComplete (contexts, results) {
  12. const failures = results.testResults.reduce((fails, { testResults: assertionResults }) => {
  13. const formattedFails = assertionResults
  14. .filter(result => result.status === 'failed')
  15. .map(({ ancestorTitles, failureMessages, title }) => {
  16. return {
  17. fileName: ancestorTitles[1],
  18. failedTests: title,
  19. failureMessage: failureMessages.map((message) => {
  20. return message.split('\n').filter(line => !stackTraceRegExp.test(stripAnsi(line))).join('\n')
  21. })
  22. }
  23. })
  24. return [...fails, ...formattedFails]
  25. }, [])
  26. const failuresByFile = groupBy(failures, 'fileName')
  27. for (const fileName in failuresByFile) {
  28. console.group(chalk.red.bold(`\n${fileName}`))
  29. failuresByFile[fileName].forEach(({ failureMessage }, index) => {
  30. console.log(chalk.bold(`\n(${index + 1})`))
  31. failureMessage.forEach(msg => console.log(msg))
  32. })
  33. console.groupEnd()
  34. }
  35. }
  36. }
  37. module.exports = TranslationReporter
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...