Skip to content

Commit

Permalink
Jest testing setup (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
prathameshkoshti authored Oct 4, 2024
1 parent 69e32bc commit a284410
Show file tree
Hide file tree
Showing 9 changed files with 4,734 additions and 1,180 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": ["next/core-web-vitals", "next/typescript", "eslint:recommended"]
"extends": ["next/core-web-vitals", "next/typescript", "eslint:recommended"],
"env": {
"jest": true
}
}
3 changes: 3 additions & 0 deletions .github/workflows/nextjs-lint-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ jobs:

- name: TypeScript type check
run: npm run type-check

- name: Run Jest tests
run: npm run test
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ After the build is complete, you can start the production server with:
npm run start
```

## Running the test cases

To run the test cases, execute following command:
```bash
npm run test
```

To execute the test cases simultaneously as you make changes to the files, execute following command:
```bash
npm run test:watch
```

To get the test coverage of the project, execute following command:
```bash
npm run test:coverage
```

## Project Structure

The main components of the DiceDB Playground include:
Expand Down
21 changes: 21 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
};

// 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.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';
Loading

0 comments on commit a284410

Please sign in to comment.