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 1 commit
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
67 changes: 63 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ 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)
- [Internships](#internships)
- [Community](#community)

Expand Down Expand Up @@ -98,20 +100,37 @@ 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
#### Jest Testing
aadhil2k4 marked this conversation as resolved.
Show resolved Hide resolved

1. Test using this set of commands:
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
```
Expand All @@ -120,6 +139,46 @@ The process of proposing a change to Talawa Admin can be summarized as:

![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

1. _General Information_
Expand Down
Loading