Skip to content

Commit

Permalink
init tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gcor committed Sep 19, 2023
1 parent bf0cd17 commit 44b4f7d
Show file tree
Hide file tree
Showing 6 changed files with 2,390 additions and 199 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.yarn

# local env files
.env*.local
Expand Down
20 changes: 20 additions & 0 deletions components/Layers/Lines/__tests__/CardContent.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { render } from '@testing-library/react';
import { LinesCardContent } from '../CardContent/CardContent';
import { LineObject } from '../lineType';

describe('CardContent', () => {
it('should render correctly', async () => {
const { getByText } = render(
<LinesCardContent
placemark={
{
geometry: [0, 0],
properties: { title: 'title' },
} as unknown as LineObject
}
/>,
);

expect(getByText('title')).toBeInTheDocument();
});
});
22 changes: 22 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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
/** @type {import('jest').Config} */
const config = {
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],

testEnvironment: 'jest-environment-jsdom',

modulePaths: ['<rootDir>/'],

prettierPath: null,
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(config);
1 change: 1 addition & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "pnpm run /^test:/",
"test": "jest",
"test:js": "next lint",
"test:types": "tsc --noEmit",
"devPreinstall": "husky install"
Expand Down Expand Up @@ -38,6 +38,10 @@
"typescript": "^5.1.6"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.5",
"@types/testing-library__jest-dom": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"eslint": "^8.47.0",
Expand All @@ -51,6 +55,8 @@
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^14.0.1",
"prettier": "3.0.2"
}
Expand Down
Loading

0 comments on commit 44b4f7d

Please sign in to comment.