https://velog.io/@superlipbalm/blogged-answers-a-mostly-complete-guide-to-react-rendering-behavior
OmitOmit은 TypeScript 유틸리티 타입으로, 주어진 타입에서 특정 속성을 제거한 새로운 타입을 생성합니다.
export type SnackbarType = {
  key: string;
  text: React.ReactNode;
  icon: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
}
export type TSnackbarProps = Omit<SnackbarType, 'key'> & {
  handleClose: () => void;
  open: boolean;
}
여기서는 Omit<SnackbarType, 'key'>를 사용하여 SnackbarType에서 key 속성을 제거한 타입을 생성했습니다.
왜?
→ 세팅 방식을 너무 많이 바꿔서 그냥 다시 처음 부터 Jest + RTL 세팅을 했다.
테스트 관련 라이브러리를 설치한다.
jest.config.ts 파일을 수정한다.
import type { Config } from "jest";
import nextJest from "next/jest.js";
const createJestConfig = nextJest({
  // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
  dir: "./",
});
// Add any custom config to be passed to Jest
const config: Config = {
  coverageProvider: "v8",
  testEnvironment: "jsdom",
  // Add more setup options before each test is run
  // setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
  setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
  testPathIgnorePatterns: ["<rootDir>/.next/", "<rootDir>/node_modules/"],
  moduleNameMapper: {
    "^@/(.*)$": "<rootDir>/src/$1",
  },
  transform: {
    "^.+\\.(ts|tsx)$": "ts-jest",
  },
};
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(config);
jest.setup.ts 파일을 생성한 후 아래 코드를 입력한다.
import "@testing-library/jest-dom";
tsconfig.json 파일을 수정한다.
{
  "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "baseUrl": "./",
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    ".next/types/**/*.ts",
    "jest.setup.ts"
  ],
  "exclude": ["node_modules"]
}
jest.setup.ts 를 추가하기만 하면 된다.테스트 코드를 작성한다.
    
    vscode 내부에서도 이상없이 코드가 작성되는 것을 볼 수 있다.