如何在react组件中显示bash输出

时间:2019-07-23 15:12:08

标签: javascript reactjs bash

在测试期间,我通过JEST从AX库获得了此输出。我想在网页上显示结果,结果如下:

Error: [2mexpect([22m[31mreceived[39m[2m).toHaveNoViolations([22m[32mexpected[39m[2m)[22m

Expected the HTML found at $('div:nth-child(2) > .FareListContainer.fr-position-relative[data-testid="fareListContainer"] > .fr-position-relative > .fr-no-gutters.fr-mb-2.fr-row > .fr-col > .fr-clearfix[data-testid="FareSimpleSorting"] > .fr-float-right > .fr-custom-select-container.fr-rounded-\@theme\:card\.rounded-x.fr-border > select') to have no violations:

<select id="fare-simple-sorting-123456789" class="fr-form-control fr-custom-select" aria-label="Press the UP/Down Arrow key to choose a sorting criteria, press the Enter key to select the item or press the TAB key to continue" aria-describedby="fare-simple-sorting-description-123456789" data-testid="simpleSortingSelect">

Expected the HTML found at $('div:nth-child(2) > .FareListContainer.fr-position-relative[data-testid="fareListContainer"] > .fr-position-relative > .fr-no-gutters.fr-mb-2.fr-row > .fr-col > .fr-clearfix[data-testid="FareSimpleSorting"] > .fr-float-right > p') to have no violations:

<p id="fare-simple-sorting-description-123456789" class="fr-sr-only" aria-hidden="true">Your are in the Fare Simple Sorting</p>

Received:

[31m"IDs used in ARIA and labels must be unique (duplicate-id-aria)"[39m

Try fixing it with this help: https://dequeuniversity.com/rules/axe/3.1/duplicate-id-aria?application=axeAPI

────────

Expected the HTML found at $('div:nth-child(2) > .FareListContainer.fr-position-relative[data-testid="fareListContainer"] > .fr-text-left.fr-font-size-3-x.fr-disclaimer') to have no violations:

<div class="fr-text-left fr-font-size-3-x fr-disclaimer" id="123456789" data-testid="disclaimer"><span>*Fares presented below are available at the beginning of each day, but may sell out. Additional baggage fees and fees for other services may apply. Other terms and conditions may apply</span></div>

Received:

[31m"id attribute value must be unique (duplicate-id)"[39m

Try fixing it with this help: https://dequeuniversity.com/rules/axe/3.1/duplicate-id?application=axeAPI

────────

Expected the HTML found at $('div:nth-child(2) > .FareListContainer.fr-position-relative[data-testid="fareListContainer"] > .fr-position-relative > .fr-no-gutters.fr-mb-2.fr-row > .fr-col > .fr-clearfix[data-testid="FareSimpleSorting"] > .fr-float-right > .fr-custom-select-container.fr-rounded-\@theme\:card\.rounded-x.fr-border > select') to have no violations:

<select id="fare-simple-sorting-123456789" class="fr-form-control fr-custom-select" aria-label="Press the UP/Down Arrow key to choose a sorting criteria, press the Enter key to select the item or press the TAB key to continue" aria-describedby="fare-simple-sorting-description-123456789" data-testid="simpleSortingSelect">

Received:

[31m"Form elements must have labels (label)"[39m

Try fixing it with this help: https://dequeuniversity.com/rules/axe/3.1/label?application=axeAPI
    at toHaveNoViolations (/home/yoandry/Documents/airmodules/src/components/containers/FareListContainer/FareListContainer.test.js:27:42)
    at tryCatch (/home/yoandry/Documents/airmodules/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/home/yoandry/Documents/airmodules/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.(anonymous function) [as next] (/home/yoandry/Documents/airmodules/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/home/yoandry/Documents/airmodules/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/home/yoandry/Documents/airmodules/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)

例如,我想显示没有这些字符“ [31m””格式的文本。我尝试使用Prims,但不适用于我。

0 个答案:

没有答案