Skip to content

Commit

Permalink
feat(cli): add --no-open option (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerYeger committed Jan 26, 2022
1 parent aaa6df4 commit a2013a5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ You can specify additional CLI options like `--port` or `--https`. For a full li
| `-u, --update` | Update snapshots |
| `-w, --watch` | Watch mode |
| `-t, --testNamePattern <pattern>` | Run tests with names matching the pattern |
| `--ui` | Open UI |
| `--ui` | Enable UI |
| `--open` | Open the UI automatically if enabled (default: true) |
| `--api [api]` | Serve API, available options: `--api.port <port>`, `--api.host [host]` and `--api.strictPort` |
| `--threads` | Enable Threads (default: true) |
| `--silent` | Silent console output from tests |
Expand Down
3 changes: 2 additions & 1 deletion packages/vitest/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ cli
.option('-u, --update', 'update snapshot')
.option('-w, --watch', 'watch mode')
.option('-t, --testNamePattern <pattern>', 'run test names with the specified pattern')
.option('--ui', 'open UI')
.option('--ui', 'enable UI')
.option('--open', 'open UI automatically', { default: true })
.option('--api [api]', 'serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort')
.option('--threads', 'enabled threads', { default: true })
.option('--silent', 'silent console output from tests')
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function VitestPlugin(options: UserConfig = {}, viteOverrides: Vite
},
server: {
...options.api,
open: options.ui
open: options.ui && options.open
? options.uiBase ?? '/__vitest__/'
: undefined,
preTransformRequests: false,
Expand Down
9 changes: 8 additions & 1 deletion packages/vitest/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,18 @@ export interface InlineConfig {
api?: boolean | number | ApiConfig

/**
* Open Vitest UI
* Enable Vitest UI
* @internal WIP
*/
ui?: boolean

/**
* Open UI automatically.
*
* @default true
*/
open?: boolean

/**
* Base url for the UI
*
Expand Down

0 comments on commit a2013a5

Please sign in to comment.