Skip to content

Commit

Permalink
ci: 🎡 addressing typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
Loonz206 committed Oct 5, 2024
1 parent bbfc183 commit 73c58c1
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"*.+(js|jsx|ts|tsx)":[
"eslint",
"tsc-files --noEmit"
],
"eslint"
],
"*.+(js|json|md)":[
"prettier --write"
]
Expand Down
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const createJestConfig = nextJest({
// Add any custom config to be passed to Jest
const customJestConfig = {
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
setupFilesAfterEnv: ["<rootDir>/setupTests.js"], // if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ["node_modules", "<rootDir>/"],
testEnvironment: "jest-environment-jsdom",
rootDir: "./",
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@testing-library/react": "^16.0.1",
"@types/jest": "^29.5.13",
"@types/react": "18.3.11",
"@types/testing-library__jest-dom": "^5.14.9",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"core-js": "^3.38.1",
Expand Down
1 change: 1 addition & 0 deletions setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@testing-library/jest-dom";
1 change: 0 additions & 1 deletion src/components/Layout/Layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
screen,
fireEvent,
} from "@testing-library/react";
import "@testing-library/jest-dom";

import Layout from "./Layout";

Expand Down
8 changes: 4 additions & 4 deletions src/utils/ErrorBoundry.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe("<ErrorBoundry/>", () => {
const Greeting = () => {
return <div>Hello World</div>;
};
const FallbackComponent = (error) => <span>Error: {error.message}</span>;
const fallback = (error) => <span>Error: {error.message}</span>;
const { getByText, unmount } = render(
<ErrorBoundary fallback={<FallbackComponent />}>
<ErrorBoundary fallback={fallback}>
<Greeting />
</ErrorBoundary>,
);
Expand All @@ -27,9 +27,9 @@ describe("<ErrorBoundry/>", () => {
throw new Error("Oh shit");
};

const FallbackComponent = (error) => <span>Error: {error.message}</span>;
const fallback = (error) => <span>Error: {error.message}</span>;
const { unmount } = render(
<ErrorBoundary fallback={<FallbackComponent />}>
<ErrorBoundary fallback={fallback}>
<Greeting />
</ErrorBoundary>,
);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ErrorBoundry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, ReactNode } from "react";

interface Props {
children?: ReactNode;
fallback?: ReactNode;
fallback?: ReactNode | null;
}

interface State {
Expand Down
7 changes: 5 additions & 2 deletions src/utils/contentfulPosts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import {
Entry,
} from "contentful";

const space = process.env.NEXT_PUBLIC_CONTENTFUL_SPACE_ID || "";
const accessToken = process.env.NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN || "";

const client = createClient({
space: process.env.NEXT_PUBLIC_CONTENTFUL_SPACE_ID,
accessToken: process.env.NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN,
space,
accessToken,
});

export async function getAllPosts(name: string) {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"],
"types": ["node", "jest", "@testing-library/jest-dom"]
}
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit 73c58c1

Please sign in to comment.