Skip to content
Merged
Changes from 6 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
41 changes: 41 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Instructions for AI pair programmer

## Testing

We use [Vitest](https://vitest.dev/api/) as our test runner.

Check warning on line 5 in .github/copilot-instructions.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.We] Try to avoid using first-person plural like 'our'. Raw Output: {"message": "[Google.We] Try to avoid using first-person plural like 'our'.", "location": {"path": ".github/copilot-instructions.md", "range": {"start": {"line": 5, "column": 45}}}, "severity": "WARNING"}

Check warning on line 5 in .github/copilot-instructions.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.We] Try to avoid using first-person plural like 'We'. Raw Output: {"message": "[Google.We] Try to avoid using first-person plural like 'We'.", "location": {"path": ".github/copilot-instructions.md", "range": {"start": {"line": 5, "column": 1}}}, "severity": "WARNING"}
There are two main types of test in this repository: unit tests and browser tests. Both use the same files.

To run tests:

- `browser tests`: `pnpm test:browser`
- Browser tests are enabled for any package that has a `vitest.config.browser.mts` in its root
- `unit tests`: `pnpm test:unit`
- Unit tests are enabled for any package that has a `vitest.config.jsdom.mts` in its root

The following options work in both environments:

- Always use the `--run` flag to skip watch mode.
- Always use `--project <project-name>` to run tests only for a specific project. The project names are defined by the folder names in the `packages` directory. Additionally you can use `<partial-project-name>*` to run tests for multiple projects that match the partial name.
- For example: `pnpm test:unit --run --project 'x-charts*'`
- To test a single file, you can append the file name to the command.
- For example: `pnpm test:unit --run --project 'x-charts' ChartsSurface.test.tsx`
- To test a single test, you can use use the `-t` flag followed by a regex that matches the test name. Always add the file name as well to avoid running all tests in the repo.
- For example: `pnpm test:unit --run --project 'x-charts' -t 'renders the surface' ChartsSurface.test.tsx`

### Ensuring a test only runs in a specific environment

- Use `it.skipIf(isJSDOM)` to skip when running unit tests
- Use `it.skipIf(!isJSDOM)` to run only in browser mode.

## Formatting

We use multiple formatters and scripts to ensure the code is consistent. Some of these scripts take multiple seconds to run.

Check warning on line 32 in .github/copilot-instructions.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.We] Try to avoid using first-person plural like 'We'. Raw Output: {"message": "[Google.We] Try to avoid using first-person plural like 'We'.", "location": {"path": ".github/copilot-instructions.md", "range": {"start": {"line": 32, "column": 1}}}, "severity": "WARNING"}

To format the code, run:

- `pnpm prettier:all` should always be run
- `pnpm eslint` should always be run
- `pnpm proptypes` should be run when editing React components
- `pnpm docs:api` should be run when editing React components or TypeScript types/interfaces
- `pnpm docs:typescript:formatted` should be run when creating or editing the docs examples using typescript
- `pnpm generate:exports` should always be run when committing code that touches the x-charts family of packages
Loading