[英]Is there a way to turn off syntax highlighting in testing-library
I am using @testing-library/vue and run the tests within a build step of Sublime Text.我正在使用 @testing-library/vue 并在 Sublime Text 的构建步骤中运行测试。 The error output uses prettyDom and isn't very legible in the output window:
错误 output 使用了 prettyDom 并且在 output window 中不是很清晰:
Example Output in Build Results window:构建结果 window 中的示例 Output:
TestingLibraryElementError: Unable to find a label with the text of: /val1/
[36m<div[39m
[33mclass[39m=[32m"Cell"[39m
[33mdata-v-1cdb88a0[39m=[32m""[39m
[33mstyle[39m=[32m"width: 40%;"[39m
[36m>[39m
[36m<div[39m
[33mclass[39m=[32m"Label"[39m
[33mdata-v-1cdb88a0[39m=[32m""[39m
[36m>[39m
[0mTest Cat #1[0m
[36m</div>[39m
[36m<div[39m
[33mattrs[39m=[32m"[object Object]"[39m
[33mdata-v-088d7313[39m=[32m""[39m
[33mdata-v-1cdb88a0[39m=[32m""[39m
[33mform[39m=[32m"[object Object]"[39m
[33mon[39m=[32m"[object Object]"[39m
[33mprops[39m=[32m"[object Object]"[39m
Is there a way to turn off the syntax highlighting with an environment variable like you can to extend the output length?有没有一种方法可以像延长 output 长度一样关闭使用环境变量突出显示的语法?
Syntax highlighting is handled by the editor displaying the text.语法高亮由显示文本的编辑器处理。
In Sublime Text you can effectively remove – turn off if you like – the syntax highlighting of the current file / buffer by changing the syntax to Plain Text
.在 Sublime Text 中,您可以通过将语法更改为
Plain Text
文本来有效地删除(如果您愿意,可以关闭)当前文件/缓冲区的语法突出显示。
You can do that by choosing Plain Text
after clicking on the active syntax name on the right of the Status Bar
or from the View --> Syntax
menu, or by opening the Command Palette
and selecting the Set Syntax: Plain Text
command.您可以通过单击
Status Bar
右侧的活动语法名称后选择Plain Text
或从View --> Syntax
菜单中选择纯文本,或打开Command Palette
并选择Set Syntax: Plain Text
命令。
prettyDOM takes the same options as pretty-format . prettyDOM 采用与pretty-format相同的选项。 One of those options is "highlight".
这些选项之一是“突出显示”。 In pretty-format it seems to be false by default, but in prettyDOM I found it's true by default.
在 pretty-format 中,它似乎默认为 false,但在 prettyDOM 中,我发现它默认为 true。 You can disable it like this:
您可以像这样禁用它:
prettyDOM(myDom, undefined, {highlight: false})
The apparent answer is to get Sublime Text to display the colors in the build window by using the ANSIescape plugin:显而易见的答案是使用 ANSIescape 插件让 Sublime Text 在构建 window 中显示 colors:
https://forum.sublimetext.com/t/ansi-color-codes-in-build-output/11296/16 https://packagecontrol.io/packages/ANSIescape https://forum.sublimetext.com/t/ansi-color-codes-in-build-output/11296/16 https://packagecontrol.io/packages/ANSIescape
You can set the COLORS
environment variable to false
to turn off colourisation.您可以将
COLORS
环境变量设置为false
以关闭着色。 See https://testing-library.com/docs/dom-testing-library/api-debugging/参见https://testing-library.com/docs/dom-testing-library/api-debugging/
Although your question relates to the build results window in Sublime, this is a common problem in other places where the colour codes make it hard to see the actual debug output (in my case a Jenkins console output when tests fail).尽管您的问题与 Sublime 中的构建结果 window 相关,但这在其他地方是一个常见问题,颜色代码使得很难看到实际调试 output(在我的例子中是 Jenkins 控制台 output 当测试失败时)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.