Skip to content

Commit

Permalink
Merge pull request #30 from uswds/mh/add-gh-actions
Browse files Browse the repository at this point in the history
Add storybook testing and CI
  • Loading branch information
mejiaj committed Jun 28, 2024
2 parents e116e48 + 5e0f35a commit e3d1721
Show file tree
Hide file tree
Showing 29 changed files with 10,184 additions and 6,171 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ui-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Storybook Tests
on: push
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Install dependencies
run: npm ci
- name: Install playwright
run: npx playwright install
- name: Run Storybook tests
run: npm run test:storybook:ci
4 changes: 3 additions & 1 deletion web-components/.gitignore → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ dist-ssr
*.sln
*.sw?

*storybook.log
*storybook.log
_site
storybook-static
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion web-components/.storybook/main.js → .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/** @type { import('@storybook/web-components-vite').StorybookConfig } */
const config = {
stories: [
"../src/**/*.mdx",
"../storybook/**/*.mdx",
"../src/components/**/*.stories.@(js|jsx|mjs|ts|tsx)",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-a11y"
],
framework: {
name: "@storybook/web-components-vite",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UswdsTheme from "./UswdsTheme";

// Global component styles.
import "../src/index.css";
import "../storybook/index.css";
// Theme overrides.
import "./index.css";

Expand Down
23 changes: 23 additions & 0 deletions .storybook/test-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { injectAxe, checkA11y, configureAxe } from "axe-playwright";
import { getStoryContext } from "@storybook/test-runner";

const config = {
async preVisit(page) {
await injectAxe(page);
},
async postVisit(page, context) {
const storyContext = await getStoryContext(page, context);

await configureAxe(page, {
rules: storyContext.parameters?.a11y?.config?.rules,
});
await checkA11y(page, "#storybook-root", {
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};

export default config;
File renamed without changes.
Loading

0 comments on commit e3d1721

Please sign in to comment.