npm i -D prettier
- package.json scripts:
"format": "prettier \"src/**/*.{js,html}\" --write"
touch .prettierrc
avec :{ "trailingComma": "es5" }
- Enable the option Run on save for files.
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
const AppBar = ({ | |
children, | |
className, | |
iconElementLeft, | |
iconElementRight, | |
title, | |
titleStyle, |
import React from 'react'; | |
import ShallowRenderer from 'react-test-renderer/shallow'; | |
import AppBar from '../'; | |
describe('<AppBar />', () => { | |
const renderer = new ShallowRenderer(); | |
it('should match snapshot without props', () => { | |
renderer.render(<AppBar />); |
describe("here name which function or feature you are testing", () => { | |
it("here explain what specific part of the feature should do", () => { | |
expect(1 + 1).toBe(2); | |
}); | |
}); |
export const ACTIONS = { | |
GET_USER_REQUEST: "GET_USER_REQUEST", | |
GET_USER_SUCCESS: "GET_USER_SUCCESS", | |
GET_USER_FAILURE: "GET_USER_FAILURE" | |
}; | |
export const initialState = { | |
isFetching: false, | |
errors: [], | |
profile: {} |
test("should render an empty firstname input", () => { | |
const props = Default.args as Props; | |
const { getByLabelText } = render(<Default {...props} />); | |
const input = getByLabelText("Firstname") as HTMLInputElement; | |
expect(input).toBeInTheDocument(); | |
expect(input.value).toBe(""); | |
}); |
import React from "react"; | |
import { render } from "@testing-library/react"; | |
import { Props } from "."; | |
import { Default } from "./index.stories"; | |
test("should render the title", () => { | |
const props = Default.args as Props; | |
const { getByText } = render(<Default {...props} />); | |
const actual = getByText(props.title); | |
expect(actual).toBeInTheDocument(); |
import React, { FunctionComponent } from "react"; | |
type Props = React.SVGProps<any> & { | |
className: string; | |
title?: string; | |
}; | |
const Download: FunctionComponent<Props> = ({ | |
className, | |
title, |
import React from "react"; | |
import { render } from "@testing-library/react"; | |
import { Props } from "."; | |
import { Default } from "./index.stories"; | |
describe("COMPONENT_NAME", () => { | |
describe("Default", () => { | |
const props = Default.args as Props; | |
test("should match snapshot", () => { |
import { axe } from "jest-axe"; | |
test("should be accessible", async () => { | |
const { container } = render(<Component />); | |
expect(await axe(container)).toHaveNoViolations(); | |
}); |