Skip to content

Commit ebd14cc

Browse files
authored
Merge pull request #7 from solana-developers/scaffold-tests
feat: scaffold tests
2 parents 40bb925 + 4552b61 commit ebd14cc

File tree

7 files changed

+2585
-4
lines changed

7 files changed

+2585
-4
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#### Problem
2+
3+
4+
5+
#### Summary of Changes
6+
7+
8+
9+
Fixes #
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Install Dependencies
2+
description: Sets up Node and its package manager, then installs all dependencies
3+
4+
inputs:
5+
version:
6+
default: 'lts/*'
7+
type: string
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Install package manager
13+
uses: pnpm/action-setup@v3
14+
with:
15+
version: 9.1.0
16+
17+
- name: Setup Node
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: ${{ inputs.version }}
21+
cache: 'pnpm'
22+
23+
- name: Install dependencies
24+
shell: bash
25+
run: pnpm install
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Pull requests
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
all-pr-checks:
8+
runs-on: ubuntu-latest
9+
needs: build-and-test
10+
steps:
11+
- run: echo "Done"
12+
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node:
19+
- "current"
20+
- "lts/*"
21+
22+
name: Build & Test on Node ${{ matrix.node }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Install NPM Dependencies
28+
uses: ./.github/workflows/actions/install-npm-dependencies
29+
with:
30+
version: ${{ matrix.node }}
31+
32+
- name: Build
33+
run: pnpm build
34+
- name: Unit Tests
35+
run: pnpm test:unit

__tests__/example.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// import assert from "node:assert";
2+
3+
describe("scaffold", () => {
4+
test("example test", () => {
5+
// do a thing
6+
// assert.equal(think1, "thing2");
7+
});
8+
});

jest-unit.config.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Config } from "@jest/types";
2+
3+
const config: Partial<Config.InitialProjectOptions> = {
4+
resetMocks: true,
5+
restoreMocks: true,
6+
roots: ["<rootDir>/"],
7+
displayName: {
8+
color: "grey",
9+
name: "Unit Test",
10+
},
11+
transform: {
12+
"^.+\\.(ts|js)x?$": [
13+
"@swc/jest",
14+
{
15+
jsc: {
16+
target: "es2020",
17+
},
18+
},
19+
],
20+
},
21+
};
22+
23+
export default config;

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
"dev": "yarn build && yarn nsolana",
1313
"build": "rollup -c",
1414
"watch": "rollup -c --watch",
15+
"test": "pnpm test:unit",
16+
"test:unit": "jest -c ./jest-unit.config.ts --rootDir . --silent",
17+
"test:unit:watch": "jest -c ./jest-unit.config.ts --rootDir . --watch",
1518
"solana": "node ./bin/index.mjs",
1619
"changeset:version": "changeset version && git add -A && git commit -m \"chore: version\"",
1720
"changeset:publish": "pnpm build && changeset publish",
18-
"postpublish": "git push --follow-tags"
21+
"postpublish": "git push --follow-tags",
22+
"style:fix": "prettier --write '{*,**/*}.{ts,tsx,js,jsx,css,json,md}'"
1923
},
2024
"bin": {
2125
"nsolana": "bin/index.mjs",
@@ -43,19 +47,27 @@
4347
},
4448
"devDependencies": {
4549
"@changesets/cli": "^2.27.9",
50+
"@jest/types": "^29.6.3",
4651
"@rollup/plugin-commonjs": "^28.0.1",
4752
"@rollup/plugin-json": "^6.1.0",
4853
"@rollup/plugin-node-resolve": "^15.3.0",
4954
"@rollup/plugin-terser": "^0.4.4",
5055
"@rollup/plugin-typescript": "^12.1.1",
56+
"@swc/core": "^1.9.3",
57+
"@swc/jest": "^0.2.37",
5158
"@types/bn.js": "^5.1.6",
5259
"@types/inquirer": "^9.0.7",
60+
"@types/jest": "^29.5.14",
5361
"@types/node": "^22.7.6",
5462
"@types/prompts": "^2.4.9",
63+
"jest": "^29.7.0",
5564
"rollup": "^4.24.0",
65+
"ts-jest": "^29.2.5",
66+
"ts-node": "^10.9.2",
5667
"tslib": "^2.8.0",
5768
"typescript": "^5.6.3"
5869
},
70+
"packageManager": "[email protected]",
5971
"keywords": [],
6072
"homepage": "https://github.com/solana-developers/solana-node-cli#readme",
6173
"bugs": {

0 commit comments

Comments
 (0)