Skip to content

Commit

Permalink
docs: initial setup (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Dec 11, 2021
1 parent 82f7ca7 commit 48f7232
Show file tree
Hide file tree
Showing 15 changed files with 820 additions and 2 deletions.
136 changes: 136 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { defineConfig } from 'vitepress'

export default defineConfig({
title: 'Vitest',
description: 'A blazing fast unit test framework powered by Vite',
head: [
['meta', { property: 'og:title', content: 'Vitest' }],
['meta', { property: 'og:description', content: 'A blazing fast unit test framework powered by Vite' }],
['meta', { property: 'og:url', content: 'https://vitest.dev/' }],
['meta', { property: 'og:image', content: 'https://vitest.dev/og.png' }],
['meta', { name: 'twitter:title', content: 'Vitest' }],
['meta', { name: 'twitter:description', content: 'A blazing fast unit test framework powered by Vite' }],
['meta', { name: 'twitter:image', content: 'https://vitest.dev/og.png' }],
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
['link', { rel: 'icon', href: '/logo.svg', type: 'image/svg+xml' }],
['link', { href: 'https://fonts.googleapis.com/css2?family=Readex+Pro:wght@200;400;600&display=swap', rel: 'stylesheet' }],
],
themeConfig: {
repo: 'vitest-dev/vitest',
logo: '/logo.svg',
docsDir: 'docs',
docsBranch: 'main',
editLinks: true,
editLinkText: 'Suggest changes to this page',

/* TODO
algolia: {
apiKey: '...',
indexName: 'vitest',
searchParameters: {
facetFilters: ['tags:en']
}
},
carbonAds: {
carbon: '...',
placement: 'vitest'
},
*/

nav: [
{ text: 'Guide', link: '/guide/' },
{ text: 'Config', link: '/config/' },
{ text: 'Plugins', link: '/plugins/' },
{
text: 'Links',
items: [
{
text: 'Twitter',
link: 'https://twitter.com/vitest_dev'
},
{
text: 'Discord Chat',
link: 'https://discord.gg/2zYZNngd7y' // TODO 'https://chat.vitest.dev'
},
/* TODO
{
text: 'Changelog',
link: 'https://github.com/vitest-dev/vitest/blob/main/CHANGELOG.md'
}
*/
]
}
/* TODO
{
text: 'Languages',
items: [
{
text: 'English',
link: 'https://vitest.dev'
},
{
text: '简体中文',
link: 'https://cn.vitest.dev'
},
{
text: '日本語',
link: 'https://ja.vitest.dev'
}
]
}
*/
],

sidebar: {
'/config/': 'auto',
'/plugins': 'auto',
// catch-all fallback
'/': [
{
text: 'Guide',
children: [
{
text: 'Why Vitest',
link: '/guide/why'
},
{
text: 'Getting Started',
link: '/guide/'
},
{
text: 'Features',
link: '/guide/features'
},
/* TODO
{
text: 'Using Plugins',
link: '/guide/using-plugins'
},
*/
{
text: 'Comparisons',
link: '/guide/comparisons'
}
]
},
/* TODO
{
text: 'APIs',
children: [
{
text: 'Plugin API',
link: '/guide/api-plugin'
},
{
text: 'Config Reference',
link: '/config/'
}
]
}
*/
]
}
}
})
30 changes: 30 additions & 0 deletions docs/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.home-hero .image {
width: 200px;
height: 200px;
}

.nav-bar .logo {
height: 30px;
margin-right: 2px;
}

.content img {
border-radius: 10px;
}

.nav-dropdown-link-item .icon {
display: none;
}

:root {
--c-brand: #646cff;
--c-brand-light: #747bff;
}

.custom-block.tip {
border-color: var(--c-brand-light);
}

.DocSearch {
--docsearch-primary-color: var(--c-brand) !important;
}
5 changes: 5 additions & 0 deletions docs/.vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Theme from 'vitepress/theme'
import './custom.css'

export default Theme

72 changes: 72 additions & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Configuring Vitest

## Configuration

`vitest` will read your root `vite.config.ts` when it present to match with the plugins and setup as your Vite app. If you want to it to have a different configuration for testing, you could either:

- Create `vitest.config.ts`, which will have the higher priority
- Pass `--config` option to CLI, e.g. `vitest --config ./path/to/vitest.config.ts`
- Use `process.env.VITEST` to conditionally apply different configuration in `vite.config.ts`

To configure `vitest` itself, add `test` property in your Vite config

```ts
// vite.config.ts
import { defineConfig } from "vite";

export default defineConfig({
test: {
// ...
},
});
```

TODO: Mention [Config File Resolving](), [Config Intellisense]()

## Options

### global

- **Type:** `boolean`
- **Default:** `false`

By default, `vitest` does not provide global APIs for explicitness. If you prefer to use the APIs globally like Jest, you can pass the `--global` option to CLI or add `global: true` in the config.

```ts
// vite.config.ts
import { defineConfig } from "vite";

export default defineConfig({
test: {
global: true,
},
});
```

To get TypeScript working with the global APIs, add `vitest/global` to the `types` filed in your `tsconfig.json`

```jsonc
// tsconfig.json
{
"compilerOptions": {
"types": ["vitest/global"]
}
}
```

If you are already using [`unplugin-auto-import`](https://github.com/antfu/unplugin-vue-components) in your project, you can also use it directly for auto importing those APIs.

```ts
// vite.config.ts
import { defineConfig } from "vite";
import AutoImport from "unplugin-auto-import/vite";

export default defineConfig({
plugins: [
AutoImport({
imports: ["vitest"],
dts: true, // generate TypeScript declaration
}),
],
});
```
13 changes: 13 additions & 0 deletions docs/guide/comparisons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Comparisons with Other Test Runners

## Jest

[Jest](https://jestjs.io/) is...

## Cypress

[Cypress](https://www.cypress.io/) is...

## peeky

[peeky](https://peeky.dev/) is...
Loading

0 comments on commit 48f7232

Please sign in to comment.