Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Migrate from Mocha to Vitest#2789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
2nofa11 wants to merge8 commits intovuejs:master
base:master
Choose a base branch
Loading
from2nofa11:chore/migrate-to-vitest
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions.vscode/launch.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,9 +5,17 @@
"type": "node",
"request": "launch",
"name": "Start testing",
"program": "${workspaceFolder}/node_modules/.bin/mocha",
"args": ["${file}", "--watch"],
"program": "${workspaceFolder}/node_modules/.bin/vitest",
"args": ["run", "${file}", "--reporter=verbose"],
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Start testing (watch)",
"program": "${workspaceFolder}/node_modules/.bin/vitest",
"args": ["${file}", "--reporter=verbose"],
"console": "integratedTerminal"
}
]
}
}
2 changes: 1 addition & 1 deletioneslint.config.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export default typegen([
globals: {
...globals.es6,
...globals.node,
...globals.mocha
...globals.vitest
}
},
linterOptions: {
Expand Down
15 changes: 7 additions & 8 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,13 +7,13 @@
"scripts": {
"new": "node tools/new-rule.js",
"start": "npm run test:base -- --watch --growl",
"test:base": "mocha \"tests/lib/**/*.js\" --reporterdot",
"test": "nyc npmrun test:base -- \"tests/integrations/*.js\" --timeout 60000",
"test:integrations": "mocha \"tests/integrations/*.js\" --timeout 60000",
"debug": "mocha--inspect\"tests/lib/**/*.js\" --reporterdot--timeout 60000",
"test:base": "vitest run --reporter=dot tests/lib",
"test": "vitestrun",
"test:integrations": "vitest runtests/integrations",
"debug": "vitest run--inspect--no-file-parallelism --reporter=dottests/lib",
"cover": "npm run cover:test && npm run cover:report",
"cover:test": "nyc npmruntest:base -- --timeout 60000",
"cover:report": "nycreport--reporter=html",
"cover:test": "vitestrun--coverage --reporter=dot tests/lib",
"cover:report": "echo 'HTML coveragereportavailable at ./coverage/index.html'",
"lint": "eslint . && markdownlint \"**/*.md\"",
"lint:fix": "eslint . --fix && markdownlint \"**/*.md\" --fix",
"tsc": "tsc",
Expand DownExpand Up@@ -87,6 +87,7 @@
"@types/xml-name-validator": "^4.0.3",
"@typescript-eslint/parser": "^8.35.1",
"@typescript-eslint/types": "^8.35.1",
"@vitest/coverage-v8": "^3.2.4",
"assert": "^2.1.0",
"env-cmd": "^10.1.0",
"esbuild": "^0.24.0",
Expand All@@ -106,8 +107,6 @@
"globals": "^15.14.0",
"jsdom": "^22.0.0",
"markdownlint-cli": "^0.42.0",
"mocha": "^10.7.3",
"nyc": "^17.1.0",
"pathe": "^1.1.2",
"prettier": "^3.3.3",
"typescript": "^5.7.2",
Expand Down
5 changes: 0 additions & 5 deletionstests/.eslintrc.json
View file
Open in desktop

This file was deleted.

14 changes: 4 additions & 10 deletionstests/integrations/eslint-plugin-import.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,18 +9,12 @@ const cp = require('child_process')
const path = require('path')
const semver = require('semver')

const PLUGIN_DIR = path.join(__dirname, 'eslint-plugin-import')
const ESLINT = `.${path.sep}node_modules${path.sep}.bin${path.sep}eslint`

describe('Integration with eslint-plugin-import', () => {
let originalCwd

before(() => {
originalCwd = process.cwd()
process.chdir(path.join(__dirname, 'eslint-plugin-import'))
cp.execSync('npm i', { stdio: 'inherit' })
})
after(() => {
process.chdir(originalCwd)
beforeAll(() => {
cp.execSync('npm i', { cwd: PLUGIN_DIR, stdio: 'inherit' })
})

// https://github.com/vuejs/eslint-plugin-vue/issues/21#issuecomment-308957697
Expand All@@ -41,6 +35,6 @@ describe('Integration with eslint-plugin-import', () => {
return
}

cp.execSync(`${ESLINT} a.vue`, { stdio: 'inherit' })
cp.execSync(`${ESLINT} a.vue`, {cwd: PLUGIN_DIR,stdio: 'inherit' })
})
})
13 changes: 4 additions & 9 deletionstests/integrations/flat-config.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,18 +5,12 @@ const cp = require('child_process')
const path = require('path')
const semver = require('semver')

const TARGET_DIR = path.join(__dirname, 'flat-config')
const ESLINT = `.${path.sep}node_modules${path.sep}.bin${path.sep}eslint`

describe('Integration with flat config', () => {
let originalCwd

before(() => {
originalCwd = process.cwd()
process.chdir(path.join(__dirname, 'flat-config'))
cp.execSync('npm i -f', { stdio: 'inherit' })
})
after(() => {
process.chdir(originalCwd)
beforeAll(() => {
cp.execSync('npm i -f', { cwd: TARGET_DIR, stdio: 'inherit' })
})

it('should lint without errors', () => {
Expand All@@ -33,6 +27,7 @@ describe('Integration with flat config', () => {

const result = JSON.parse(
cp.execSync(`${ESLINT} a.vue --format=json`, {
cwd: TARGET_DIR,
encoding: 'utf8'
})
)
Expand Down
32 changes: 32 additions & 0 deletionsvitest.config.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@

import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
include: [
'tests/lib/**/*.js',
'tests/integrations/**/*.js'
],
exclude: [
'**/node_modules/**',
'**/dist/**',
'tests/fixtures/**',
'tests/integrations/flat-config/eslint.config.js',
'tests/lib/rules/no-unsupported-features/utils.js'
],
testTimeout: 60_000,
globals: true,
coverage: {
provider: 'v8',
include: ['lib/**/*.js'],
exclude: [
'tests/**',
'dist/**',
'tools/**',
'node_modules/**'
],
reporter: ['text', 'lcov', 'json-summary', 'html'],
all: true,
reportsDirectory: './coverage'
},
},
});

[8]ページ先頭

©2009-2025 Movatter.jp