Skip to content

Commit 167d87d

Browse files
authored
test: Set up Vitest (#131)
* build: Add vitest * build: Add @testing-library/react * build: Add @testing-library/user-event * build: Add jsdom * build: Add @testing-library/dom * build: Add @testing-library/jest-dom * test: Configure Vitest * test: Assert editor load notice * build: Add test-js make command * ci: Run JavaScript tests in CI * docs: Document test commands * test: Clean up stubbed test globals Avoid cryptic errors from lingering global stubs.
1 parent bd26c73 commit 167d87d

File tree

10 files changed

+1392
-56
lines changed

10 files changed

+1392
-56
lines changed

.buildkite/pipeline.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ steps:
1515
command: make lint-js
1616
plugins: *plugins
1717

18+
- label: ':javascript: Test JavaScript'
19+
command: make test-js
20+
plugins: *plugins
21+
1822
- label: ':android: Publish Android Library'
1923
command: |
2024
make build

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ fmt-js: npm-dependencies
4444
lint-js: npm-dependencies
4545
npm run lint
4646

47+
test-js: npm-dependencies
48+
npm run test -- run
49+
4750
local-android-library: build
4851
echo "--- :android: Building Library"
4952
./android/gradlew -p ./android :gutenberg:publishToMavenLocal -exclude-task prepareToPublishToS3

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@ GUTENBERG_EDITOR_URL=http://<YOUR_LOCAL_IP>:5173/
6060

6161
</details>
6262

63+
## Testing
64+
65+
To run the JavaScript tests, run the following command in your terminal:
66+
67+
```bash
68+
make test-js
69+
```
70+
71+
To run the Swift tests, run the following command in your terminal:
72+
73+
```bash
74+
make test-swift
75+
```
76+
77+
To run the Android tests, run the following command in your terminal:
78+
79+
```bash
80+
make test-android
81+
```
82+
6383
## Production
6484

6585
To build GutenbergKit for production run the following command in your terminal:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const Notice = ( { children, actions } ) => (
2+
<div data-testid="mock-notice">
3+
<span>{ children }</span>
4+
{ actions?.map( ( action, index ) => (
5+
<button
6+
key={ index }
7+
onClick={ action.onClick }
8+
data-variant={ action.variant }
9+
>
10+
{ action.label }
11+
</button>
12+
) ) }
13+
</div>
14+
);

__mocks__/@wordpress/i18n/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { vi } from 'vitest';
2+
3+
export const __ = vi.fn( ( text ) => text );

0 commit comments

Comments
 (0)