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

GitHub action jest #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lighthouse CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lighthouseci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: npm install && npm install -g @lhci/[email protected]
- run: npm run build
- run: lhci autorun
30 changes: 30 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
25,337 changes: 12,707 additions & 12,630 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
Expand Down Expand Up @@ -43,12 +42,16 @@
]
},
"devDependencies": {
"@axe-core/react": "^4.1.1",
"@storybook/addon-a11y": "^6.1.17",
"@storybook/addon-actions": "^6.1.17",
"@storybook/addon-essentials": "^6.1.17",
"@storybook/addon-links": "^6.1.17",
"@storybook/node-logger": "^6.1.17",
"@storybook/preset-create-react-app": "^3.1.5",
"@storybook/react": "^6.1.17"
"@storybook/react": "^6.1.17",
"@types/jest": "^26.0.20",
"@types/jest-axe": "^3.5.1",
"jest-axe": "^4.1.0"
}
}
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

19 changes: 11 additions & 8 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
import React from "react"
import App from "./App"
import { render } from "@testing-library/react"
import { axe, toHaveNoViolations } from "jest-axe"

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
expect.extend(toHaveNoViolations)

it("should not have any accessibility violations", async () => {
const { container } = render(<App />)
const results = await axe(container)
expect(results).toHaveNoViolations()
})
32 changes: 12 additions & 20 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import React from "react"
import ReactDOM from "react-dom"
import { ColorImage } from "./stories/ColorImage"

if (process.env.NODE_ENV !== "production") {
const axe = require("@axe-core/react")
axe(React, ReactDOM, 1000)
}

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<div>
<ColorImage role="asdfa" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential accessibility issue: Ensures all elements with a role attribute use a valid value

</div>
);
)
}

export default App;
export default App
11 changes: 4 additions & 7 deletions src/stories/ColorImage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from "react"
import Image from "./ColorImage.jpeg"

export const ColorImage: React.FC = () => (
<img
src={Image}
alt="A bunch of chocolate candies with different colors"
width="500px"
/>
)
export const ColorImage: React.FC<{ alt?: string; role?: string }> = ({
alt,
role,
}) => <img src={Image} role={role} alt={alt} width="600px" />
74 changes: 37 additions & 37 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["dom", "es2018"],
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"paths": {
"@content/*": ["content/*"],
"@context/*": ["src/context/*"],
"@components/*": ["src/components/*"],
"@layouts/*": ["src/layouts/*"],
"@hooks/*": ["src/hooks/*"],
"@images/*": ["src/images/*"],
"@data/*": ["src/data/*"],
"@utils/*": ["src/utils/*"],
"@styles/*": ["src/styles/*"],
},
"preserveConstEnums": true,
"removeComments": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"typeRoots": [
"./src/types"
]
"allowJs": false,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react-jsx",
"lib": [
"dom",
"es2018"
],
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"typeRoots": [
"./src/types"
],
"target": "es5",
"module": "esnext",
"noEmit": true
},
"exclude": ["node_modules"],
"include": ["**/*.ts", "**/*.tsx"]
"exclude": [
"node_modules"
],
"include": [
"**/*.ts",
"**/*.tsx"
]
}