-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from NEARBuilders/doc/readme
Updates README, Contributing guide, testing guide
- Loading branch information
Showing
10 changed files
with
212 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
prettier: | ||
name: Prettier | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
- name: Install dependencies | ||
run: npm install --frozen-lockfile | ||
- name: Run code formatting check | ||
run: npm run fmt:check | ||
playwright-tests: | ||
name: Playwright tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
cache: "npm" | ||
- uses: actions/cache@v3 | ||
id: playwright-cache | ||
with: | ||
path: | | ||
~/.cache/ms-playwright | ||
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }} | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install dependencies | ||
run: | | ||
npx playwright install-deps | ||
npx playwright install | ||
if: steps.playwright-cache.outputs.cache-hit != 'true' | ||
- name: Run tests | ||
run: | | ||
npx playwright test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Contributing Guide | ||
|
||
Thank you for considering contributing to near-directory! Here are some guidelines to help you get started. | ||
|
||
## Getting Started | ||
|
||
To contribute to near-directory, follow these steps: | ||
|
||
1. Fork the repository on GitHub. | ||
2. Clone your forked repository to your local machine. | ||
3. Make your changes locally. | ||
4. Test your changes to ensure they work as expected. | ||
5. Commit your changes with descriptive commit messages. We like [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716). | ||
6. Push your changes to your fork on GitHub. | ||
7. Create a pull request to the main repository. | ||
|
||
## Code Style | ||
|
||
Please follow the existing code style and conventions used in the project. | ||
|
||
## Testing | ||
|
||
This repository uses playwright tests, which can be found in [/playwright-tests](./playwright-tests/). Ensure that your changes include appropriate tests and that existing tests pass. | ||
|
||
## Submitting Issues | ||
|
||
If you encounter any issues or have feature requests, please submit them through GitHub issues. Include as much detail as possible to help us understand and address the problem efficiently. | ||
|
||
Thank you for your interest in contributing to near-directory! Your contributions are greatly appreciated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Testing Guide | ||
|
||
This project uses [playwright](https://playwright.dev/) for end-to-end testing. Please become familiar with this documentation. | ||
|
||
## Writing tests | ||
|
||
Tests should be written for each change or addition to the codebase. | ||
If a new feature is introduced, tests should be written to validate its functionality. If a bug is fixed, tests should be written to prevent regression. Writing tests not only safeguards against future breaks by other developers but also accelerates development by minimizing manual coding and browser interactions. | ||
|
||
When writing tests, remember to: | ||
|
||
- Test user-visible behavior | ||
- Make tests as isolated as possible | ||
- Avoid testing third-party dependencies | ||
|
||
> **[LEARN BEST PRACTICES](https://playwright.dev/docs/best-practices)** | ||
See the [cookbook](#cookbook) for help in covering scenerios. It is possible to [generate tests](https://playwright.dev/docs/codegen) via the [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright). | ||
|
||
## Running tests | ||
|
||
To run the tests, you may do so through the command line: | ||
|
||
```cmd | ||
npm run test | ||
``` | ||
|
||
With playwright's interactive testing UI: | ||
|
||
```cmd | ||
npm run test:ui | ||
``` | ||
|
||
Or through VS Code, see [Getting started - VS Code](https://playwright.dev/docs/getting-started-vscode). | ||
|
||
## Recording video | ||
|
||
You may automatically record video with your tests by setting | ||
|
||
``` | ||
use: { | ||
video: "on" | ||
} | ||
``` | ||
|
||
in the [playwright.config.js](../playwright.config.js). After running tests, you will find the output as a `.webm` in `./test-results`. Then, [convert to MP4](https://video.online-convert.com/convert/webm-to-mp4) and share. | ||
|
||
It is encouraged to include video in pull requests in order to demonstrate functionality and prove thorough testing. | ||
|
||
## Cookbook | ||
|
||
### Mocking fetch requests | ||
|
||
If you are testing a component that makes fetch requests, you can mock them using the [fetch](https://playwright.dev/docs/api/class-fetch) API. | ||
|
||
```javascript | ||
await page.route("**/api/hello", (route) => { | ||
return route.fulfill({ | ||
status: 200, | ||
body: "Hello, World!", | ||
}); | ||
}); | ||
``` | ||
|
||
Currently, we add this to the `beforeEach` hook in the test file. This way we do not have to mock the requests for every test. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters