@a11ycore/reporter 中文文档教程

发布于 4年前 浏览 23 项目主页 更新于 3年前

@a11ycore/reporter

npm 版本 NPM

Description

Reporter 是一个允许您将 a11y 结果与 A11ycore 报告平台同步的工具。 如果您还没有注册一个帐户,您将无法使用这个包。 您可以在此处注册;

Usage

const { runA11yJest } = require('@a11ycore/jest');
const { reporter }  = require('@a11ycore/reporter');
const { normaliseBuild } = require('@a11ycore/utils');

// can be found in the details page of your a11ycore project
const apiKey = process.env.A11Y_API_KEY;
const projectId = process.env.PROJECT_ID

describe("jest", () => {
  test("it should call the runA11yMethod", async () => {
    const element = React.createElement("img", { src: "#" });
    const html = ReactDOMServer.renderToString(element);
    const results = await runA11yJest(html)
    expect(results.violations.length).toBeGreaterThan(1);
    const normalisedResults = normaliseBuild(projectId, results); // if not done your results will not process and may be rejected
    await reporter(projectId, apiKey, normaliseBuild(projectId, results)); // you can then login to your a11ycore dashbaord to see results
  });
});

@a11ycore/reporter

npm version NPM

Description

The reporter is a tool to allow you to sync a11y results with the A11ycore reporting platform. If you have not signed up for an account you will not be able to use this package. You can sign up here;

Usage

const { runA11yJest } = require('@a11ycore/jest');
const { reporter }  = require('@a11ycore/reporter');
const { normaliseBuild } = require('@a11ycore/utils');

// can be found in the details page of your a11ycore project
const apiKey = process.env.A11Y_API_KEY;
const projectId = process.env.PROJECT_ID

describe("jest", () => {
  test("it should call the runA11yMethod", async () => {
    const element = React.createElement("img", { src: "#" });
    const html = ReactDOMServer.renderToString(element);
    const results = await runA11yJest(html)
    expect(results.violations.length).toBeGreaterThan(1);
    const normalisedResults = normaliseBuild(projectId, results); // if not done your results will not process and may be rejected
    await reporter(projectId, apiKey, normaliseBuild(projectId, results)); // you can then login to your a11ycore dashbaord to see results
  });
});
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文