Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable code coverage for most of playground/web #2829

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/playground/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ module.exports = require("@batch/common-config/jest-common").createConfig(
{
testEnvironment: "jsdom",
setupFilesAfterEnv: ["<rootDir>/src/__tests__/setup-tests.tsx"],
// Ignore most code coverage as this isn't used in production
coveragePathIgnorePatterns: ["^(?!.*(playground-example.tsx))"],
}
);
4 changes: 4 additions & 0 deletions util/common-config/jest-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ function getCombinedResourceStrings() {
__dirname,
"../../packages/playground/resources/i18n/json/resources.en.json"
)),
require(path.join(
__dirname,
"../../web/resources/i18n/resources.en.json"
)),
];

const allResourceStrings = {};
Expand Down
2 changes: 2 additions & 0 deletions web/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ module.exports = require("@batch/common-config/jest-common").createConfig(
{
testEnvironment: "jsdom",
setupFilesAfterEnv: ["<rootDir>/src/__tests__/setup-tests.ts"],
// Ignore most code coverage as this isn't used in production
coveragePathIgnorePatterns: ["^(?!.*(application.tsx))"],
}
);
8 changes: 8 additions & 0 deletions web/src/__tests__/setup-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { destroyEnvironment } from "@azure/bonito-core";
import { initializeAxe } from "@azure/bonito-ui/lib/test-util";

beforeAll(async () => {
await initializeAxe();
});

afterEach(() => {
jest.resetAllMocks();
Expand All @@ -9,6 +14,9 @@ afterAll(() => {
jest.restoreAllMocks();
});

// UI tests can be slow, especially with a11y tests enabled
jest.setTimeout(30000);

// KLUDGE: Mock out the monaco API so that imports to MonacoEditor do not error.
// Note that the editor itself currently does not work in a Node.js
// environment regardless
Expand Down
23 changes: 23 additions & 0 deletions web/src/components/__tests__/application.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { initMockBrowserEnvironment } from "@azure/bonito-ui";
import { runAxe } from "@azure/bonito-ui/lib/test-util/a11y";
import { render } from "@testing-library/react";
import { Application } from "components/application";
import * as React from "react";

describe("Application tests", () => {
beforeEach(() => initMockBrowserEnvironment());

test("Can render the web UI without accessibility violations", async () => {
const { container } = render(<Application />);
expect(
await runAxe(container, {
rules: {
// See https://github.com/microsoft/fluentui/issues/28706
"aria-required-children": { enabled: false },
// See https://github.com/microsoft/fluentui/issues/18474
"empty-table-header": { enabled: false },
},
})
).toHaveNoViolations();
});
});