Skip to content

Commit be84759

Browse files
Fix test setup (#98)
* test: add unit test with vitest * test: add e2e tests using `msw` * ci: stricter permissions * update lock file * just assume node 24 * remove `next` branch references * simplify * use snapshots * tweak * revamp tests * make tests concurrent * refactor some tests * refactor * fixup branch name * add extra test case --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
1 parent 57f8dd7 commit be84759

7 files changed

Lines changed: 1516 additions & 3378 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Setup CI
2+
description: Setup Node and project dependencies using yarn
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup Node.js 24
8+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
9+
with:
10+
node-version: 24
11+
cache: yarn
12+
13+
- name: Install dependencies
14+
shell: bash
15+
run: yarn install --frozen-lockfile --ignore-scripts

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
merge_group:
9+
branches:
10+
- master
11+
12+
permissions: {}
13+
14+
jobs:
15+
test:
16+
name: Test
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
timeout-minutes: 20
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 6.0.1
24+
with:
25+
persist-credentials: false
26+
27+
- name: Setup dependencies
28+
uses: ./.github/actions/ci-setup
29+
30+
- name: Run test
31+
run: yarn test
32+
33+
ci-ok:
34+
name: CI OK
35+
runs-on: ubuntu-latest
36+
if: always()
37+
needs: [test]
38+
steps:
39+
- name: Exit with error if some jobs are not successful
40+
run: exit 1
41+
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }}

index.test.js

Lines changed: 0 additions & 171 deletions
This file was deleted.

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ ${changedPackages.map((x) => `"${x}": patch`).join("\n")}
9797
${title}
9898
`);
9999

100-
type PRContext = EmitterWebhookEvent<
100+
export type PRContext = EmitterWebhookEvent<
101101
"pull_request.opened" | "pull_request.synchronize"
102102
> &
103103
Omit<Context, keyof EmitterWebhookEvent>;

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
"private": true,
66
"repository": "https://github.com/changesets/bot",
77
"homepage": "https://github.com/apps/changeset-bot",
8+
"scripts": {
9+
"test": "vitest"
10+
},
811
"dependencies": {
912
"@changesets/assemble-release-plan": "^6.0.2",
1013
"@changesets/config": "^3.0.1",
1114
"@changesets/parse": "^0.4.0",
1215
"@changesets/types": "^6.0.0",
1316
"@manypkg/get-packages": "^1.1.3",
14-
"@types/bunyan": "^1.8.6",
15-
"@types/express": "^4.17.2",
16-
"@types/ioredis": "^4.14.8",
1717
"@types/js-yaml": "^3.12.2",
1818
"@types/markdown-table": "^2.0.0",
1919
"@types/micromatch": "^4.0.1",
20+
"@types/node": "^25.5.0",
2021
"@types/node-fetch": "^2.5.5",
2122
"@types/react": "^18.0.14",
2223
"@types/react-dom": "^18.0.5",
@@ -32,11 +33,11 @@
3233
"typescript": "^4.7.4"
3334
},
3435
"devDependencies": {
35-
"jest": "^24.1.0",
36-
"nock": "^10.0.0",
37-
"outdent": "^0.7.0"
36+
"msw": "^2.12.14",
37+
"vitest": "^4.1.1"
38+
},
39+
"resolutions": {
40+
"vite": "npm:vite@8.0.0-beta.18"
3841
},
39-
"jest": {
40-
"testEnvironment": "node"
41-
}
42+
"packageManager": "yarn@1.22.22"
4243
}

0 commit comments

Comments
 (0)