diff --git a/__mocks__/fileMock.js b/__mocks__/fileMock.js new file mode 100644 index 0000000..08d725c --- /dev/null +++ b/__mocks__/fileMock.js @@ -0,0 +1 @@ +export default ''; diff --git a/jest.config.js b/jest.config.js index 6487180..d9bbb10 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,5 +13,7 @@ module.exports = { transformIgnorePatterns: ['/node_modules/', '^.+\\.module\\.(css|sass|scss)$'], moduleNameMapper: { '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy', + '\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': + '/__mocks__/fileMock.js', }, }; diff --git a/package.json b/package.json index 01c8547..9ce8220 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix", "tsc": "tsc --noEmit", "test": "jest --watch", - "test:ci": "jest --ci" + "test:ci": "jest --ci --coverage" }, "browserslist": [ "> 1% in NO", @@ -65,6 +65,7 @@ "eslint-plugin-react-hooks": "^4.1.2", "identity-obj-proxy": "^3.0.0", "jest": "^26.6.3", + "next-page-tester": "^0.5.0", "prettier": "^2.1.2", "react-test-renderer": "^17.0.1" } diff --git a/setupTests.js b/setupTests.js index 4966a54..a792f39 100644 --- a/setupTests.js +++ b/setupTests.js @@ -4,6 +4,7 @@ // used for __tests__/testing-library.js // learn more: https://github.com/testing-library/jest-dom import '@testing-library/jest-dom/extend-expect'; +import 'isomorphic-fetch'; import { setConfig } from 'next/config'; import { publicRuntimeConfig, serverRuntimeConfig } from './next.config'; diff --git a/src/__tests__/app.tsx b/src/__tests__/app.tsx new file mode 100644 index 0000000..b68044c --- /dev/null +++ b/src/__tests__/app.tsx @@ -0,0 +1,12 @@ +import { render } from '@testing-library/react'; +import { getPage } from 'next-page-tester'; +import { act } from 'react-dom/test-utils'; + +test('Renders index page correctly', async () => { + const Index = await getPage({ route: '/index', useCustomApp: true }); + const { getByText } = render(Index); + await act(async () => { + const title = await getByText('Kvitteringsskjema'); + expect(title).toBeInTheDocument(); + }); +}); diff --git a/src/components/Input/CommitteeDropdown.tsx b/src/components/Input/CommitteeDropdown.tsx index 3aa56f5..c1ebdcd 100644 --- a/src/components/Input/CommitteeDropdown.tsx +++ b/src/components/Input/CommitteeDropdown.tsx @@ -47,7 +47,6 @@ export const CommitteeDropdown: FC = () => {