[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

chore: apply lint

Anthony Fu (Apr 3, 2022, 4:35 PM +0800) db824cf4 4cc2a294

+134 -115
+3 -3
package.json
··· 1 1 { 2 2 "name": "@vitest/monorepo", 3 + "type": "module", 3 4 "version": "0.8.4", 4 5 "private": true, 5 - "description": "A blazing fast unit test framework powered by Vite", 6 - "type": "module", 7 6 "packageManager": "pnpm@6.32.3", 7 + "description": "A blazing fast unit test framework powered by Vite", 8 8 "scripts": { 9 9 "build": "pnpm -r --filter {packages} run build", 10 10 "ci": "ni && nr typecheck && nr lint && nr build && nr test:all", ··· 16 16 "docs:examples": "esmo scripts/update-examples.ts", 17 17 "docs:contributors": "esmo scripts/update-contributors.ts", 18 18 "postinstall": "pnpm -C examples/vue2 i", 19 - "lint": "eslint --ext .", 19 + "lint": "eslint .", 20 20 "lint:fix": "nr lint --fix", 21 21 "release": "bumpp package.json packages/*/package.json --commit --push --tag && pnpm -r publish --access public", 22 22 "test": "vitest --api -r test/core",
+1 -1
.github/renovate.json5
··· 13 13 "enabled": false 14 14 }, 15 15 { 16 - "packageNames": ["node"], 16 + "packageNames": ["node"], 17 17 "enabled": false 18 18 } 19 19 ],
+1 -1
bench/package.json
··· 1 1 { 2 - "private": true, 3 2 "type": "module", 3 + "private": true, 4 4 "scripts": { 5 5 "bench": "esmo src/index.ts", 6 6 "bench:ci": "esmo src/github.ts"
+1 -1
.github/ISSUE_TEMPLATE/bug_report.yml
··· 1 - name: "\U0001F41E Bug report" 1 + name: 🐞 Bug report 2 2 description: Report an issue with Vitest 3 3 labels: [pending triage] 4 4 body:
+4 -4
.github/ISSUE_TEMPLATE/feature_request.yml
··· 1 - name: "\U0001F680 New feature proposal" 1 + name: 🚀 New feature proposal 2 2 description: Propose a new feature to be added to Vite 3 - labels: ["enhancement: pending triage"] 3 + labels: ['enhancement: pending triage'] 4 4 body: 5 5 - type: markdown 6 6 attributes: ··· 10 10 id: feature-description 11 11 attributes: 12 12 label: Clear and concise description of the problem 13 - description: "As a developer using Vitest I want [goal / wish] so that [benefit]. If you intend to submit a PR for this issue, tell us in the description. Thanks!" 13 + description: 'As a developer using Vitest I want [goal / wish] so that [benefit]. If you intend to submit a PR for this issue, tell us in the description. Thanks!' 14 14 validations: 15 15 required: true 16 16 - type: textarea 17 17 id: suggested-solution 18 18 attributes: 19 19 label: Suggested solution 20 - description: "We could provide following implementation..." 20 + description: We could provide following implementation... 21 21 validations: 22 22 required: true 23 23 - type: textarea
+2 -2
.github/workflows/bench.yml
··· 3 3 on: 4 4 issue_comment: 5 5 types: 6 - - created 6 + - created 7 7 8 8 jobs: 9 9 bench: ··· 19 19 - name: Install node 20 20 uses: actions/setup-node@v3 21 21 with: 22 - cache: "pnpm" 22 + cache: pnpm 23 23 24 24 - name: Install 25 25 working-directory: ./bench
+5 -5
.github/workflows/ci.yml
··· 22 22 uses: actions/setup-node@v3 23 23 with: 24 24 node-version: 16.x 25 - cache: "pnpm" 25 + cache: pnpm 26 26 27 27 - name: Install 28 28 run: pnpm i ··· 42 42 uses: actions/setup-node@v3 43 43 with: 44 44 node-version: 16.x 45 - cache: "pnpm" 45 + cache: pnpm 46 46 47 47 - name: Install 48 48 run: pnpm i ··· 61 61 strategy: 62 62 matrix: 63 63 node_version: [14.x, 16.x] 64 - os: [ubuntu-latest, windows-latest] #, macos-latest] 64 + os: [ubuntu-latest, windows-latest] # , macos-latest] 65 65 fail-fast: false 66 66 67 67 steps: ··· 74 74 uses: actions/setup-node@v3 75 75 with: 76 76 node-version: ${{ matrix.node_version }} 77 - cache: "pnpm" 77 + cache: pnpm 78 78 79 79 - name: Install 80 80 run: pnpm i ··· 97 97 uses: actions/setup-node@v3 98 98 with: 99 99 node-version: 16.x 100 - cache: "pnpm" 100 + cache: pnpm 101 101 102 102 - name: Install 103 103 run: pnpm i
+2 -2
.github/workflows/release.yml
··· 20 20 uses: actions/setup-node@v3 21 21 with: 22 22 node-version: 16 23 - cache: "pnpm" 23 + cache: pnpm 24 24 25 25 # - run: pnpm i -g @antfu/ni 26 26 # - run: nci ··· 28 28 # - run: npm publish --access public 29 29 # env: 30 30 # NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 31 - 31 + 32 32 - run: npx conventional-github-releaser -p angular 33 33 env: 34 34 CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}}
+2 -1
docs/api/index.md
··· 409 409 import { expect, test } from 'vitest' 410 410 411 411 function getApplesFromStock(stock) { 412 - if (stock === 'Bill') return 13 412 + if (stock === 'Bill') 413 + return 13 413 414 } 414 415 415 416 test('mary doesn\'t have a stock', () => {
+1 -1
examples/basic/package.json
··· 1 1 { 2 2 "name": "vitest-test", 3 + "type": "module", 3 4 "private": true, 4 5 "license": "MIT", 5 - "type": "module", 6 6 "main": "index.js", 7 7 "scripts": { 8 8 "test": "vitest",
+1 -1
examples/ruby/package.json
··· 1 1 { 2 2 "name": "vitest-test", 3 + "type": "module", 3 4 "private": true, 4 5 "license": "MIT", 5 - "type": "module", 6 6 "main": "index.js", 7 7 "scripts": { 8 8 "test": "vitest",
+1 -1
examples/svelte/package.json
··· 1 1 { 2 2 "name": "@vitest/test-svelte", 3 - "private": true, 4 3 "type": "module", 4 + "private": true, 5 5 "scripts": { 6 6 "test": "vitest", 7 7 "test:ui": "vitest --ui",
+8 -8
packages/ui/package.json
··· 1 1 { 2 2 "name": "@vitest/ui", 3 + "type": "module", 3 4 "version": "0.8.4", 4 5 "description": "UI for Vitest", 5 - "sideEffects": false, 6 6 "repository": { 7 7 "type": "git", 8 8 "url": "git+https://github.com/vitest-dev/vitest.git", 9 9 "directory": "packages/ui" 10 10 }, 11 - "type": "module", 12 - "files": [ 13 - "dist" 14 - ], 11 + "main": "./dist/index.js", 12 + "module": "./dist/index.js", 13 + "types": "./dist/index.d.ts", 15 14 "exports": { 16 15 ".": { 17 16 "import": "./dist/index.js", ··· 19 18 }, 20 19 "./*": "./*" 21 20 }, 22 - "main": "./dist/index.js", 23 - "module": "./dist/index.js", 24 - "types": "./dist/index.d.ts", 21 + "files": [ 22 + "dist" 23 + ], 24 + "sideEffects": false, 25 25 "scripts": { 26 26 "build": "rimraf dist && pnpm build:node && pnpm build:client", 27 27 "build:client": "vite build",
+10 -10
packages/vite-node/package.json
··· 1 1 { 2 2 "name": "vite-node", 3 + "type": "module", 3 4 "version": "0.8.4", 4 5 "description": "Vite as Node.js runtime", 5 6 "homepage": "https://github.com/vitest-dev/vitest/blob/main/packages/vite-node#readme", ··· 7 8 "url": "https://github.com/vitest-dev/vitest/issues" 8 9 }, 9 10 "license": "MIT", 11 + "author": "Anthony Fu <anthonyfu117@hotmail.com>", 10 12 "repository": { 11 13 "type": "git", 12 14 "url": "git+https://github.com/vitest-dev/vitest.git", 13 15 "directory": "packages/vite-node" 14 16 }, 15 17 "funding": "https://github.com/sponsors/antfu", 16 - "author": "Anthony Fu <anthonyfu117@hotmail.com>", 17 - "type": "module", 18 - "files": [ 19 - "dist", 20 - "*.d.ts", 21 - "*.mjs" 22 - ], 18 + "main": "./dist/index.js", 19 + "module": "./dist/index.js", 20 + "types": "./dist/index.d.ts", 23 21 "exports": { 24 22 ".": { 25 23 "import": "./dist/index.js", ··· 42 40 "types": "./dist/utils.d.ts" 43 41 } 44 42 }, 45 - "main": "./dist/index.js", 46 - "module": "./dist/index.js", 47 - "types": "./dist/index.d.ts", 43 + "files": [ 44 + "dist", 45 + "*.d.ts", 46 + "*.mjs" 47 + ], 48 48 "bin": { 49 49 "vite-node": "./vite-node.mjs" 50 50 },
+11 -11
packages/vitest/package.json
··· 1 1 { 2 2 "name": "vitest", 3 + "type": "module", 3 4 "version": "0.8.4", 4 5 "description": "A blazing fast unit test framework powered by Vite", 5 6 "keywords": [ ··· 13 14 "url": "https://github.com/vitest-dev/vitest/issues" 14 15 }, 15 16 "license": "MIT", 17 + "author": "Anthony Fu <anthonyfu117@hotmail.com>", 16 18 "repository": { 17 19 "type": "git", 18 20 "url": "git+https://github.com/vitest-dev/vitest.git" 19 21 }, 20 22 "funding": "https://github.com/sponsors/antfu", 21 - "author": "Anthony Fu <anthonyfu117@hotmail.com>", 22 - "type": "module", 23 - "files": [ 24 - "dist", 25 - "bin", 26 - "*.d.ts", 27 - "*.mjs" 28 - ], 23 + "main": "./dist/index.js", 24 + "module": "./dist/index.js", 25 + "types": "./dist/index.d.ts", 29 26 "exports": { 30 27 ".": { 31 28 "import": "./dist/index.js", ··· 48 45 "types": "./config.d.ts" 49 46 } 50 47 }, 51 - "main": "./dist/index.js", 52 - "module": "./dist/index.js", 53 - "types": "./dist/index.d.ts", 48 + "files": [ 49 + "dist", 50 + "bin", 51 + "*.d.ts", 52 + "*.mjs" 53 + ], 54 54 "bin": { 55 55 "vitest": "./vitest.mjs" 56 56 },
+8 -8
packages/web-worker/package.json
··· 1 1 { 2 2 "name": "@vitest/web-worker", 3 + "type": "module", 3 4 "version": "0.8.4", 4 5 "description": "Web Worker support for testing in Vitest", 5 - "type": "module", 6 - "files": [ 7 - "dist", 8 - "*.d.ts" 9 - ], 6 + "main": "./dist/index.js", 7 + "module": "./dist/index.js", 8 + "types": "./index.d.ts", 10 9 "exports": { 11 10 ".": { 12 11 "import": "./dist/index.js", ··· 19 18 "types": "./pure.d.ts" 20 19 } 21 20 }, 22 - "main": "./dist/index.js", 23 - "module": "./dist/index.js", 21 + "files": [ 22 + "dist", 23 + "*.d.ts" 24 + ], 24 25 "scripts": { 25 26 "build": "rimraf dist && rollup -c", 26 27 "dev": "rollup -c --watch --watch.include=src/**", 27 28 "prepublishOnly": "nr build", 28 29 "typecheck": "tsc --noEmit" 29 30 }, 30 - "types": "./index.d.ts", 31 31 "peerDependencies": { 32 32 "vitest": "*" 33 33 },
+10 -10
packages/ws-client/package.json
··· 1 1 { 2 2 "name": "@vitest/ws-client", 3 + "type": "module", 3 4 "version": "0.8.4", 4 5 "description": "WebSocket client wrapper for communicating with Vitest", 5 6 "homepage": "https://github.com/vitest-dev/vitest#readme", ··· 7 8 "url": "https://github.com/vitest-dev/vitest/issues" 8 9 }, 9 10 "license": "MIT", 11 + "author": "Anthony Fu <anthonyfu117@hotmail.com>", 10 12 "repository": { 11 13 "type": "git", 12 14 "url": "git+https://github.com/vitest-dev/vitest.git" 13 15 }, 14 16 "funding": "https://github.com/sponsors/antfu", 15 - "author": "Anthony Fu <anthonyfu117@hotmail.com>", 16 - "type": "module", 17 - "files": [ 18 - "dist", 19 - "*.d.ts", 20 - "*.mjs" 21 - ], 17 + "main": "./dist/index.js", 18 + "module": "./dist/index.js", 19 + "types": "./dist/index.d.ts", 22 20 "exports": { 23 21 ".": { 24 22 "import": "./dist/index.js", 25 23 "types": "./dist/index.d.ts" 26 24 } 27 25 }, 28 - "main": "./dist/index.js", 29 - "module": "./dist/index.js", 30 - "types": "./dist/index.d.ts", 26 + "files": [ 27 + "dist", 28 + "*.d.ts", 29 + "*.mjs" 30 + ], 31 31 "scripts": { 32 32 "build": "rimraf dist && rollup -c", 33 33 "dev": "rollup -c --watch --watch.include=src/**",
+1 -1
test/global-setup-fail/package.json
··· 1 1 { 2 2 "name": "@vitest/test-global-setup-fail", 3 - "private": true, 4 3 "type": "module", 4 + "private": true, 5 5 "scripts": { 6 6 "test": "vitest" 7 7 },
+1 -1
test/global-setup/package.json
··· 1 1 { 2 2 "name": "@vitest/test-global-setup", 3 - "private": true, 4 3 "type": "module", 4 + "private": true, 5 5 "scripts": { 6 6 "test": "vitest", 7 7 "coverage": "vitest run --coverage"
+1 -1
test/web-worker/package.json
··· 1 1 { 2 2 "name": "@vitest/test-global-setup", 3 - "private": true, 4 3 "type": "module", 4 + "private": true, 5 5 "scripts": { 6 6 "test": "vitest", 7 7 "coverage": "vitest run --coverage"
-1
examples/react-testing-lib-msw/src/App.tsx
··· 1 - 2 1 import * as React from 'react' 3 2 import fetch from 'cross-fetch' 4 3 import { gql, useLazyQuery } from '@apollo/client'
+2 -1
packages/web-worker/src/pure.ts
··· 65 65 } 66 66 67 67 export function defineWebWorker() { 68 - if ('Worker' in globalThis) return 68 + if ('Worker' in globalThis) 69 + return 69 70 70 71 const { config, rpc, mockMap, moduleCache } = getWorkerState() 71 72
+20 -20
packages/ui/client/components/Modal.vue
··· 1 - <template> 2 - <div 3 - class="fixed inset-0 z-40" 4 - :class="modelValue ? '': 'pointer-events-none'" 5 - > 6 - <div 7 - class="bg-base inset-0 absolute transition-opacity duration-500 ease-out" 8 - :class="modelValue ? 'opacity-50': 'opacity-0'" 9 - @click="$emit('update:modelValue', false)" 10 - /> 11 - <div 12 - class="bg-base border-base absolute transition-all duration-200 ease-out" 13 - :class="[positionClass, 'scrolls']" 14 - :style="modelValue ? {}: {transform}" 15 - > 16 - <slot /> 17 - </div> 18 - </div> 19 - </template> 20 - 21 1 <script setup lang='ts'> 22 2 const props = withDefaults(defineProps<{ 23 3 modelValue?: boolean ··· 61 41 } 62 42 }) 63 43 </script> 44 + 45 + <template> 46 + <div 47 + class="fixed inset-0 z-40" 48 + :class="modelValue ? '': 'pointer-events-none'" 49 + > 50 + <div 51 + class="bg-base inset-0 absolute transition-opacity duration-500 ease-out" 52 + :class="modelValue ? 'opacity-50': 'opacity-0'" 53 + @click="$emit('update:modelValue', false)" 54 + /> 55 + <div 56 + class="bg-base border-base absolute transition-all duration-200 ease-out" 57 + :class="[positionClass, 'scrolls']" 58 + :style="modelValue ? {}: {transform}" 59 + > 60 + <slot /> 61 + </div> 62 + </div> 63 + </template>
+2 -2
packages/ui/client/utils/task.ts
··· 1 - 2 1 import type { Suite, Task } from '#types' 3 2 4 3 export function isSuite(task: Task): task is Suite { ··· 6 5 } 7 6 8 7 export function caseInsensitiveMatch(target: string, str2: string) { 9 - if (typeof target !== 'string' || typeof str2 !== 'string') return false 8 + if (typeof target !== 'string' || typeof str2 !== 'string') 9 + return false 10 10 return target.toLowerCase().includes(str2.toLowerCase()) 11 11 }
+1 -1
packages/ui/cypress/plugins/index.ts
··· 1 - import path from 'path' 1 + import path from 'pathe' 2 2 import { startDevServer } from '@cypress/vite-dev-server' 3 3 4 4 const plugin: Cypress.PluginConfig = (on, config) => {
+2 -1
packages/vitest/src/api/setup.ts
··· 94 94 } 95 95 }, 96 96 updateSnapshot(file?: File) { 97 - if (!file) return ctx.updateSnapshot() 97 + if (!file) 98 + return ctx.updateSnapshot() 98 99 return ctx.updateSnapshot([file.filepath]) 99 100 }, 100 101 },
+1
packages/vitest/src/integrations/globals.ts
··· 4 4 export function registerApiGlobally() { 5 5 globalApis.forEach((api) => { 6 6 // @ts-expect-error I know what I am doing :P 7 + // eslint-disable-next-line import/namespace 7 8 globalThis[api] = index[api] 8 9 }) 9 10 }
+6 -3
packages/vitest/src/node/core.ts
··· 122 122 else { 123 123 this.error(c.red(`No test files found, exiting code with ${exitCode}\nRun with \`--passWithNoTests\`to exit with code 0\n`)) 124 124 console.error(`In ${c.bold(this.config.root)}`) 125 - if (filters?.length) this.console.error(` filter: ${c.yellow(filters.join(', '))}`) 126 - if (this.config.include) this.console.error(` include: ${c.yellow(this.config.include.join(', '))}`) 127 - if (this.config.watchIgnore) this.console.error(` watchIgnore: ${c.yellow(this.config.watchIgnore.join(', '))}`) 125 + if (filters?.length) 126 + this.console.error(` filter: ${c.yellow(filters.join(', '))}`) 127 + if (this.config.include) 128 + this.console.error(` include: ${c.yellow(this.config.include.join(', '))}`) 129 + if (this.config.watchIgnore) 130 + this.console.error(` watchIgnore: ${c.yellow(this.config.watchIgnore.join(', '))}`) 128 131 } 129 132 130 133 process.exit(exitCode)
+2 -1
packages/vitest/src/runtime/collect.ts
··· 135 135 } 136 136 137 137 function checkAllowOnly(task: TaskBase, allowOnly?: boolean) { 138 - if (allowOnly) return 138 + if (allowOnly) 139 + return 139 140 task.result = { 140 141 state: 'fail', 141 142 error: processError(new Error('[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error')),
+6 -3
packages/vitest/src/runtime/mocker.ts
··· 19 19 let curr = obj 20 20 do { 21 21 // we don't need propterties from 'Object' 22 - if (curr === Object.prototype) break 22 + if (curr === Object.prototype) 23 + break 23 24 const props = Object.getOwnPropertyNames(curr) 24 25 props.forEach(prop => allProps.add(prop)) 25 26 // eslint-disable-next-line no-cond-assign ··· 132 133 const baseFilename = basename(path) 133 134 const mockFolder = resolve(this.root, '__mocks__', mockDirname) 134 135 135 - if (!existsSync(mockFolder)) return null 136 + if (!existsSync(mockFolder)) 137 + return null 136 138 137 139 const files = readdirSync(mockFolder) 138 140 ··· 235 237 } 236 238 237 239 private async ensureSpy() { 238 - if (VitestMocker.spyModule) return 240 + if (VitestMocker.spyModule) 241 + return 239 242 VitestMocker.spyModule = await this.request(resolve(distDir, 'jest-mock.js')) as typeof import('../integrations/jest-mock') 240 243 } 241 244
+2 -1
packages/vitest/src/runtime/run.ts
··· 142 142 t.mode = 'skip' 143 143 t.result = { ...t.result, state: 'skip' } 144 144 updateTask(t) 145 - if (t.type === 'suite') markTasksAsSkipped(t) 145 + if (t.type === 'suite') 146 + markTasksAsSkipped(t) 146 147 }) 147 148 } 148 149
+2 -1
packages/vitest/src/utils/base.ts
··· 110 110 export function assertTypes(value: unknown, name: string, types: string[]): void { 111 111 const receivedType = typeof value 112 112 const pass = types.includes(receivedType) 113 - if (!pass) throw new TypeError(`${name} value must be ${types.join(' or ')}, received "${receivedType}"`) 113 + if (!pass) 114 + throw new TypeError(`${name} value must be ${types.join(' or ')}, received "${receivedType}"`) 114 115 }
+2 -1
packages/vitest/src/utils/source-map.ts
··· 101 101 source: string, 102 102 offset: number | Position, 103 103 ): Position { 104 - if (typeof offset !== 'number') return offset 104 + if (typeof offset !== 'number') 105 + return offset 105 106 if (offset > source.length) { 106 107 throw new Error( 107 108 `offset is longer than source length! offset ${offset} > length ${source.length}`,
+2 -1
packages/ui/client/components/views/ViewEditor.vue
··· 81 81 widgets.push(cm.value!.addLineWidget(pos.line - 1, div)) 82 82 } 83 83 }) 84 - if (!hasBeenEdited.value) cm.value?.clearHistory() // Prevent getting access to initial state 84 + if (!hasBeenEdited.value) 85 + cm.value?.clearHistory() // Prevent getting access to initial state 85 86 }, 100) 86 87 }, { flush: 'post' }) 87 88
+2 -1
packages/ui/client/components/views/ViewReport.vue
··· 12 12 } 13 13 14 14 function collectFailed(task: Task, level: number): LeveledTask[] { 15 - if (task.result?.state !== 'fail') return [] 15 + if (task.result?.state !== 'fail') 16 + return [] 16 17 17 18 if (task.type === 'test') 18 19 return [{ ...task, level }]
+2 -1
packages/vitest/src/integrations/env/utils.ts
··· 8 8 export function getWindowKeys(global: any, win: any) { 9 9 const keys = new Set(KEYS.concat(Object.getOwnPropertyNames(win)) 10 10 .filter((k) => { 11 - if (k.startsWith('_')) return false 11 + if (k.startsWith('_')) 12 + return false 12 13 if (k in global) 13 14 return allowRewrite.has(k) 14 15
+2 -1
packages/vitest/src/integrations/snapshot/client.ts
··· 89 89 } 90 90 91 91 async saveSnap() { 92 - if (!this.testFile || !this.snapshotState) return 92 + if (!this.testFile || !this.snapshotState) 93 + return 93 94 const result = await packSnapshotState(this.testFile, this.snapshotState) 94 95 await rpc().snapshotSaved(result) 95 96
+2 -1
packages/vitest/src/node/plugins/mock.ts
··· 12 12 for (const mockResult of mocks) { 13 13 const lastIndex = getMockLastIndex(code.slice(mockResult.index!)) 14 14 15 - if (lastIndex === null) continue 15 + if (lastIndex === null) 16 + continue 16 17 17 18 const startIndex = mockResult.index! 18 19
+2 -1
packages/vitest/src/integrations/snapshot/port/utils.ts
··· 215 215 const mergedOutput = { ...target } 216 216 Object.keys(source).forEach((key) => { 217 217 if (isObject(source[key]) && !source[key].$$typeof) { 218 - if (!(key in target)) Object.assign(mergedOutput, { [key]: source[key] }) 218 + if (!(key in target)) 219 + Object.assign(mergedOutput, { [key]: source[key] }) 219 220 else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]) 220 221 } 221 222 else if (Array.isArray(source[key])) {