diff --git a/docs/api/index.md b/docs/api/index.md
index d7a2dc8f9..5bbe17f02 100644
--- a/docs/api/index.md
+++ b/docs/api/index.md
@@ -75,9 +75,9 @@ For compatibility with Jest, `TestFunction` can also be of type `(done: DoneCall
// The two tests marked with concurrent will be run in parallel
describe('suite', () => {
- test('serial test', async() => { /* ... */ })
- test.concurrent('concurrent test 1', async() => { /* ... */ })
- test.concurrent('concurrent test 2', async() => { /* ... */ })
+ test('serial test', async () => { /* ... */ })
+ test.concurrent('concurrent test 1', async () => { /* ... */ })
+ test.concurrent('concurrent test 2', async () => { /* ... */ })
})
```
@@ -247,9 +247,9 @@ When you use `test` in the top level of file, they are collected as part of the
```ts
// All tests within this suite will be run in parallel
describe.concurrent('suite', () => {
- test('concurrent test 1', async() => { /* ... */ })
- test('concurrent test 2', async() => { /* ... */ })
- test.concurrent('concurrent test 3', async() => { /* ... */ })
+ test('concurrent test 1', async () => { /* ... */ })
+ test('concurrent test 2', async () => { /* ... */ })
+ test.concurrent('concurrent test 3', async () => { /* ... */ })
})
```
@@ -1131,7 +1131,7 @@ snapshots
return fetch('/buy/apples').then(r => r.json())
}
- test('buyApples returns new stock id', async() => {
+ test('buyApples returns new stock id', async () => {
// toEqual returns a promise now, so you HAVE to await it
await expect(buyApples()).resolves.toEqual({ id: 1 }) // jest API
await expect(buyApples()).resolves.to.equal({ id: 1 }) // chai API
@@ -1160,7 +1160,7 @@ snapshots
throw new Error('no id')
}
- test('buyApples throws an error when no id provided', async() => {
+ test('buyApples throws an error when no id provided', async () => {
// toThrow returns a promise now, so you HAVE to await it
await expect(buyApples()).rejects.toThrow('no id')
})
@@ -1187,7 +1187,7 @@ snapshots
)
}
- test('all assertions are called', async() => {
+ test('all assertions are called', async () => {
expect.assertions(2)
function callback1(data) {
expect(data).toBeTruthy()
@@ -1227,7 +1227,7 @@ snapshots
})
}
- test('callback was called', async() => {
+ test('callback was called', async () => {
expect.hasAssertions()
onSelect((data) => {
// should be called on select
@@ -1269,7 +1269,7 @@ These functions allow you to hook into the life cycle of tests to avoid repeatin
```ts
import { beforeEach } from 'vitest'
- beforeEach(async() => {
+ beforeEach(async () => {
// Clear mocks and add some testing data after before each test run
await stopMocking()
await addUser({ name: 'John' })
@@ -1290,7 +1290,7 @@ These functions allow you to hook into the life cycle of tests to avoid repeatin
```ts
import { afterEach } from 'vitest'
- afterEach(async() => {
+ afterEach(async () => {
await clearTestingData() // clear testing data after each test run
})
```
@@ -1308,7 +1308,7 @@ These functions allow you to hook into the life cycle of tests to avoid repeatin
```ts
import { beforeAll } from 'vitest'
- beforeAll(async() => {
+ beforeAll(async () => {
await startMocking() // called once before all tests run
})
```
@@ -1327,7 +1327,7 @@ These functions allow you to hook into the life cycle of tests to avoid repeatin
```ts
import { afterAll } from 'vitest'
- afterAll(async() => {
+ afterAll(async () => {
await stopMocking() // this method is called after all tests run
})
```
@@ -1454,7 +1454,7 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
import example from './example'
vi.mock('./example')
- test('1+1 equals 2', async() => {
+ test('1+1 equals 2', async () => {
vi.mocked(example.calc).mockRestore()
const res = example.calc(1, '+', 1)
@@ -1470,7 +1470,7 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
Imports module, bypassing all checks if it should be mocked. Can be useful if you want to mock module partially.
```ts
- vi.mock('./example', async() => {
+ vi.mock('./example', async () => {
const axios = await vi.importActual('./example')
return { ...axios, get: vi.fn() }
@@ -1496,13 +1496,13 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
vi.resetModules()
})
- test('change state', async() => {
+ test('change state', async () => {
const mod = await import('./some/path')
mod.changeLocalState('new value')
expect(mod.getlocalState()).toBe('new value')
})
- test('module has old state', async() => {
+ test('module has old state', async () => {
const mod = await import('./some/path')
expect(mod.getlocalState()).toBe('old value')
})
@@ -1682,7 +1682,7 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
Accepts an error that will be rejected, when async function will be called.
```ts
- test('async test', async() => {
+ test('async test', async () => {
const asyncMock = vi.fn().mockRejectedValue(new Error('Async error'))
await asyncMock() // throws "Async error"
@@ -1696,7 +1696,7 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
Accepts a value that will be rejected for one call to the mock function. If chained, every consecutive call will reject passed value.
```ts
- test('async test', async() => {
+ test('async test', async () => {
const asyncMock = vi
.fn()
.mockResolvedValueOnce('first call')
@@ -1732,7 +1732,7 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
Accepts a value that will be resolved, when async function will be called.
```ts
- test('async test', async() => {
+ test('async test', async () => {
const asyncMock = vi.fn().mockResolvedValue(43)
await asyncMock() // 43
@@ -1746,7 +1746,7 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
Accepts a value that will be resolved for one call to the mock function. If chained, every consecutive call will resolve passed value.
```ts
- test('async test', async() => {
+ test('async test', async () => {
const asyncMock = vi
.fn()
.mockResolvedValue('default')
diff --git a/docs/guide/features.md b/docs/guide/features.md
index cd6c50622..35f99adb1 100644
--- a/docs/guide/features.md
+++ b/docs/guide/features.md
@@ -63,7 +63,7 @@ You can optionally pass a timeout in milliseconds as third argument to tests. Th
```ts
import { test } from 'vitest'
-test('name', async() => { /* ... */ }, 1000)
+test('name', async () => { /* ... */ }, 1000)
```
Hooks also can receive a timeout, with the same 5 seconds default.
@@ -71,7 +71,7 @@ Hooks also can receive a timeout, with the same 5 seconds default.
```ts
import { beforeAll } from 'vitest'
-beforeAll(async() => { /* ... */ }, 1000)
+beforeAll(async () => { /* ... */ }, 1000)
```
### Skipping suites and tests
@@ -148,9 +148,9 @@ import { describe, it } from 'vitest'
// The two tests marked with concurrent will be run in parallel
describe('suite', () => {
- it('serial test', async() => { /* ... */ })
- it.concurrent('concurrent test 1', async() => { /* ... */ })
- it.concurrent('concurrent test 2', async() => { /* ... */ })
+ it('serial test', async () => { /* ... */ })
+ it.concurrent('concurrent test 1', async () => { /* ... */ })
+ it.concurrent('concurrent test 2', async () => { /* ... */ })
})
```
@@ -161,9 +161,9 @@ import { describe, it } from 'vitest'
// All tests within this suite will be run in parallel
describe.concurrent('suite', () => {
- it('concurrent test 1', async() => { /* ... */ })
- it('concurrent test 2', async() => { /* ... */ })
- it.concurrent('concurrent test 3', async() => { /* ... */ })
+ it('concurrent test 1', async () => { /* ... */ })
+ it('concurrent test 2', async () => { /* ... */ })
+ it.concurrent('concurrent test 3', async () => { /* ... */ })
})
```
diff --git a/docs/guide/mocking.md b/docs/guide/mocking.md
index c4eba1fb6..154ed9ba2 100644
--- a/docs/guide/mocking.md
+++ b/docs/guide/mocking.md
@@ -171,7 +171,7 @@ import { Client } from 'pg'
export function success(data) {}
export function failure(data) {}
// get todos
-export const getTodos = async(event, context) => {
+export const getTodos = async (event, context) => {
const client = new Client({
// ...clientOptions
})
@@ -226,7 +226,7 @@ describe('get a list of todo items', () => {
vi.clearAllMocks()
})
- it('should return items successfully', async() => {
+ it('should return items successfully', async () => {
client.query.mockResolvedValueOnce({ rows: [], rowCount: 0 })
await getTodos()
@@ -242,7 +242,7 @@ describe('get a list of todo items', () => {
})
})
- it('should throw an error', async() => {
+ it('should throw an error', async () => {
const mError = new Error('Unable to retrieve rows')
client.query.mockRejectedValueOnce(mError)
diff --git a/docs/scripts/assets.ts b/docs/scripts/assets.ts
index c665bab62..6948a09f0 100644
--- a/docs/scripts/assets.ts
+++ b/docs/scripts/assets.ts
@@ -12,10 +12,10 @@ const preconnectHome = `
${preconnectHomeLinks.map(l => ``).join('\n')}
`
-export const optimizePages = async(pwa: boolean) => {
+export const optimizePages = async (pwa: boolean) => {
const names = await fg('./.vitepress/dist/**/*.html', { onlyFiles: true })
- await Promise.all(names.map(async(i) => {
+ await Promise.all(names.map(async (i) => {
let html = await fs.readFile(i, 'utf-8')
let prefetchImg = '\n\t'
diff --git a/docs/scripts/build-pwa.ts b/docs/scripts/build-pwa.ts
index a6163f9b3..0a0fc34d6 100644
--- a/docs/scripts/build-pwa.ts
+++ b/docs/scripts/build-pwa.ts
@@ -2,7 +2,7 @@ import { resolveConfig } from 'vite'
import type { VitePluginPWAAPI } from 'vite-plugin-pwa'
import { optimizePages } from './assets'
-const rebuildPwa = async() => {
+const rebuildPwa = async () => {
const config = await resolveConfig({}, 'build', 'production')
// when `vite-plugin-pwa` is presented, use it to regenerate SW after rendering
const pwaPlugin: VitePluginPWAAPI = config.plugins.find(i => i.name === 'vite-plugin-pwa')?.api
diff --git a/docs/src/components/ListItem.vue b/docs/src/components/ListItem.vue
index c3c39cb33..a1b001f2f 100644
--- a/docs/src/components/ListItem.vue
+++ b/docs/src/components/ListItem.vue
@@ -28,7 +28,7 @@ const scope = effectScope()
const visibility = scope.run(() => useElementVisibility(el))
-onMounted(async() => {
+onMounted(async () => {
await until(visibility).toBe(true)
scope.stop()
diff --git a/examples/lit/test/basic.test.ts b/examples/lit/test/basic.test.ts
index 4199e2fba..f92c0b2c0 100644
--- a/examples/lit/test/basic.test.ts
+++ b/examples/lit/test/basic.test.ts
@@ -7,8 +7,8 @@ declare global {
interface Window extends IWindow {}
}
-describe('Button with increment', async() => {
- beforeEach(async() => {
+describe('Button with increment', async () => {
+ beforeEach(async () => {
document.body.innerHTML = ''
await window.happyDOM.whenAsyncComplete()
await new Promise(resolve => setTimeout(resolve, 0))
diff --git a/examples/mocks/test/automocking.spec.ts b/examples/mocks/test/automocking.spec.ts
index c1d49313a..69a757329 100644
--- a/examples/mocks/test/automocking.spec.ts
+++ b/examples/mocks/test/automocking.spec.ts
@@ -5,7 +5,7 @@ import { methodSymbol, moduleWithSymbol } from '../src/moduleWithSymbol'
vi.mock('../src/log')
vi.mock('../src/moduleWithSymbol')
-test('all mocked are valid', async() => {
+test('all mocked are valid', async () => {
const example = await vi.importMock('../src/example')
// creates a new mocked function with no formal arguments.
@@ -41,7 +41,7 @@ test('all mocked are valid', async() => {
expect(example.symbol).toEqual(Symbol.for('a.b.c'))
})
-test('automock properly restores mock', async() => {
+test('automock properly restores mock', async () => {
expect(log.warn()).toBeUndefined()
expect(moduleWithSymbol.warn()).toBeUndefined()
expect(moduleWithSymbol[methodSymbol]()).toBeUndefined()
diff --git a/examples/mocks/test/axios-not-mocked.test.ts b/examples/mocks/test/axios-not-mocked.test.ts
index a7e35e037..bef3540bc 100644
--- a/examples/mocks/test/axios-not-mocked.test.ts
+++ b/examples/mocks/test/axios-not-mocked.test.ts
@@ -1,6 +1,6 @@
import axios from 'axios'
-test('mocked axios', async() => {
+test('mocked axios', async () => {
const { default: ax } = await vi.importMock('axios')
await ax.get('string')
@@ -8,6 +8,6 @@ test('mocked axios', async() => {
expect(ax.get).toHaveBeenCalledWith('string')
})
-test('actual axios is not mocked', async() => {
+test('actual axios is not mocked', async () => {
expect(vi.isMockFunction(axios.get)).toBe(false)
})
diff --git a/examples/mocks/test/axios.test.ts b/examples/mocks/test/axios.test.ts
index fe2cec6f2..65004b7e4 100644
--- a/examples/mocks/test/axios.test.ts
+++ b/examples/mocks/test/axios.test.ts
@@ -2,14 +2,14 @@ import axios from 'axios'
vi.mock('axios')
-test('mocked axios', async() => {
+test('mocked axios', async () => {
await axios.get('string')
expect(axios.get).toHaveBeenCalledWith('string')
expect(axios.post).toBeUndefined()
})
-test('can get actual axios', async() => {
+test('can get actual axios', async () => {
const ax = await vi.importActual('axios')
expect(vi.isMockFunction(ax.get)).toBe(false)
diff --git a/examples/mocks/test/factory.test.ts b/examples/mocks/test/factory.test.ts
index 4c6256ce0..a60a62a0f 100644
--- a/examples/mocks/test/factory.test.ts
+++ b/examples/mocks/test/factory.test.ts
@@ -12,7 +12,7 @@ vi
// mocked: false,
// }))
-vi.mock('../src/moduleA', async() => {
+vi.mock('../src/moduleA', async () => {
const actual = await vi.importActual('../src/moduleA')
return {
B: 'B',
diff --git a/examples/mocks/test/tinyspy.test.ts b/examples/mocks/test/tinyspy.test.ts
index e7c724650..8df920c25 100644
--- a/examples/mocks/test/tinyspy.test.ts
+++ b/examples/mocks/test/tinyspy.test.ts
@@ -1,6 +1,6 @@
import type * as tinyspyModule from 'tinyspy'
-test('tinyspy is not mocked with __mocks__, but automatically mocked', async() => {
+test('tinyspy is not mocked with __mocks__, but automatically mocked', async () => {
const tinyspy = await vi.importMock('tinyspy')
expect(vi.isMockFunction(tinyspy.spyOn)).toBe(true)
diff --git a/examples/puppeteer/test/basic.test.ts b/examples/puppeteer/test/basic.test.ts
index fd6abbcc9..734a71d7f 100644
--- a/examples/puppeteer/test/basic.test.ts
+++ b/examples/puppeteer/test/basic.test.ts
@@ -4,23 +4,23 @@ import type { PreviewServer } from 'vite'
import puppeteer from 'puppeteer'
import type { Browser, Page } from 'puppeteer'
-describe('basic', async() => {
+describe('basic', async () => {
let server: PreviewServer
let browser: Browser
let page: Page
- beforeAll(async() => {
+ beforeAll(async () => {
server = await preview({ preview: { port: 3000 } })
browser = await puppeteer.launch()
page = await browser.newPage()
})
- afterAll(async() => {
+ afterAll(async () => {
await browser.close()
await server.httpServer.close()
})
- test('should have the correct title', async() => {
+ test('should have the correct title', async () => {
try {
await page.goto('http://localhost:3000')
const button = (await page.$('#btn'))!
diff --git a/examples/react-storybook/src/App.test.tsx b/examples/react-storybook/src/App.test.tsx
index d03dcade9..de00b372a 100644
--- a/examples/react-storybook/src/App.test.tsx
+++ b/examples/react-storybook/src/App.test.tsx
@@ -17,7 +17,7 @@ it('renders in the loading state', () => {
expect(screen.getByLabelText(/loading/i)).toBeInTheDocument()
})
-it('renders with data', async() => {
+it('renders with data', async () => {
render()
expect(
screen.getByRole('heading', {
@@ -26,7 +26,7 @@ it('renders with data', async() => {
}),
).toBeInTheDocument()
- posts.forEach(async(post) => {
+ posts.forEach(async (post) => {
expect(
await screen.findByRole('heading', { name: post.title, level: 2 }),
).toBeDefined()
@@ -34,7 +34,7 @@ it('renders with data', async() => {
})
})
-it('handles errors', async() => {
+it('handles errors', async () => {
render()
expect(
screen.getByRole('heading', {
diff --git a/examples/react-testing-lib-msw/src/App.test.tsx b/examples/react-testing-lib-msw/src/App.test.tsx
index 513da648b..c31a5a95f 100644
--- a/examples/react-testing-lib-msw/src/App.test.tsx
+++ b/examples/react-testing-lib-msw/src/App.test.tsx
@@ -5,7 +5,7 @@ import { render, screen, userEvent, waitForElementToBeRemoved } from './utils/te
import App from './App'
import { posts } from './mocks/handlers'
-it('Should return posts when clicking fetch button', async() => {
+it('Should return posts when clicking fetch button', async () => {
render(
)
@@ -22,7 +22,7 @@ it('Should return posts when clicking fetch button', async() => {
})
})
-it('Should return posts when clicking fetch with graphql button', async() => {
+it('Should return posts when clicking fetch with graphql button', async () => {
render(
)
diff --git a/examples/react-testing-lib-msw/src/App.tsx b/examples/react-testing-lib-msw/src/App.tsx
index d4988b635..0cf1fd315 100644
--- a/examples/react-testing-lib-msw/src/App.tsx
+++ b/examples/react-testing-lib-msw/src/App.tsx
@@ -13,7 +13,7 @@ function App() {
const [posts, setPosts] = React.useState([])
const [isLoading, setIsLoading] = React.useState(false)
- const fetchPosts = async() => {
+ const fetchPosts = async () => {
setIsLoading(true)
await fetch('https://jsonplaceholder.typicode.com/posts')
.then(res => res.json())
diff --git a/examples/react-testing-lib/src/App.test.tsx b/examples/react-testing-lib/src/App.test.tsx
index 2a004f6eb..f8f4ce7c1 100644
--- a/examples/react-testing-lib/src/App.test.tsx
+++ b/examples/react-testing-lib/src/App.test.tsx
@@ -8,7 +8,7 @@ describe('Simple working test', () => {
expect(screen.getByText(/Hello Vite \+ React!/i)).toBeInTheDocument()
})
- it('should increment count on click', async() => {
+ it('should increment count on click', async () => {
render()
userEvent.click(screen.getByRole('button'))
expect(await screen.findByText(/count is: 1/i)).toBeInTheDocument()
diff --git a/examples/react-testing-lib/src/components/input.test.tsx b/examples/react-testing-lib/src/components/input.test.tsx
index 9ed1c72a7..ba5a8224e 100644
--- a/examples/react-testing-lib/src/components/input.test.tsx
+++ b/examples/react-testing-lib/src/components/input.test.tsx
@@ -2,7 +2,7 @@ import '@testing-library/jest-dom'
import { render, screen, userEvent } from '../utils/test-utils'
import { Input } from './Input'
-describe('Input', async() => {
+describe('Input', async () => {
it('should render the input', () => {
render(
{
+test('mount component', async () => {
const host = document.createElement('div')
host.setAttribute('id', 'host')
document.body.appendChild(host)
diff --git a/examples/svelte/test/hello.test.ts b/examples/svelte/test/hello.test.ts
index cb3c9f7ad..0cc41dd51 100644
--- a/examples/svelte/test/hello.test.ts
+++ b/examples/svelte/test/hello.test.ts
@@ -12,7 +12,7 @@ describe('Hello.svelte', () => {
expect(container.innerHTML).toMatchSnapshot()
})
- it('updates on button click', async() => {
+ it('updates on button click', async () => {
render(Hello, { count: 4 })
const btn = screen.getByRole('button')
const div = screen.getByText('4 x 2 = 8')
diff --git a/examples/vitesse/test/basic.test.ts b/examples/vitesse/test/basic.test.ts
index cc961a241..899eec24a 100644
--- a/examples/vitesse/test/basic.test.ts
+++ b/examples/vitesse/test/basic.test.ts
@@ -1,7 +1,7 @@
import { mount } from '@vue/test-utils'
import Hello from '../src/components/Hello.vue'
-test('mount component', async() => {
+test('mount component', async () => {
expect(Hello).toBeTruthy()
const wrapper = mount(Hello, {
diff --git a/examples/vue/test/async.test.ts b/examples/vue/test/async.test.ts
index fcbdf08cc..69d68badd 100644
--- a/examples/vue/test/async.test.ts
+++ b/examples/vue/test/async.test.ts
@@ -2,7 +2,7 @@ import { nextTick } from 'vue'
import { flushPromises, mount } from '@vue/test-utils'
import AsyncWrapper from '../components/AsyncWrapper.vue'
-test('async component with suspense', async() => {
+test('async component with suspense', async () => {
expect(AsyncWrapper).toBeTruthy()
let resolve: Function
diff --git a/examples/vue/test/basic.test.ts b/examples/vue/test/basic.test.ts
index 116b288ec..8c800d74c 100644
--- a/examples/vue/test/basic.test.ts
+++ b/examples/vue/test/basic.test.ts
@@ -1,7 +1,7 @@
import { mount } from '@vue/test-utils'
import Hello from '../components/Hello.vue'
-test('mount component', async() => {
+test('mount component', async () => {
expect(Hello).toBeTruthy()
const wrapper = mount(Hello, {
diff --git a/examples/vue/test/imports.test.ts b/examples/vue/test/imports.test.ts
index 86d880b73..f1ffe3193 100644
--- a/examples/vue/test/imports.test.ts
+++ b/examples/vue/test/imports.test.ts
@@ -1,16 +1,16 @@
describe('import vue components', () => {
- test('normal imports as expected', async() => {
+ test('normal imports as expected', async () => {
const cmp = await import('../components/Hello.vue')
expect(cmp).toBeDefined()
})
- test('template string imports as expected', async() => {
+ test('template string imports as expected', async () => {
// eslint-disable-next-line quotes
const cmp = await import(`../components/Hello.vue`)
expect(cmp).toBeDefined()
})
- test('dynamic imports as expected', async() => {
+ test('dynamic imports as expected', async () => {
const name = 'Hello'
const cmp = await import(`../components/${name}.vue`)
expect(cmp).toBeDefined()
diff --git a/examples/vue2/test/basic.test.ts b/examples/vue2/test/basic.test.ts
index 88fd8e75f..f2d1a3b8e 100644
--- a/examples/vue2/test/basic.test.ts
+++ b/examples/vue2/test/basic.test.ts
@@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
import { nextTick } from '@vue/composition-api'
import Hello from '../src/components/Options.vue'
-test('mount component', async() => {
+test('mount component', async () => {
expect(Hello).toBeTruthy()
const wrapper = mount(Hello, {
diff --git a/examples/vue2/test/script-setup.test.ts b/examples/vue2/test/script-setup.test.ts
index 51b3320cf..93bef086c 100644
--- a/examples/vue2/test/script-setup.test.ts
+++ b/examples/vue2/test/script-setup.test.ts
@@ -3,7 +3,7 @@ import { nextTick } from '@vue/composition-api'
import Hello from '../src/components/ScriptSetup.vue'
// TODO: find out why
-test.skip('mount component', async() => {
+test.skip('mount component', async () => {
expect(Hello).toBeTruthy()
const wrapper = mount(Hello, {
diff --git a/packages/ui/client/components/CodeMirror.vue b/packages/ui/client/components/CodeMirror.vue
index e56e76ed9..f965d8cc5 100644
--- a/packages/ui/client/components/CodeMirror.vue
+++ b/packages/ui/client/components/CodeMirror.vue
@@ -34,17 +34,17 @@ const cm = shallowRef()
defineExpose({ cm })
-onMounted(async() => {
+onMounted(async () => {
cm.value = useCodeMirror(el, input, {
...props,
...attrs,
mode: modeMap[props.mode || ''] || props.mode,
readOnly: props.readOnly ? 'nocursor' : undefined,
extraKeys: {
- 'Cmd-S': function(cm) {
+ 'Cmd-S': function (cm) {
emit('save', cm.getValue())
},
- 'Ctrl-S': function(cm) {
+ 'Ctrl-S': function (cm) {
emit('save', cm.getValue())
},
},
diff --git a/packages/ui/client/components/FileDetails.vue b/packages/ui/client/components/FileDetails.vue
index b08faa7a5..76e2c6fe3 100644
--- a/packages/ui/client/components/FileDetails.vue
+++ b/packages/ui/client/components/FileDetails.vue
@@ -12,7 +12,7 @@ const draft = ref(false)
debouncedWatch(
current,
- async(c, o) => {
+ async (c, o) => {
if (c && c.filepath !== o?.filepath) {
data.value = await client.rpc.getModuleGraph(c.filepath)
graph.value = getModuleGraph(data.value, c.filepath)
diff --git a/packages/ui/client/components/views/ViewEditor.vue b/packages/ui/client/components/views/ViewEditor.vue
index 9d58bec8a..9264fe11a 100644
--- a/packages/ui/client/components/views/ViewEditor.vue
+++ b/packages/ui/client/components/views/ViewEditor.vue
@@ -14,7 +14,7 @@ const code = ref('')
const serverCode = shallowRef(undefined)
const draft = ref(false)
watch(() => props.file,
- async() => {
+ async () => {
if (!props.file || !props.file?.filepath) {
code.value = ''
serverCode.value = code.value
@@ -93,7 +93,7 @@ watch([cm, failed], ([cmValue]) => {
content: 'Open in Editor',
placement: 'bottom',
}, false)
- const el: EventListener = async() => {
+ const el: EventListener = async () => {
await openInEditor(stacks[0].file, pos.line, pos.column)
}
div.appendChild(span)
diff --git a/packages/vite-node/src/cli.ts b/packages/vite-node/src/cli.ts
index ee5893be0..66a7ab502 100644
--- a/packages/vite-node/src/cli.ts
+++ b/packages/vite-node/src/cli.ts
@@ -95,7 +95,7 @@ async function run(options: CliOptions = {}) {
if (!options.watch)
await server.close()
- server.watcher.on('change', async(eventName, path) => {
+ server.watcher.on('change', async (eventName, path) => {
// eslint-disable-next-line no-console
console.log(dim(`[${eventName}] ${path}`))
diff --git a/packages/vite-node/src/client.ts b/packages/vite-node/src/client.ts
index 6cf320995..fd9a6bb1e 100644
--- a/packages/vite-node/src/client.ts
+++ b/packages/vite-node/src/client.ts
@@ -90,7 +90,7 @@ export class ViteNodeRunner {
/** @internal */
async directRequest(id: string, fsPath: string, _callstack: string[]) {
const callstack = [..._callstack, normalizeModuleId(id)]
- const request = async(dep: string) => {
+ const request = async (dep: string) => {
const getStack = () => {
return `stack:\n${[...callstack, dep].reverse().map(p => `- ${p}`).join('\n')}`
}
@@ -242,7 +242,7 @@ export class ViteNodeRunner {
}
function proxyMethod(name: 'get' | 'set' | 'has' | 'deleteProperty', tryDefault: boolean) {
- return function(target: any, key: string | symbol, ...args: [any?, any?]) {
+ return function (target: any, key: string | symbol, ...args: [any?, any?]) {
const result = Reflect[name](target, key, ...args)
if (isPrimitive(target.default))
return result
diff --git a/packages/vitest/src/api/setup.ts b/packages/vitest/src/api/setup.ts
index 50daf1909..23545953b 100644
--- a/packages/vitest/src/api/setup.ts
+++ b/packages/vitest/src/api/setup.ts
@@ -137,7 +137,7 @@ class WebSocketReporter implements Reporter {
if (this.clients.size === 0)
return
- await Promise.all(packs.map(async(i) => {
+ await Promise.all(packs.map(async (i) => {
if (i[1]?.error)
await interpretSourcePos(parseStacktrace(i[1].error as any), this.ctx)
}))
diff --git a/packages/vitest/src/integrations/chai/jest-expect.ts b/packages/vitest/src/integrations/chai/jest-expect.ts
index a2f5d5f3c..4c8349b23 100644
--- a/packages/vitest/src/integrations/chai/jest-expect.ts
+++ b/packages/vitest/src/integrations/chai/jest-expect.ts
@@ -52,7 +52,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
(['throw', 'throws', 'Throw'] as const).forEach((m) => {
utils.overwriteMethod(chai.Assertion.prototype, m, (_super: any) => {
- return function(this: Chai.Assertion & Chai.AssertionStatic, ...args: any[]) {
+ return function (this: Chai.Assertion & Chai.AssertionStatic, ...args: any[]) {
const promise = utils.flag(this, 'promise')
const object = utils.flag(this, 'object')
if (promise === 'rejects') {
@@ -65,7 +65,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
})
})
- def('toEqual', function(expected) {
+ def('toEqual', function (expected) {
const actual = utils.flag(this, 'object')
const equal = jestEquals(
actual,
@@ -82,7 +82,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
)
})
- def('toStrictEqual', function(expected) {
+ def('toStrictEqual', function (expected) {
const obj = utils.flag(this, 'object')
const equal = jestEquals(
obj,
@@ -104,7 +104,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
obj,
)
})
- def('toBe', function(expected) {
+ def('toBe', function (expected) {
const actual = this._obj
return this.assert(
Object.is(actual, expected),
@@ -114,7 +114,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
actual,
)
})
- def('toMatchObject', function(expected) {
+ def('toMatchObject', function (expected) {
const actual = this._obj
return this.assert(
jestEquals(actual, expected, [iterableEquality, subsetEquality]),
@@ -124,16 +124,16 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
actual,
)
})
- def('toMatch', function(expected: string | RegExp) {
+ def('toMatch', function (expected: string | RegExp) {
if (typeof expected === 'string')
return this.include(expected)
else
return this.match(expected)
})
- def('toContain', function(item) {
+ def('toContain', function (item) {
return this.contain(item)
})
- def('toContainEqual', function(expected) {
+ def('toContainEqual', function (expected) {
const obj = utils.flag(this, 'object')
const index = Array.from(obj).findIndex((item) => {
return jestEquals(item, expected)
@@ -146,7 +146,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
expected,
)
})
- def('toBeTruthy', function() {
+ def('toBeTruthy', function () {
const obj = utils.flag(this, 'object')
this.assert(
Boolean(obj),
@@ -155,7 +155,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
obj,
)
})
- def('toBeFalsy', function() {
+ def('toBeFalsy', function () {
const obj = utils.flag(this, 'object')
this.assert(
!obj,
@@ -164,7 +164,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
obj,
)
})
- def('toBeGreaterThan', function(expected: number | bigint) {
+ def('toBeGreaterThan', function (expected: number | bigint) {
const actual = this._obj
assertTypes(actual, 'actual', ['number', 'bigint'])
assertTypes(expected, 'expected', ['number', 'bigint'])
@@ -176,7 +176,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
expected,
)
})
- def('toBeGreaterThanOrEqual', function(expected: number | bigint) {
+ def('toBeGreaterThanOrEqual', function (expected: number | bigint) {
const actual = this._obj
assertTypes(actual, 'actual', ['number', 'bigint'])
assertTypes(expected, 'expected', ['number', 'bigint'])
@@ -188,7 +188,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
expected,
)
})
- def('toBeLessThan', function(expected: number | bigint) {
+ def('toBeLessThan', function (expected: number | bigint) {
const actual = this._obj
assertTypes(actual, 'actual', ['number', 'bigint'])
assertTypes(expected, 'expected', ['number', 'bigint'])
@@ -200,7 +200,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
expected,
)
})
- def('toBeLessThanOrEqual', function(expected: number | bigint) {
+ def('toBeLessThanOrEqual', function (expected: number | bigint) {
const actual = this._obj
assertTypes(actual, 'actual', ['number', 'bigint'])
assertTypes(expected, 'expected', ['number', 'bigint'])
@@ -212,16 +212,16 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
expected,
)
})
- def('toBeNaN', function() {
+ def('toBeNaN', function () {
return this.be.NaN
})
- def('toBeUndefined', function() {
+ def('toBeUndefined', function () {
return this.be.undefined
})
- def('toBeNull', function() {
+ def('toBeNull', function () {
return this.be.null
})
- def('toBeDefined', function() {
+ def('toBeDefined', function () {
const negate = utils.flag(this, 'negate')
utils.flag(this, 'negate', false)
@@ -230,7 +230,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
return this.not.be.undefined
})
- def('toBeTypeOf', function(expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined') {
+ def('toBeTypeOf', function (expected: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined') {
const actual = typeof this._obj
const equal = expected === actual
return this.assert(
@@ -241,20 +241,20 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
actual,
)
})
- def('toBeInstanceOf', function(obj: any) {
+ def('toBeInstanceOf', function (obj: any) {
return this.instanceOf(obj)
})
- def('toHaveLength', function(length: number) {
+ def('toHaveLength', function (length: number) {
return this.have.length(length)
})
// destructuring, because it checks `arguments` inside, and value is passing as `undefined`
- def('toHaveProperty', function(...args: [property: string | string[], value?: any]) {
+ def('toHaveProperty', function (...args: [property: string | string[], value?: any]) {
if (Array.isArray(args[0]))
args[0] = args[0].map(key => key.replace(/([.[\]])/g, '\\$1')).join('.')
return this.have.deep.nested.property(...args as [property: string, value?: any])
})
- def('toBeCloseTo', function(received: number, precision = 2) {
+ def('toBeCloseTo', function (received: number, precision = 2) {
const expected = this._obj
let pass = false
let expectedDiff = 0
@@ -317,7 +317,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
msg += c.gray(`\n\nNumber of calls: ${c.bold(spy.mock.calls.length)}\n`)
return msg
}
- def(['toHaveBeenCalledTimes', 'toBeCalledTimes'], function(number: number) {
+ def(['toHaveBeenCalledTimes', 'toBeCalledTimes'], function (number: number) {
const spy = getSpy(this)
const spyName = spy.getMockName()
const callCount = spy.mock.calls.length
@@ -329,7 +329,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
callCount,
)
})
- def('toHaveBeenCalledOnce', function() {
+ def('toHaveBeenCalledOnce', function () {
const spy = getSpy(this)
const spyName = spy.getMockName()
const callCount = spy.mock.calls.length
@@ -341,7 +341,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
callCount,
)
})
- def(['toHaveBeenCalled', 'toBeCalled'], function() {
+ def(['toHaveBeenCalled', 'toBeCalled'], function () {
const spy = getSpy(this)
const spyName = spy.getMockName()
const called = spy.mock.calls.length > 0
@@ -365,7 +365,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
throw err
}
})
- def(['toHaveBeenCalledWith', 'toBeCalledWith'], function(...args) {
+ def(['toHaveBeenCalledWith', 'toBeCalledWith'], function (...args) {
const spy = getSpy(this)
const spyName = spy.getMockName()
const pass = spy.mock.calls.some(callArg => jestEquals(callArg, args, [iterableEquality]))
@@ -388,7 +388,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
throw err
}
})
- def(['toHaveBeenNthCalledWith', 'nthCalledWith'], function(times: number, ...args: any[]) {
+ def(['toHaveBeenNthCalledWith', 'nthCalledWith'], function (times: number, ...args: any[]) {
const spy = getSpy(this)
const spyName = spy.getMockName()
const nthCall = spy.mock.calls[times - 1]
@@ -401,7 +401,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
nthCall,
)
})
- def(['toHaveBeenLastCalledWith', 'lastCalledWith'], function(...args: any[]) {
+ def(['toHaveBeenLastCalledWith', 'lastCalledWith'], function (...args: any[]) {
const spy = getSpy(this)
const spyName = spy.getMockName()
const lastCall = spy.mock.calls[spy.calls.length - 1]
@@ -414,7 +414,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
lastCall,
)
})
- def(['toThrow', 'toThrowError'], function(expected?: string | Constructable | RegExp | Error) {
+ def(['toThrow', 'toThrowError'], function (expected?: string | Constructable | RegExp | Error) {
if (typeof expected === 'string' || typeof expected === 'undefined' || expected instanceof RegExp)
return this.throws(expected)
@@ -468,7 +468,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
throw new Error(`"toThrow" expects string, RegExp, function, Error instance or asymmetric matcher, got "${typeof expected}"`)
})
- def(['toHaveReturned', 'toReturn'], function() {
+ def(['toHaveReturned', 'toReturn'], function () {
const spy = getSpy(this)
const spyName = spy.getMockName()
const calledAndNotThrew = spy.mock.calls.length > 0 && !spy.mock.results.some(({ type }) => type === 'throw')
@@ -480,7 +480,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
!calledAndNotThrew,
)
})
- def(['toHaveReturnedTimes', 'toReturnTimes'], function(times: number) {
+ def(['toHaveReturnedTimes', 'toReturnTimes'], function (times: number) {
const spy = getSpy(this)
const spyName = spy.getMockName()
const successfullReturns = spy.mock.results.reduce((success, { type }) => type === 'throw' ? success : ++success, 0)
@@ -492,7 +492,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
`received number of returns: ${successfullReturns}`,
)
})
- def(['toHaveReturnedWith', 'toReturnWith'], function(value: any) {
+ def(['toHaveReturnedWith', 'toReturnWith'], function (value: any) {
const spy = getSpy(this)
const spyName = spy.getMockName()
const pass = spy.mock.results.some(({ type, value: result }) => type === 'return' && jestEquals(value, result))
@@ -503,7 +503,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
value,
)
})
- def(['toHaveLastReturnedWith', 'lastReturnedWith'], function(value: any) {
+ def(['toHaveLastReturnedWith', 'lastReturnedWith'], function (value: any) {
const spy = getSpy(this)
const spyName = spy.getMockName()
const { value: lastResult } = spy.mock.results[spy.returns.length - 1]
@@ -516,7 +516,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
lastResult,
)
})
- def(['toHaveNthReturnedWith', 'nthReturnedWith'], function(nthCall: number, value: any) {
+ def(['toHaveNthReturnedWith', 'nthReturnedWith'], function (nthCall: number, value: any) {
const spy = getSpy(this)
const spyName = spy.getMockName()
const isNot = utils.flag(this, 'negate') as boolean
@@ -536,7 +536,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
callResult,
)
})
- def('toSatisfy', function() {
+ def('toSatisfy', function () {
return this.be.satisfy
})
@@ -551,7 +551,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
if (typeof result !== 'function')
return result instanceof chai.Assertion ? proxy : result
- return async(...args: any[]) => {
+ return async (...args: any[]) => {
return obj.then(
(value: any) => {
utils.flag(this, 'object', value)
@@ -580,7 +580,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
if (typeof result !== 'function')
return result instanceof chai.Assertion ? proxy : result
- return async(...args: any[]) => {
+ return async (...args: any[]) => {
return wrapper.then(
(value: any) => {
throw new Error(`promise resolved "${value}" instead of rejecting`)
diff --git a/packages/vitest/src/integrations/coverage.ts b/packages/vitest/src/integrations/coverage.ts
index 99bec798a..57cf3421a 100644
--- a/packages/vitest/src/integrations/coverage.ts
+++ b/packages/vitest/src/integrations/coverage.ts
@@ -53,7 +53,7 @@ export async function reportCoverage(ctx: Vitest) {
await Promise.all(Array
.from(ctx.vitenode.fetchCache.entries())
.filter(i => !i[0].includes('/node_modules/'))
- .map(async([file, { result }]) => {
+ .map(async ([file, { result }]) => {
const map = result.map
if (!map)
return
diff --git a/packages/vitest/src/integrations/mockdate.ts b/packages/vitest/src/integrations/mockdate.ts
index 83a5a7768..71fa1167a 100644
--- a/packages/vitest/src/integrations/mockdate.ts
+++ b/packages/vitest/src/integrations/mockdate.ts
@@ -63,15 +63,15 @@ class MockDate extends RealDate {
MockDate.UTC = RealDate.UTC
-MockDate.now = function() {
+MockDate.now = function () {
return new MockDate().valueOf()
}
-MockDate.parse = function(dateString) {
+MockDate.parse = function (dateString) {
return RealDate.parse(dateString)
}
-MockDate.toString = function() {
+MockDate.toString = function () {
return RealDate.toString()
}
diff --git a/packages/vitest/src/integrations/snapshot/chai.ts b/packages/vitest/src/integrations/snapshot/chai.ts
index c91d4dfac..67e5cdee3 100644
--- a/packages/vitest/src/integrations/snapshot/chai.ts
+++ b/packages/vitest/src/integrations/snapshot/chai.ts
@@ -29,7 +29,7 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
utils.addMethod(
chai.Assertion.prototype,
key,
- function(this: Record, properties?: object, message?: string) {
+ function (this: Record, properties?: object, message?: string) {
const expected = utils.flag(this, 'object')
if (typeof properties === 'string' && typeof message === 'undefined') {
message = properties
@@ -58,7 +58,7 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
utils.addMethod(
chai.Assertion.prototype,
'toThrowErrorMatchingSnapshot',
- function(this: Record, message?: string) {
+ function (this: Record, message?: string) {
const expected = utils.flag(this, 'object')
getSnapshotClient().assert(getErrorString(expected), message)
},
diff --git a/packages/vitest/src/integrations/snapshot/port/inlineSnapshot.ts b/packages/vitest/src/integrations/snapshot/port/inlineSnapshot.ts
index 4970f74d2..dc3a825ac 100644
--- a/packages/vitest/src/integrations/snapshot/port/inlineSnapshot.ts
+++ b/packages/vitest/src/integrations/snapshot/port/inlineSnapshot.ts
@@ -16,7 +16,7 @@ export async function saveInlineSnapshots(
) {
const MagicString = (await import('magic-string')).default
const files = new Set(snapshots.map(i => i.file))
- await Promise.all(Array.from(files).map(async(file) => {
+ await Promise.all(Array.from(files).map(async (file) => {
const map = await rpc().getSourceMap(file)
const snaps = snapshots.filter(i => i.file === file)
const code = await fs.readFile(file, 'utf8')
diff --git a/packages/vitest/src/integrations/spy.ts b/packages/vitest/src/integrations/spy.ts
index 821d9a2d3..b9f040116 100644
--- a/packages/vitest/src/integrations/spy.ts
+++ b/packages/vitest/src/integrations/spy.ts
@@ -213,7 +213,7 @@ function enhanceSpy(
}
stub.mockReturnThis = () =>
- stub.mockImplementation(function(this: TReturns) {
+ stub.mockImplementation(function (this: TReturns) {
return this
})
@@ -236,7 +236,7 @@ function enhanceSpy(
get: () => mockContext,
})
- stub.willCall(function(this: unknown, ...args) {
+ stub.willCall(function (this: unknown, ...args) {
instances.push(this)
invocations.push(++callOrder)
const impl = onceImplementations.shift() || implementation || stub.getOriginal() || (() => {})
diff --git a/packages/vitest/src/node/core.ts b/packages/vitest/src/node/core.ts
index 3b8cdf909..0e06e00d2 100644
--- a/packages/vitest/src/node/core.ts
+++ b/packages/vitest/src/node/core.ts
@@ -151,7 +151,7 @@ export class Vitest {
private async getTestDependencies(filepath: string) {
const deps = new Set()
- const addImports = async(filepath: string) => {
+ const addImports = async (filepath: string) => {
const transformed = await this.vitenode.transformRequest(filepath)
if (!transformed)
return
@@ -194,7 +194,7 @@ export class Vitest {
return []
const testDeps = await Promise.all(
- tests.map(async(filepath) => {
+ tests.map(async (filepath) => {
const deps = await this.getTestDependencies(filepath)
return [filepath, deps] as const
}),
@@ -214,7 +214,7 @@ export class Vitest {
async runFiles(files: string[]) {
await this.runningPromise
- this.runningPromise = (async() => {
+ this.runningPromise = (async () => {
if (!this.pool)
this.pool = createPool(this)
@@ -298,7 +298,7 @@ export class Vitest {
if (this.restartsCount !== currentCount)
return
- this._rerunTimer = setTimeout(async() => {
+ this._rerunTimer = setTimeout(async () => {
if (this.changedTests.size === 0) {
this.invalidates.clear()
return
@@ -353,7 +353,7 @@ export class Vitest {
this.report('onTestRemoved', id)
}
}
- const onAdd = async(id: string) => {
+ const onAdd = async (id: string) => {
id = slash(id)
if (await this.isTargetFile(id)) {
this.changedTests.add(id)
@@ -456,7 +456,7 @@ export class Vitest {
if (filters.length)
files = files.filter(i => filters.some(f => i.includes(f)))
- await Promise.all(files.map(async(file) => {
+ await Promise.all(files.map(async (file) => {
try {
const code = await fs.readFile(file, 'utf-8')
if (this.isInSourceTestFile(code))
diff --git a/packages/vitest/src/node/error.ts b/packages/vitest/src/node/error.ts
index 999a61f2f..c973e1b22 100644
--- a/packages/vitest/src/node/error.ts
+++ b/packages/vitest/src/node/error.ts
@@ -37,7 +37,7 @@ export async function printError(error: unknown, ctx: Vitest) {
)
printErrorMessage(e, ctx.console)
- await printStack(ctx, stacks, nearest, async(s, pos) => {
+ await printStack(ctx, stacks, nearest, async (s, pos) => {
if (s === nearest && nearest) {
const sourceCode = await fs.readFile(fileFromParsedStack(nearest), 'utf-8')
ctx.log(c.yellow(generateCodeFrame(sourceCode, 4, pos)))
diff --git a/packages/vitest/src/node/pool.ts b/packages/vitest/src/node/pool.ts
index dd5f4a942..191b4f753 100644
--- a/packages/vitest/src/node/pool.ts
+++ b/packages/vitest/src/node/pool.ts
@@ -29,7 +29,7 @@ const workerPath = pathToFileURL(resolve(distDir, './worker.js')).href
export function createFakePool(ctx: Vitest): WorkerPool {
const runWithFiles = (name: 'run' | 'collect'): RunWithFiles => {
- return async(files, invalidates) => {
+ return async (files, invalidates) => {
const worker = await import(workerPath)
const { workerPort, port } = createChannel(ctx)
@@ -52,7 +52,7 @@ export function createFakePool(ctx: Vitest): WorkerPool {
return {
runTests: runWithFiles('run'),
collectTests: runWithFiles('collect'),
- close: async() => {},
+ close: async () => {},
}
}
@@ -78,9 +78,9 @@ export function createWorkerPool(ctx: Vitest): WorkerPool {
const pool = new Tinypool(options)
const runWithFiles = (name: string): RunWithFiles => {
- return async(files, invalidates) => {
+ return async (files, invalidates) => {
let id = 0
- await Promise.all(files.map(async(file) => {
+ await Promise.all(files.map(async (file) => {
const { workerPort, port } = createChannel(ctx)
const data: WorkerContext = {
@@ -101,7 +101,7 @@ export function createWorkerPool(ctx: Vitest): WorkerPool {
return {
runTests: runWithFiles('run'),
collectTests: runWithFiles('collect'),
- close: async() => {}, // TODO: not sure why this will cause Node crash: pool.destroy(),
+ close: async () => {}, // TODO: not sure why this will cause Node crash: pool.destroy(),
}
}
diff --git a/packages/vitest/src/node/reporters/base.ts b/packages/vitest/src/node/reporters/base.ts
index 447d00c92..a52233377 100644
--- a/packages/vitest/src/node/reporters/base.ts
+++ b/packages/vitest/src/node/reporters/base.ts
@@ -207,7 +207,7 @@ export abstract class BaseReporter implements Reporter {
}
registerUnhandledRejection() {
- process.on('unhandledRejection', async(err) => {
+ process.on('unhandledRejection', async (err) => {
process.exitCode = 1
this.ctx.error(`\n${c.red(divider(c.bold(c.inverse(' Unhandled Rejection '))))}`)
await this.ctx.printError(err)
diff --git a/packages/vitest/src/node/reporters/junit.ts b/packages/vitest/src/node/reporters/junit.ts
index 681b4dfef..df3f8d523 100644
--- a/packages/vitest/src/node/reporters/junit.ts
+++ b/packages/vitest/src/node/reporters/junit.ts
@@ -82,10 +82,10 @@ export class JUnitReporter implements Reporter {
const fileFd = await fs.open(this.reportFile, 'w+')
- this.baseLog = async(text: string) => await fs.writeFile(fileFd, `${text}\n`)
+ this.baseLog = async (text: string) => await fs.writeFile(fileFd, `${text}\n`)
}
else {
- this.baseLog = async(text: string) => this.ctx.log(text)
+ this.baseLog = async (text: string) => this.ctx.log(text)
}
this.logger = new IndentedLogger(this.baseLog)
@@ -138,7 +138,7 @@ export class JUnitReporter implements Reporter {
if (logs.length === 0)
return
- await this.writeElement(`system-${type}`, {}, async() => {
+ await this.writeElement(`system-${type}`, {}, async () => {
for (const log of logs)
await this.baseLog(escapeXML(log.content))
})
@@ -150,7 +150,7 @@ export class JUnitReporter implements Reporter {
classname: filename,
name: task.name,
time: getDuration(task),
- }, async() => {
+ }, async () => {
await this.writeLogs(task, 'out')
await this.writeLogs(task, 'err')
@@ -163,7 +163,7 @@ export class JUnitReporter implements Reporter {
await this.writeElement('failure', {
message: error?.message,
type: error?.name ?? error?.nameStr,
- }, async() => {
+ }, async () => {
if (!error)
return
@@ -201,7 +201,7 @@ export class JUnitReporter implements Reporter {
}
})
- await this.writeElement('testsuites', {}, async() => {
+ await this.writeElement('testsuites', {}, async () => {
for (const file of transformed) {
await this.writeElement('testsuite', {
name: file.name,
@@ -212,7 +212,7 @@ export class JUnitReporter implements Reporter {
errors: 0, // An errored test is one that had an unanticipated problem. We cannot detect those.
skipped: file.stats.skipped,
time: getDuration(file),
- }, async() => {
+ }, async () => {
await this.writeTasks(file.tasks, file.name)
})
}
diff --git a/packages/vitest/src/runtime/chain.ts b/packages/vitest/src/runtime/chain.ts
index 8067ac971..b47b1eea1 100644
--- a/packages/vitest/src/runtime/chain.ts
+++ b/packages/vitest/src/runtime/chain.ts
@@ -9,7 +9,7 @@ export function createChainable(
fn: (this: Record, ...args: Args) => R,
): ChainableFunction {
function create(obj: Record) {
- const chain = function(this: any, ...args: Args) {
+ const chain = function (this: any, ...args: Args) {
return fn.apply(obj, args)
}
for (const key of keys) {
diff --git a/packages/vitest/src/runtime/entry.ts b/packages/vitest/src/runtime/entry.ts
index 87c0cf238..2f837a58c 100644
--- a/packages/vitest/src/runtime/entry.ts
+++ b/packages/vitest/src/runtime/entry.ts
@@ -22,7 +22,7 @@ export async function run(files: string[], config: ResolvedConfig): Promise {
+ await withEnv(env as BuiltinEnvironment, config.environmentOptions || {}, async () => {
await startTests([file], config)
})
diff --git a/packages/vitest/src/runtime/mocker.ts b/packages/vitest/src/runtime/mocker.ts
index 43194aea2..ab9933f0e 100644
--- a/packages/vitest/src/runtime/mocker.ts
+++ b/packages/vitest/src/runtime/mocker.ts
@@ -87,7 +87,7 @@ export class VitestMocker {
}
private async resolveMocks() {
- await Promise.all(VitestMocker.pendingIds.map(async(mock) => {
+ await Promise.all(VitestMocker.pendingIds.map(async (mock) => {
const { path, external } = await this.resolvePath(mock.id, mock.importer)
if (mock.type === 'unmock')
this.unmockPath(path)
diff --git a/packages/vitest/src/runtime/setup.ts b/packages/vitest/src/runtime/setup.ts
index 8de40ca32..c63d933e5 100644
--- a/packages/vitest/src/runtime/setup.ts
+++ b/packages/vitest/src/runtime/setup.ts
@@ -157,7 +157,7 @@ export async function withEnv(
export async function runSetupFiles(config: ResolvedConfig) {
const files = toArray(config.setupFiles)
await Promise.all(
- files.map(async(file) => {
+ files.map(async (file) => {
getWorkerState().moduleCache.delete(file)
await import(file)
}),
diff --git a/packages/vitest/src/runtime/suite.ts b/packages/vitest/src/runtime/suite.ts
index 835d4bebb..be07a9697 100644
--- a/packages/vitest/src/runtime/suite.ts
+++ b/packages/vitest/src/runtime/suite.ts
@@ -8,7 +8,7 @@ import { getHooks, setFn, setHooks } from './map'
// apis
export const suite = createSuite()
export const test = createTest(
- function(name: string, fn?: TestFunction, timeout?: number) {
+ function (name: string, fn?: TestFunction, timeout?: number) {
// @ts-expect-error untyped internal prop
getCurrentSuite().test.fn.call(this, name, fn, timeout)
},
@@ -67,7 +67,7 @@ function createSuiteCollector(name: string, factory: SuiteFactory = () => { }, m
initSuite()
- const test = createTest(function(name: string, fn?: TestFunction, timeout?: number) {
+ const test = createTest(function (name: string, fn?: TestFunction, timeout?: number) {
const mode = this.only ? 'only' : this.skip ? 'skip' : this.todo ? 'todo' : 'run'
const test: Test = {
@@ -146,7 +146,7 @@ function createSuiteCollector(name: string, factory: SuiteFactory = () => { }, m
function createSuite() {
const suite = createChainable(
['concurrent', 'skip', 'only', 'todo'],
- function(name: string, factory?: SuiteFactory) {
+ function (name: string, factory?: SuiteFactory) {
const mode = this.only ? 'only' : this.skip ? 'skip' : this.todo ? 'todo' : 'run'
return createSuiteCollector(name, factory, mode, this.concurrent)
},
diff --git a/scripts/update-examples.ts b/scripts/update-examples.ts
index 6551e8de9..7436a07d6 100644
--- a/scripts/update-examples.ts
+++ b/scripts/update-examples.ts
@@ -13,7 +13,7 @@ async function run() {
const examples = await fg('*/package.json', { cwd: examplesRoot, absolute: true })
- const data = await Promise.all(examples.sort().map(async(pkgPath) => {
+ const data = await Promise.all(examples.sort().map(async (pkgPath) => {
const path = dirname(pkgPath)
const name = basename(path)
if ((await fs.lstat(path)).isFile())
diff --git a/test/core/test/basic.test.ts b/test/core/test/basic.test.ts
index 59662e744..577e7a9fa 100644
--- a/test/core/test/basic.test.ts
+++ b/test/core/test/basic.test.ts
@@ -2,7 +2,7 @@ import { assert, expect, it, suite, test } from 'vitest'
import { two } from '../src/submodule'
import { timeout } from '../src/timeout'
-test('Math.sqrt()', async() => {
+test('Math.sqrt()', async () => {
assert.equal(Math.sqrt(4), two)
assert.equal(Math.sqrt(2), Math.SQRT2)
expect(Math.sqrt(144)).toStrictEqual(12)
@@ -44,7 +44,7 @@ hi.test('expect truthy', () => {
})
// Remove .skip to test async fail by timeout
-test.skip('async with timeout', async() => {
+test.skip('async with timeout', async () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve()
diff --git a/test/core/test/chainable.test.ts b/test/core/test/chainable.test.ts
index 5542313d7..ac7148f7b 100644
--- a/test/core/test/chainable.test.ts
+++ b/test/core/test/chainable.test.ts
@@ -3,7 +3,7 @@ import { createChainable } from '../../../packages/vitest/src/runtime/chain'
describe('chainable', () => {
it('creates', () => {
- const chain = createChainable(['a', 'b'], function() {
+ const chain = createChainable(['a', 'b'], function () {
return this
})
diff --git a/test/core/test/each.test.ts b/test/core/test/each.test.ts
index 677962d4e..b9a44f87a 100644
--- a/test/core/test/each.test.ts
+++ b/test/core/test/each.test.ts
@@ -87,7 +87,7 @@ test.each([
test.each([
[1, 2, 3],
[4, 5, 9],
-])('return a promise like result %#', async(a, b, expected) => {
+])('return a promise like result %#', async (a, b, expected) => {
const promiseResolver = (first: number, second: number) => {
return new Promise((resolve) => {
setTimeout(() => resolve(first + second), 1)
diff --git a/test/core/test/execution-order.test.ts b/test/core/test/execution-order.test.ts
index 822d58b02..1f0b1b2f6 100644
--- a/test/core/test/execution-order.test.ts
+++ b/test/core/test/execution-order.test.ts
@@ -20,7 +20,7 @@ it('one', () => {
expect(v).toBe(1)
})
-it('two', async() => {
+it('two', async () => {
expect(v).toBe(1)
await bump()
expect(v).toBe(2)
@@ -32,7 +32,7 @@ describe('suite', () => {
expect(v).toBe(3)
})
- it('four', async() => {
+ it('four', async () => {
expect(v).toBe(3)
await bump()
expect(v).toBe(4)
diff --git a/test/core/test/fs.test.ts b/test/core/test/fs.test.ts
index c84ff856d..b6a8b3b6f 100644
--- a/test/core/test/fs.test.ts
+++ b/test/core/test/fs.test.ts
@@ -8,19 +8,19 @@ const content = 'Hello, World!'
const filename = 'fixtures/hi.txt'
describe('fs', () => {
- it('__dirname', async() => {
+ it('__dirname', async () => {
const raw = await fs.readFile(resolve(__dirname, filename), 'utf-8')
expect(raw.trim()).toEqual(content)
})
- it('__filename', async() => {
+ it('__filename', async () => {
const raw = await fs.readFile(resolve(__filename, '..', filename), 'utf-8')
expect(raw.trim()).toEqual(content)
})
- it('import.meta.url', async() => {
+ it('import.meta.url', async () => {
const raw = await fs.readFile(resolve(fileURLToPath(import.meta.url), '..', filename), 'utf-8')
expect(raw.trim()).toEqual(content)
diff --git a/test/core/test/hooks.test.js b/test/core/test/hooks.test.js
index 175ae230a..bb2780033 100644
--- a/test/core/test/hooks.test.js
+++ b/test/core/test/hooks.test.js
@@ -23,12 +23,12 @@ describe('before and after hooks', () => {
})
// Hooks accepting a timeout
- beforeAll(async() => { }, 1000)
- afterAll(async() => { }, 1000)
- beforeEach(async() => { }, 1000)
- afterEach(async() => { }, 1000)
+ beforeAll(async () => { }, 1000)
+ afterAll(async () => { }, 1000)
+ beforeEach(async () => { }, 1000)
+ afterEach(async () => { }, 1000)
- beforeAll(async() => {
+ beforeAll(async () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve()
diff --git a/test/core/test/imports.test.ts b/test/core/test/imports.test.ts
index 51137f509..389e0d869 100644
--- a/test/core/test/imports.test.ts
+++ b/test/core/test/imports.test.ts
@@ -1,7 +1,7 @@
import { expect, test } from 'vitest'
import { dynamicRelativeImport } from '../src/relative-import'
-test('dynamic relative import works', async() => {
+test('dynamic relative import works', async () => {
const stringTimeoutMod = await import('./../src/timeout')
const timeoutPath = './../src/timeout'
@@ -10,14 +10,14 @@ test('dynamic relative import works', async() => {
expect(stringTimeoutMod).toBe(variableTimeoutMod)
})
-test('Relative imports in imported modules work', async() => {
+test('Relative imports in imported modules work', async () => {
const relativeImportFromFile = await dynamicRelativeImport('timeout')
const directImport = await import('./../src/timeout')
expect(relativeImportFromFile).toBe(directImport)
})
-test('dynamic aliased import works', async() => {
+test('dynamic aliased import works', async () => {
const stringTimeoutMod = await import('./../src/timeout')
const timeoutPath = '@/timeout'
@@ -26,7 +26,7 @@ test('dynamic aliased import works', async() => {
expect(stringTimeoutMod).toBe(variableTimeoutMod)
})
-test('dynamic absolute import works', async() => {
+test('dynamic absolute import works', async () => {
const stringTimeoutMod = await import('./../src/timeout')
const timeoutPath = '/src/timeout'
@@ -35,20 +35,20 @@ test('dynamic absolute import works', async() => {
expect(stringTimeoutMod).toBe(variableTimeoutMod)
})
-test('data with dynamic import works', async() => {
+test('data with dynamic import works', async () => {
const dataUri = 'data:text/javascript;charset=utf-8,export default "hi"'
const { default: hi } = await import(dataUri)
expect(hi).toBe('hi')
})
-test('dynamic import has Module symbol', async() => {
+test('dynamic import has Module symbol', async () => {
const stringTimeoutMod = await import('./../src/timeout')
// @ts-expect-error The symbol won't exist on the import type
expect(stringTimeoutMod[Symbol.toStringTag]).toBe('Module')
})
-test('dynamic import has null prototype', async() => {
+test('dynamic import has null prototype', async () => {
const stringTimeoutMod = await import('./../src/timeout')
expect(Object.getPrototypeOf(stringTimeoutMod)).toBe(null)
diff --git a/test/core/test/inline-snap.test.ts b/test/core/test/inline-snap.test.ts
index 59985d788..f46188c33 100644
--- a/test/core/test/inline-snap.test.ts
+++ b/test/core/test/inline-snap.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'
import { replaceInlineSnap } from '../../../packages/vitest/src/integrations/snapshot/port/inlineSnapshot'
describe('inline-snap utils', () => {
- it('replaceInlineSnap', async() => {
+ it('replaceInlineSnap', async () => {
const code = `
expect('foo').toMatchInlineSnapshot('"foo"')
expect('foo').toMatchInlineSnapshot(\`{
@@ -24,7 +24,7 @@ expect('foo').toMatchInlineSnapshot(\`{
`)
})
- it('replaceInlineSnap with indenetation', async() => {
+ it('replaceInlineSnap with indenetation', async () => {
const indent = ' '
const code = `
${indent}expect('foo').toMatchInlineSnapshot('"foo"')
diff --git a/test/core/test/jest-expect.test.ts b/test/core/test/jest-expect.test.ts
index a4ac77509..2669a4440 100644
--- a/test/core/test/jest-expect.test.ts
+++ b/test/core/test/jest-expect.test.ts
@@ -218,7 +218,7 @@ describe('jest-expect', () => {
expect(1).toBe(1)
})
- it('assertions when asynchronous code', async() => {
+ it('assertions when asynchronous code', async () => {
expect.assertions(3)
await Promise.all([
expect(1).toBe(1),
@@ -227,7 +227,7 @@ describe('jest-expect', () => {
])
})
- it.fails('assertions when asynchronous code', async() => {
+ it.fails('assertions when asynchronous code', async () => {
// Error: expected number of assertions to be 2, but got 3
expect.assertions(2)
await Promise.all([
@@ -398,7 +398,7 @@ describe('toBeTypeOf()', () => {
[true, 'boolean'],
[false, 'boolean'],
[() => {}, 'function'],
- [function() {}, 'function'],
+ [function () {}, 'function'],
[1, 'number'],
[Infinity, 'number'],
[NaN, 'number'],
@@ -432,44 +432,44 @@ describe('toSatisfy()',() => {
})
describe('async expect', () => {
- it('resolves', async() => {
- await expect((async() => 'true')()).resolves.toBe('true')
- await expect((async() => 'true')()).resolves.not.toBe('true22')
+ it('resolves', async () => {
+ await expect((async () => 'true')()).resolves.toBe('true')
+ await expect((async () => 'true')()).resolves.not.toBe('true22')
})
- it.fails('failed to resolve', async() => {
- await expect((async() => {
+ it.fails('failed to resolve', async () => {
+ await expect((async () => {
throw new Error('err')
})()).resolves.toBe('true')
})
- it('rejects', async() => {
- await expect((async() => {
+ it('rejects', async () => {
+ await expect((async () => {
throw new Error('err')
})()).rejects.toStrictEqual(new Error('err'))
- await expect((async() => {
+ await expect((async () => {
throw new Error('err')
})()).rejects.toThrow('err')
- expect((async() => {
+ expect((async () => {
throw new TestError('error')
})()).rejects.toThrow(TestError)
const err = new Error('hello world')
- expect((async() => {
+ expect((async () => {
throw err
})()).rejects.toThrow(err)
- expect((async() => {
+ expect((async () => {
throw new Error('message')
})()).rejects.toThrow(expect.objectContaining({
message: expect.stringContaining('mes'),
}))
- await expect((async() => {
+ await expect((async () => {
throw new Error('err')
})()).rejects.not.toStrictEqual(new Error('fake err'))
})
- it.fails('failed to reject', async() => {
- await expect((async() => 'test')()).rejects.toBe('test')
+ it.fails('failed to reject', async () => {
+ await expect((async () => 'test')()).rejects.toBe('test')
})
})
diff --git a/test/core/test/jest-mock.test.ts b/test/core/test/jest-mock.test.ts
index e4b551d64..5cd044fd1 100644
--- a/test/core/test/jest-mock.test.ts
+++ b/test/core/test/jest-mock.test.ts
@@ -42,7 +42,7 @@ describe('jest mock compat layer', () => {
})
it('implementation sync fn', () => {
- const originalFn = function() {
+ const originalFn = function () {
return 'original'
}
const spy = vi.fn(originalFn)
@@ -102,8 +102,8 @@ describe('jest mock compat layer', () => {
expect(spy.mock.results).toEqual([])
})
- it('implementation async fn', async() => {
- const originalFn = async function() {
+ it('implementation async fn', async () => {
+ const originalFn = async function () {
return 'original'
}
const spy = vi.fn(originalFn)
@@ -170,7 +170,7 @@ describe('jest mock compat layer', () => {
it('getter function spyOn', () => {
const obj = {
get getter() {
- return function() { return 'original' }
+ return function () { return 'original' }
},
}
@@ -252,7 +252,7 @@ describe('jest mock compat layer', () => {
expect(obj.property).toBe(true)
})
- it('throwing', async() => {
+ it('throwing', async () => {
const fn = vi.fn(() => {
// eslint-disable-next-line no-throw-literal
throw 'error'
@@ -268,8 +268,8 @@ describe('jest mock compat layer', () => {
])
})
- it('mockRejectedValue', async() => {
- const safeCall = async(fn: () => void) => {
+ it('mockRejectedValue', async () => {
+ const safeCall = async (fn: () => void) => {
try {
await fn()
}
@@ -286,7 +286,7 @@ describe('jest mock compat layer', () => {
expect(spy.mock.results[0]).toEqual(e(new Error('once')))
expect(spy.mock.results[1]).toEqual(e(new Error('error')))
})
- it('mockResolvedValue', async() => {
+ it('mockResolvedValue', async () => {
const spy = vi.fn()
.mockResolvedValue('resolved')
.mockResolvedValueOnce('once')
diff --git a/test/core/test/modes.test.ts b/test/core/test/modes.test.ts
index 4288a163a..553ba038b 100644
--- a/test/core/test/modes.test.ts
+++ b/test/core/test/modes.test.ts
@@ -22,7 +22,7 @@ const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))
describe('concurrent tests', () => {
let count = 0
- const counterTest = (c: number) => async() => {
+ const counterTest = (c: number) => async () => {
assert.equal(count, c)
await delay(20)
count++
@@ -50,7 +50,7 @@ describe('concurrent tests', () => {
describe.concurrent('concurrent suite', () => {
let count = 0
- const counterTest = (c: number) => async() => {
+ const counterTest = (c: number) => async () => {
assert.equal(count, c)
await delay(20)
count++
diff --git a/test/core/test/snapshot-inline.test.ts b/test/core/test/snapshot-inline.test.ts
index 6d043a001..5c357d9c3 100644
--- a/test/core/test/snapshot-inline.test.ts
+++ b/test/core/test/snapshot-inline.test.ts
@@ -107,13 +107,13 @@ test('literal tag', () => {
`)
})
-test('resolves', async() => {
- const getText = async() => 'text'
+test('resolves', async () => {
+ const getText = async () => 'text'
await expect(getText()).resolves.toMatchInlineSnapshot('"text"')
})
-test('rejects', async() => {
- const getText = async() => {
+test('rejects', async () => {
+ const getText = async () => {
throw new Error('error')
}
await expect(getText()).rejects.toMatchInlineSnapshot('[Error: error]')
diff --git a/test/core/test/spy.test.ts b/test/core/test/spy.test.ts
index 08b0089b6..140cbd1ee 100644
--- a/test/core/test/spy.test.ts
+++ b/test/core/test/spy.test.ts
@@ -5,7 +5,7 @@ import { describe, expect, test, vi } from 'vitest'
*/
describe('spyOn', () => {
- test('correctly infers method types', async() => {
+ test('correctly infers method types', async () => {
vi.spyOn(localStorage, 'getItem').mockReturnValue('world')
expect(window.localStorage.getItem('hello')).toEqual('world')
})
diff --git a/test/core/test/vi.spec.ts b/test/core/test/vi.spec.ts
index 63406c3f6..2bb4f7465 100644
--- a/test/core/test/vi.spec.ts
+++ b/test/core/test/vi.spec.ts
@@ -13,7 +13,7 @@ describe('testing vi utils', () => {
expect(IntersectionObserver).toBe(IntersectionObserverMock)
})
- test('reseting modules', async() => {
+ test('reseting modules', async () => {
const mod1 = await import('../src/env')
vi.resetModules()
const mod2 = await import('../src/env')
@@ -22,7 +22,7 @@ describe('testing vi utils', () => {
expect(mod2).toBe(mod3)
})
- test('reseting modules doesnt reset vitest', async() => {
+ test('reseting modules doesnt reset vitest', async () => {
const v1 = await import('vitest')
vi.resetModules()
const v2 = await import('vitest')
diff --git a/test/coverage-test/coverage-test/coverage.test.ts b/test/coverage-test/coverage-test/coverage.test.ts
index 5ccaa59f8..1cf396507 100644
--- a/test/coverage-test/coverage-test/coverage.test.ts
+++ b/test/coverage-test/coverage-test/coverage.test.ts
@@ -2,7 +2,7 @@ import fs from 'fs'
import { resolve } from 'pathe'
import { expect, test } from 'vitest'
-test('coverage', async() => {
+test('coverage', async () => {
const coveragePath = resolve('./coverage/tmp/')
const stat = fs.statSync(coveragePath)
expect(stat.isDirectory()).toBe(true)
diff --git a/test/coverage-test/test/coverage.test.ts b/test/coverage-test/test/coverage.test.ts
index c210f2e8f..3fc0c95b2 100644
--- a/test/coverage-test/test/coverage.test.ts
+++ b/test/coverage-test/test/coverage.test.ts
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest'
import { pythagoras } from '../src'
-test('Math.sqrt()', async() => {
+test('Math.sqrt()', async () => {
expect(pythagoras(3, 4)).toBe(5)
})
diff --git a/test/coverage-test/test/vue.test.ts b/test/coverage-test/test/vue.test.ts
index 521f4bfb5..1dd265ca6 100644
--- a/test/coverage-test/test/vue.test.ts
+++ b/test/coverage-test/test/vue.test.ts
@@ -7,7 +7,7 @@ import { mount } from '@vue/test-utils'
import Hello from '../src/Hello.vue'
import Defined from '../src/Defined.vue'
-test('vue 3 coverage', async() => {
+test('vue 3 coverage', async () => {
expect(Hello).toBeTruthy()
const wrapper = mount(Hello, {
diff --git a/test/fails/fixtures/hook-timeout.test.ts b/test/fails/fixtures/hook-timeout.test.ts
index 25bfbc8f8..c9fdb8c1d 100644
--- a/test/fails/fixtures/hook-timeout.test.ts
+++ b/test/fails/fixtures/hook-timeout.test.ts
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it } from 'vitest'
describe('hooks should timeout', () => {
- beforeEach(async() => {
+ beforeEach(async () => {
await new Promise(resolve => setTimeout(resolve, 20))
}, 10)
it('hello', () => {
diff --git a/test/fails/fixtures/timeout.test.ts b/test/fails/fixtures/timeout.test.ts
index c65c04a4c..e01540952 100644
--- a/test/fails/fixtures/timeout.test.ts
+++ b/test/fails/fixtures/timeout.test.ts
@@ -1,5 +1,5 @@
import { test } from 'vitest'
-test('hi', async() => {
+test('hi', async () => {
await new Promise(resolve => setTimeout(resolve, 20))
}, 10)
diff --git a/test/fails/test/runner.test.ts b/test/fails/test/runner.test.ts
index 503e53ca0..98d00de30 100644
--- a/test/fails/test/runner.test.ts
+++ b/test/fails/test/runner.test.ts
@@ -3,12 +3,12 @@ import fg from 'fast-glob'
import { execa } from 'execa'
import { describe, expect, it } from 'vitest'
-describe('should fails', async() => {
+describe('should fails', async () => {
const root = resolve(__dirname, '../fixtures')
const files = await fg('*.test.ts', { cwd: root })
for (const file of files) {
- it(file, async() => {
+ it(file, async () => {
// in Windows child_process is very unstable, we skip testing it
if (process.platform === 'win32' && process.env.CI)
return
diff --git a/test/global-setup-fail/fixtures/globalSetup/error.js b/test/global-setup-fail/fixtures/globalSetup/error.js
index b5d6c0aed..cd07c86ea 100644
--- a/test/global-setup-fail/fixtures/globalSetup/error.js
+++ b/test/global-setup-fail/fixtures/globalSetup/error.js
@@ -1,3 +1,3 @@
-export default function() {
+export default function () {
throw new Error('error')
}
diff --git a/test/global-setup-fail/test/runner.test.ts b/test/global-setup-fail/test/runner.test.ts
index e85e4f54a..b2c8f4b43 100644
--- a/test/global-setup-fail/test/runner.test.ts
+++ b/test/global-setup-fail/test/runner.test.ts
@@ -2,7 +2,7 @@ import { resolve } from 'pathe'
import { execa } from 'execa'
import { expect, it } from 'vitest'
-it('should fail', async() => {
+it('should fail', async () => {
// in Windows child_process is very unstable, we skip testing it
if (process.platform === 'win32' && process.env.CI)
return
diff --git a/test/global-setup/globalSetup/another-vite-instance.ts b/test/global-setup/globalSetup/another-vite-instance.ts
index a15211dc9..74522166f 100644
--- a/test/global-setup/globalSetup/another-vite-instance.ts
+++ b/test/global-setup/globalSetup/another-vite-instance.ts
@@ -10,7 +10,7 @@ export async function setup() {
})
await server.listen(9988)
- return async() => {
+ return async () => {
await server.close()
}
}
diff --git a/test/global-setup/globalSetup/default-export.js b/test/global-setup/globalSetup/default-export.js
index 317883aea..08a7f650c 100644
--- a/test/global-setup/globalSetup/default-export.js
+++ b/test/global-setup/globalSetup/default-export.js
@@ -1,13 +1,13 @@
const sleep = async n => new Promise(resolve => setTimeout(resolve, n))
-export default async function() {
+export default async function () {
// setup something eg start a server, db or whatever
// const server = await start()
// console.log('globalSetup default-export.js')
// const start = Date.now()
await sleep(25)
- return async() => {
+ return async () => {
// tear it down here
// await server.close()
await sleep(25)
diff --git a/test/global-setup/globalSetup/ts-with-imports.ts b/test/global-setup/globalSetup/ts-with-imports.ts
index 0399dcfb9..5e061b6fc 100644
--- a/test/global-setup/globalSetup/ts-with-imports.ts
+++ b/test/global-setup/globalSetup/ts-with-imports.ts
@@ -1,6 +1,6 @@
import { startServer } from './server'
-export default async function() {
+export default async function () {
const server = await startServer('127.0.0.1', 9876)
- return async() => new Promise(resolve => server.close(() => resolve()))
+ return async () => new Promise(resolve => server.close(() => resolve()))
}
diff --git a/test/global-setup/setupFiles/add-something-to-global.ts b/test/global-setup/setupFiles/add-something-to-global.ts
index 011dff2b7..540094fda 100644
--- a/test/global-setup/setupFiles/add-something-to-global.ts
+++ b/test/global-setup/setupFiles/add-something-to-global.ts
@@ -5,7 +5,7 @@ beforeAll(() => {
global.something = 'something'
})
-beforeAll(async() => {
+beforeAll(async () => {
await new Promise((resolve) => {
setTimeout(() => {
resolve(null)
@@ -13,7 +13,7 @@ beforeAll(async() => {
})
})
-beforeEach(async() => {
+beforeEach(async () => {
await new Promise((resolve) => {
setTimeout(() => {
resolve(null)
@@ -26,7 +26,7 @@ afterAll(() => {
delete global.something
})
-afterAll(async() => {
+afterAll(async () => {
await new Promise((resolve) => {
setTimeout(() => {
resolve(null)
diff --git a/test/global-setup/test/global-setup.test.ts b/test/global-setup/test/global-setup.test.ts
index f7d0df084..59f05f2e4 100644
--- a/test/global-setup/test/global-setup.test.ts
+++ b/test/global-setup/test/global-setup.test.ts
@@ -1,7 +1,7 @@
import fetch from 'node-fetch'
import { expect } from 'vitest'
-beforeEach(async() => {
+beforeEach(async () => {
await new Promise((resolve) => {
setTimeout(() => {
resolve(null)
@@ -9,7 +9,7 @@ beforeEach(async() => {
})
})
-afterEach(async() => {
+afterEach(async () => {
await new Promise((resolve) => {
setTimeout(() => {
resolve(null)
@@ -17,12 +17,12 @@ afterEach(async() => {
})
})
-test('server running', async() => {
+test('server running', async () => {
const res = await (await fetch('http://localhost:9876')).text()
expect(res).toBe('Hello Vitest\n')
})
-test('vite instance running', async() => {
+test('vite instance running', async () => {
const res = await (await fetch('http://localhost:9988')).text()
expect(res).toContain('