-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #406 from inikulin/gh374-5
Redesign error decorator, so it fits needs of both API versions (#374 part5)
- Loading branch information
Showing
24 changed files
with
285 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
import { escape as escapeHtml } from 'lodash'; | ||
import highlight from 'highlight-es'; | ||
import TestRunErrorFormattableAdapter from '../../errors/test-run/formattable-adapter'; | ||
import TEMPLATES from './templates'; | ||
|
||
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/; | ||
|
||
var renderer = ['string', 'punctuator', 'keyword', 'number', 'regex', 'comment', 'invalid'].reduce((syntaxRenderer, tokenType) => { | ||
syntaxRenderer[tokenType] = str => `<span class="syntax-${tokenType}">${escapeHtml(str)}</span>`; | ||
|
||
return syntaxRenderer; | ||
}, {}); | ||
|
||
export default class LegacyTestRunErrorFormattableAdapter extends TestRunErrorFormattableAdapter { | ||
constructor (err, userAgent) { | ||
super(err, userAgent); | ||
constructor (err, userAgent, screenshotPath, callsite) { | ||
super(err, userAgent, screenshotPath, callsite); | ||
|
||
this.TEMPLATES = TEMPLATES; | ||
} | ||
|
||
getCallsiteMarkup () { | ||
var code = highlight(this.callsite, renderer); | ||
var lines = code.split(NEWLINE); | ||
var lastLine = lines.pop(); | ||
|
||
lastLine = `<div class="code-line-last">${lastLine}</div>`; | ||
lines = lines.map(line => `<div class="code-line"><div class="code-line-src">${line}</div></div>`); | ||
|
||
return `<div class="code-frame">${lines.join('')}${lastLine}</div>`; | ||
} | ||
} |
Oops, something went wrong.