-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
3,842 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true, | ||
"jest/globals": true | ||
}, | ||
"extends": [ | ||
"plugin:react/recommended", | ||
"plugin:jest/recommended", | ||
"airbnb-typescript", | ||
"prettier" | ||
], | ||
"parserOptions": { | ||
"project": ["tsconfig.json"], | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"react", | ||
"jest", | ||
"import" | ||
], | ||
"rules": { | ||
// React scope no longer necessary with new JSX transform | ||
"react/react-in-jsx-scope": "off", | ||
"no-underscore-dangle": 0, | ||
"import/extensions": [ | ||
"error", | ||
"ignorePackages", | ||
{ | ||
"js": "never", | ||
"jsx": "never", | ||
"ts": "never", | ||
"tsx": "never" | ||
} | ||
] | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { Config } from 'jest'; | ||
|
||
const config: Config = { | ||
clearMocks: true, | ||
collectCoverage: true, | ||
coverageDirectory: "coverage", | ||
testEnvironment: "jsdom", | ||
transform: { | ||
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest` | ||
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest` | ||
'^.+\\.tsx?$': [ | ||
'ts-jest', | ||
{ | ||
babelConfig: true, | ||
}, | ||
], | ||
}, | ||
setupFilesAfterEnv: [ | ||
"<rootDir>/tests/setupTests.ts" | ||
], | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
import { render, screen } from "@testing-library/react"; | ||
import App from './App'; | ||
|
||
describe("test App.tsx", () => { | ||
it("should render the title through props", () => { | ||
render(<App title="testing component"/>); | ||
expect( | ||
screen.getByText(/testing component/) | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
|
||
import React from "react"; | ||
import './App.css'; | ||
|
||
export default function App() { | ||
return ( | ||
<main> | ||
<p>App is running!</p> | ||
</main> | ||
); | ||
} | ||
type AppProps = { | ||
title?: string; | ||
}; /* use `interface` if exporting so that consumers can extend */ | ||
|
||
const App = ({ title }: AppProps) => <div>{title}</div>; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
|
||
import { StrictMode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import App from "./App"; | ||
|
||
const rootElement = document.getElementById("root"); | ||
|
||
// New as of React v18.x | ||
const root = createRoot(rootElement!); | ||
const rootElement = document.getElementById("root") as HTMLElement; | ||
const root = createRoot(rootElement); | ||
|
||
root.render( | ||
<StrictMode> | ||
<App /> | ||
<App title="Hello world!"/> | ||
</StrictMode> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "@testing-library/jest-dom"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.