diff --git a/packages/dapp/jest.config.ts b/packages/dapp/jest.config.ts new file mode 100644 index 00000000..e69eba3b --- /dev/null +++ b/packages/dapp/jest.config.ts @@ -0,0 +1,31 @@ +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: './', +}) + +const esModules = ['isows'].join('|'); + +const config: Config = { + coverageProvider: 'v8', + preset: "ts-jest", + rootDir: ".", + setupFilesAfterEnv: ["/test/setupTests.ts"], + testEnvironment: 'jsdom', + testMatch: ["/test/**/*.test.(ts|tsx)"], + transform: { + [`(${esModules}).+\.js$`]: "babel-jest", + "^.+\.(ts|tsx)$": [ + "ts-jest", { + tsconfig: "/tsconfig.test.json" + } + ], + }, + transformIgnorePatterns: [`/node_modules/(?!${esModules})`], + verbose: true, +} + +// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async +export default createJestConfig(config); \ No newline at end of file diff --git a/packages/dapp/package.json b/packages/dapp/package.json index 74dcefcd..c1f36a17 100644 --- a/packages/dapp/package.json +++ b/packages/dapp/package.json @@ -40,7 +40,8 @@ "dev": "next dev", "start": "next start", "build": "next build", - "test": "next test", + "test": "jest", + "test:watch": "jest --watch", "lint": "eslint \"**/*.{js,jsx,ts,tsx}\"", "format": "prettier --ignore-path .prettierignore --write \"**/*.{js,jsx,ts,tsx}\"" }, diff --git a/packages/dapp/test/components/NavButton.test.tsx b/packages/dapp/test/components/NavButton.test.tsx deleted file mode 100644 index 1f58c0d1..00000000 --- a/packages/dapp/test/components/NavButton.test.tsx +++ /dev/null @@ -1,13 +0,0 @@ -// import { render } from '@testing-library/react'; -// import React from 'react'; -// import { NavButton } from '../../src/components/NavButton'; - -// describe('NavButton', () => { -// const mockOnClickHandler = jest.fn(); - -// it('should render', () => { -// const view = render(); - -// expect(view.asFragment()).toMatchSnapshot(); -// }); -// }); diff --git a/packages/dapp/test/components/ProfileButton.test.tsx b/packages/dapp/test/components/ProfileButton.test.tsx deleted file mode 100644 index 9d37125f..00000000 --- a/packages/dapp/test/components/ProfileButton.test.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// import React from 'react'; - -// import { render } from '@testing-library/react'; - -// import { ProfileButton } from './ProfileButton'; - -// describe('ProfileButton', () => { -// const mockDisconnect = jest.fn(); - -// it('should render', () => { -// const view = render( -// , -// ); - -// expect(view.asFragment()).toMatchSnapshot(); -// }); -// }); diff --git a/packages/dapp/test/components/StyledButton.test.tsx b/packages/dapp/test/components/StyledButton.test.tsx deleted file mode 100644 index f53d2ed4..00000000 --- a/packages/dapp/test/components/StyledButton.test.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { render } from '@testing-library/react'; -import React from 'react'; -import { StyledButton } from './StyledButton'; - -describe('StyledButton', () => { - it('should render', () => { - const view = render(); - - expect(view.asFragment()).toMatchSnapshot(); - }); -}); diff --git a/packages/dapp/test/setupTests.ts b/packages/dapp/test/setupTests.ts index a4a3cfb1..9b61b6f9 100644 --- a/packages/dapp/test/setupTests.ts +++ b/packages/dapp/test/setupTests.ts @@ -1,3 +1,4 @@ +import '@testing-library/jest-dom'; import { TextEncoder, TextDecoder } from 'util'; Object.assign(global, { TextDecoder, TextEncoder }); \ No newline at end of file