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

tests: add unit tests for commands and utils #49

Merged
merged 13 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": ["@matterlabs/eslint-config-typescript"],
"rules": {
"no-console": "off",
"no-multiple-empty-lines": ["error", { "max": 1 }]
"no-multiple-empty-lines": ["error", { "max": 1 }],
"@typescript-eslint/no-namespace": "off"
}
}
36 changes: 21 additions & 15 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,44 @@ Hello, contributor! Thanks for thinking about helping with the `zkSync Era CLI`

- **Download the project.** Now, get the project on your computer:

```bash
git clone https://github.com/<your-github-username>/zksync-cli.git
```
```bash
git clone https://github.com/<your-github-username>/zksync-cli.git
```

- **Make a new branch.** Give your branch a simple name that tells what you're working on:

```bash
git checkout -b my-new-feature
```
```bash
git checkout -b my-new-feature
```

## Making Changes

- **Write your code.** Keep your code clear and easy to understand. It helps everyone.

- **Test your code.** Make sure your code is covered with tests and all tests are passing:

```bash
npm run test
```

- **Build and check your code.** Before you ask others to look at your code, make sure it works well. You can use these commands:

```bash
npm run build
node ./bin [your-command]
```
```bash
npm run build
npx zksync-cli [command] # you should be in the root directory of the project
```

- **Save your changes.** Use easy-to-understand messages when saving your changes.

- **Send your changes.** Now, put your code back on your GitHub:

```bash
git push origin my-new-feature
```
```bash
git push origin my-new-feature
```

## Sending a Pull Request

- **Ask to add your changes.** Go to the `zkSync Era CLI` project on GitHub. You'll see a button "Compare & pull request." Click it and tell us about your changes.
- **Ask to add your changes.** Go to the `zkSync Era CLI` repository on GitHub. You'll see a button "Compare & pull request." Click it and tell us about your changes.

- **Wait for feedback.** Our team will look at your changes. We might ask you to change some things.

Expand All @@ -67,4 +73,4 @@ We hope you enjoy helping and come back to help more. Thanks for being part of o

---

*Last update: September 1, 2023*
*Last update: September 7, 2023*
9 changes: 9 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ jobs:
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm run test -- --ci --reporters=default --reporters=jest-junit
- name: Publish Test Results
JackHamer09 marked this conversation as resolved.
Show resolved Hide resolved
uses: EnricoMi/publish-unit-test-result-action/composite@v1
if: always()
with:
files: "junit.xml"
check_run_annotations: all tests, skipped tests
report_individual_runs: "true"
12 changes: 5 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Default
node_modules
.env
coverage
coverage.json
typechain

#Hardhat files
cache
artifacts

# Build
bin

# Workflow
junit.xml
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ If you're using [local setup (dockerized testing node)](https://github.com/matte
### Run in development mode

1. Install all dependencies with `npm i`.
2. To use CLI in development mode run `NODE_ENV=development npx ts-node --transpile-only src/index.ts`.
2. To use CLI in development mode run `npm run dev -- [command] [options]` (eg. `npm run dev -- deposit --chain=era-testnet`).

### Building for production

Expand All @@ -62,10 +62,8 @@ If you're using [local setup (dockerized testing node)](https://github.com/matte

### Testing

> ⚠️ This project does not have unit tests yet 🤕

Proper tests will be included soon. For now, you can test new changes manually by running your build (refer to [Install and build](#install-and-build)).

1. Make sure you have all dependencies installed with `npm i`.
2. Run `npm run test` to run all tests.

### 📊 Tracking

Expand Down
9 changes: 9 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
preset: "ts-jest",
roots: ["<rootDir>/tests/"],
testMatch: ["./**/*.spec.ts"],
setupFilesAfterEnv: ["./tests/jestGlobalSetup.ts", "./tests/requestInterceptor.ts"],
transform: {
"^.+\\.ts?$": ["ts-jest", { tsconfig: "./tests/tsconfig.json" }],
},
};
Loading
Loading