Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the CONTRIBUTING.md Testing section to cover jest and vitest #3277

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ If you are new to contributing to open source, please read the Open Source Guide
- [Branching Strategy](#branching-strategy)
- [Conflict Resolution](#conflict-resolution)
- [Contributing Code](#contributing-code)
- [Jest Testing](#jest-testing)
- [Vitest Testing](#vitest-testing)
- [Combined testing and coverage](#combined-testing-and-coverage)
- [Internships](#internships)
- [Community](#community)

Expand Down Expand Up @@ -98,27 +101,58 @@ The process of proposing a change to Talawa Admin can be summarized as:
1. Pull requests that don't meet the minimum test coverage levels will not be accepted. This may mean that you will have to create tests for code you did not write. You can decide which part of the code base needs additional tests if this happens to you.
aadhil2k4 marked this conversation as resolved.
Show resolved Hide resolved

2. **_Testing_:**
aadhil2k4 marked this conversation as resolved.
Show resolved Hide resolved

1. Test using this set of commands:

#### Jest Testing
aadhil2k4 marked this conversation as resolved.
Show resolved Hide resolved
1. Running a single test:
```
npm run test path/to/test/file
```
2. Running all tests:
aadhil2k4 marked this conversation as resolved.
Show resolved Hide resolved
```
npm run test --watchAll=false
```
3. Viewing the code coverage of a single test file:
```
npm run test --watchAll=false --coverage /path/to/test/file
```
4. Viewing the code coverage of all test files:
```
npm install
npm run test --watchAll=false --coverage
```

2. Debug tests in browser

5. Debug tests in browser
You can see the output of failing tests in broswer by running `jest-preview` package before running your tests

```
npm install
npm run jest-preview
npm run test --watchAll=false --coverage
```

You don't need to re-run the `npm run jest-preview` command each time, simply run the `npm run test` command if the Jest Preview server is already running in the background, it'll automatically detect any failing tests and show the preview at `http://localhost:3336` as shown in this screenshot -

![Debugging Test Demo](./public/images/jest-preview.webp)
#### Vitest Testing
aadhil2k4 marked this conversation as resolved.
Show resolved Hide resolved
1. Running a single test:
```
npm run test:vitest /path/to/test/file
```
2. Running all tests:
```
npm run test:vitest
```
3. Viewing the code coverage of a single test file:
```
npm run test:vitest:coverage /path/to/test/file
```
4. Viewing the code coverage of all test files:
```
npm run test:vitest:coverage
```
#### Combined testing and coverage
aadhil2k4 marked this conversation as resolved.
Show resolved Hide resolved
1. Running all tests:
```
npm run test && npm run test:vitest
```
2. Viewing combined code coverage:
```
npm run test --watchAll=false --coverage && npm run test:vitest:coverage
```

3. **_Test Code Coverage_:**
aadhil2k4 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Loading