diff --git a/eslint.config.mjs b/eslint.config.mjs index b299e7140604..41a9e3d5709c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -31,12 +31,15 @@ const restrictNamedDeclarations = { const vitestFiles = [ 'packages/eslint-plugin-internal/tests/**/*.test.{ts,tsx,cts,mts}', - 'packages/typescript-eslint/tests/**/*.test.{ts,tsx,cts,mts}', - 'packages/visitor-keys/tests/**/*.test.{ts,tsx,cts,mts}', + 'packages/integration-tests/tests/**/*.test.{ts,tsx,cts,mts},', + 'packages/integration-tests/tools/integration-test-base.ts', + 'packages/integration-tests/tools/pack-packages.ts', 'packages/parser/tests/lib/**/*.test.{ts,tsx,cts,mts}', 'packages/parser/tests/test-utils/**/*.{ts,tsx,cts,mts}', - 'packages/utils/tests/**/*.test?(-d).{ts,tsx,cts,mts}', 'packages/type-utils/tests/**/*.test.{ts,tsx,cts,mts}', + 'packages/typescript-eslint/tests/**/*.test.{ts,tsx,cts,mts}', + 'packages/utils/tests/**/*.test?(-d).{ts,tsx,cts,mts}', + 'packages/visitor-keys/tests/**/*.test.{ts,tsx,cts,mts}', ]; export default tseslint.config( @@ -390,8 +393,6 @@ export default tseslint.config( files: [ 'packages/*/tests/**/*.test.{ts,tsx,cts,mts}', 'packages/*/tests/**/test.{ts,tsx,cts,mts}', - 'packages/integration-tests/tools/integration-test-base.ts', - 'packages/integration-tests/tools/pack-packages.ts', ], ignores: vitestFiles, rules: { diff --git a/knip.ts b/knip.ts index 31e97fbfb05f..fe899305fe41 100644 --- a/knip.ts +++ b/knip.ts @@ -59,7 +59,7 @@ export default { ignore: ['tests/fixtures/**'], }, 'packages/integration-tests': { - ignore: ['fixtures/**', 'typings/global.d.ts'], + ignore: ['fixtures/**'], }, 'packages/parser': { ignore: ['tests/fixtures/**'], diff --git a/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v8/eslint.config.js b/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v8/eslint.config.js index c0e380da22d2..2a31589bc03c 100644 --- a/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v8/eslint.config.js +++ b/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v8/eslint.config.js @@ -3,8 +3,8 @@ import { FlatCompat } from '@eslint/eslintrc'; import eslint from '@eslint/js'; import stylisticPlugin from '@stylistic/eslint-plugin'; +import vitestPlugin from '@vitest/eslint-plugin'; import deprecationPlugin from 'eslint-plugin-deprecation'; -import jestPlugin from 'eslint-plugin-jest'; import tseslint from 'typescript-eslint'; import __dirname from './dirname.cjs'; @@ -26,7 +26,7 @@ export default tseslint.config( plugins: { ['@typescript-eslint']: tseslint.plugin, ['deprecation']: deprecationPlugin, - ['jest']: jestPlugin, + ['vitest']: vitestPlugin, }, }, eslint.configs.recommended, @@ -42,23 +42,23 @@ function _otherCases() { ['@stylistic']: stylisticPlugin, ['@typescript-eslint']: tseslint.plugin, ['deprecation']: deprecationPlugin, - ['jest']: jestPlugin, + ['vitest']: vitestPlugin, }, }); tseslint.config( eslint.configs.recommended, ...tseslint.configs.recommended, stylisticPlugin.configs['recommended-flat'], - jestPlugin.configs['flat/recommended'], + vitestPlugin.configs.recommended, ); tseslint.config( // @ts-expect-error compat.config(deprecationPlugin.configs.recommended), - ...compat.config(jestPlugin.configs.recommended), + vitestPlugin.configs.recommended, ); tseslint.config( // @ts-expect-error deprecationPlugin.configs.recommended, - jestPlugin.configs.recommended, + vitestPlugin.configs.recommended, ); } diff --git a/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v8/package.json b/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v8/package.json index 36b3ca74a7fd..4a4107573d35 100644 --- a/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v8/package.json +++ b/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v8/package.json @@ -7,6 +7,6 @@ "eslint": "9.9.1", "@stylistic/eslint-plugin": "2.3.0", "eslint-plugin-deprecation": "latest", - "eslint-plugin-jest": "latest" + "@vitest/eslint-plugin": "latest" } } diff --git a/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/eslint.config.js b/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/eslint.config.js index c0e380da22d2..2a31589bc03c 100644 --- a/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/eslint.config.js +++ b/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/eslint.config.js @@ -3,8 +3,8 @@ import { FlatCompat } from '@eslint/eslintrc'; import eslint from '@eslint/js'; import stylisticPlugin from '@stylistic/eslint-plugin'; +import vitestPlugin from '@vitest/eslint-plugin'; import deprecationPlugin from 'eslint-plugin-deprecation'; -import jestPlugin from 'eslint-plugin-jest'; import tseslint from 'typescript-eslint'; import __dirname from './dirname.cjs'; @@ -26,7 +26,7 @@ export default tseslint.config( plugins: { ['@typescript-eslint']: tseslint.plugin, ['deprecation']: deprecationPlugin, - ['jest']: jestPlugin, + ['vitest']: vitestPlugin, }, }, eslint.configs.recommended, @@ -42,23 +42,23 @@ function _otherCases() { ['@stylistic']: stylisticPlugin, ['@typescript-eslint']: tseslint.plugin, ['deprecation']: deprecationPlugin, - ['jest']: jestPlugin, + ['vitest']: vitestPlugin, }, }); tseslint.config( eslint.configs.recommended, ...tseslint.configs.recommended, stylisticPlugin.configs['recommended-flat'], - jestPlugin.configs['flat/recommended'], + vitestPlugin.configs.recommended, ); tseslint.config( // @ts-expect-error compat.config(deprecationPlugin.configs.recommended), - ...compat.config(jestPlugin.configs.recommended), + vitestPlugin.configs.recommended, ); tseslint.config( // @ts-expect-error deprecationPlugin.configs.recommended, - jestPlugin.configs.recommended, + vitestPlugin.configs.recommended, ); } diff --git a/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/package.json b/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/package.json index 517496e985ec..79a0437dc5e1 100644 --- a/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/package.json +++ b/packages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/package.json @@ -7,6 +7,6 @@ "eslint": "latest", "@stylistic/eslint-plugin": "latest", "eslint-plugin-deprecation": "latest", - "eslint-plugin-jest": "latest" + "@vitest/eslint-plugin": "latest" } } diff --git a/packages/integration-tests/jest.config.js b/packages/integration-tests/jest.config.js deleted file mode 100644 index ce0a347c52e1..000000000000 --- a/packages/integration-tests/jest.config.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -// pack the packages ahead of time and create a mapping for use in the tests -require('tsx/cjs'); -const { setup } = require('./tools/pack-packages'); - -// @ts-check -/** @type {() => Promise} */ -module.exports = async () => ({ - ...require('../../jest.config.base.js'), - globals: { - tseslintPackages: await setup(), - }, - globalTeardown: './tools/pack-packages.ts', - testRegex: ['/tests/[^/]+.test.ts$'], - rootDir: __dirname, -}); diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index a58c13b47ef7..c1298201a5a8 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -14,12 +14,11 @@ "scripts": { "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "npx nx lint", - "test": "jest --no-coverage", + "test": "vitest --run --config=$INIT_CWD/vitest.config.mts", "check-types": "npx nx typecheck" }, "devDependencies": { - "@jest/types": "29.6.3", - "jest": "29.7.0", - "tsx": "*" + "@vitest/coverage-v8": "^3.1.1", + "vitest": "^3.1.1" } } diff --git a/packages/integration-tests/project.json b/packages/integration-tests/project.json index ce97afcc5e5a..a34197dff37d 100644 --- a/packages/integration-tests/project.json +++ b/packages/integration-tests/project.json @@ -1,12 +1,17 @@ { "name": "integration-tests", "$schema": "../../node_modules/nx/schemas/project-schema.json", - "type": "library", + "projectType": "library", + "root": "packages/integration-tests", + "sourceRoot": "packages/integration-tests/tools", "implicitDependencies": ["typescript-eslint"], "targets": { "lint": { "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"] + }, + "test": { + "executor": "@nx/vite:test" } } } diff --git a/packages/integration-tests/tests/__snapshots__/eslint-v8.test.ts.snap b/packages/integration-tests/tests/__snapshots__/eslint-v8.test.ts.snap index fc96eb5bd1b2..8b4bb4e3cfdc 100644 --- a/packages/integration-tests/tests/__snapshots__/eslint-v8.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/eslint-v8.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`eslint-v8 eslint should work successfully 1`] = ` +exports[`eslint-v8 > eslint > should work successfully 1`] = ` [ { "errorCount": 1, diff --git a/packages/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v8.test.ts.snap b/packages/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v8.test.ts.snap index 1fe0ccef80bf..7592f9303847 100644 --- a/packages/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v8.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v8.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`flat-config-types-@types__eslint-v8 eslint should work successfully 1`] = ` +exports[`flat-config-types-@types__eslint-v8 > eslint > should work successfully 1`] = ` [ { "errorCount": 3, @@ -48,8 +48,8 @@ exports[`flat-config-types-@types__eslint-v8 eslint should work successfully 1`] import { FlatCompat } from '@eslint/eslintrc' import eslint from '@eslint/js' import stylisticPlugin from '@stylistic/eslint-plugin' +import vitestPlugin from '@vitest/eslint-plugin' import deprecationPlugin from 'eslint-plugin-deprecation' -import jestPlugin from 'eslint-plugin-jest' import tseslint from 'typescript-eslint' import __dirname from './dirname.cjs' @@ -71,7 +71,7 @@ export default tseslint.config( plugins: { ['@typescript-eslint']: tseslint.plugin, ['deprecation']: deprecationPlugin, - ['jest']: jestPlugin, + ['vitest']: vitestPlugin, }, }, eslint.configs.recommended, @@ -87,24 +87,24 @@ function _otherCases() { ['@stylistic']: stylisticPlugin, ['@typescript-eslint']: tseslint.plugin, ['deprecation']: deprecationPlugin, - ['jest']: jestPlugin, + ['vitest']: vitestPlugin, }, }) tseslint.config( eslint.configs.recommended, ...tseslint.configs.recommended, stylisticPlugin.configs['recommended-flat'], - jestPlugin.configs['flat/recommended'], + vitestPlugin.configs.recommended, ) tseslint.config( // @ts-expect-error compat.config(deprecationPlugin.configs.recommended), - ...compat.config(jestPlugin.configs.recommended), + vitestPlugin.configs.recommended, ) tseslint.config( // @ts-expect-error deprecationPlugin.configs.recommended, - jestPlugin.configs.recommended, + vitestPlugin.configs.recommended, ) } ", diff --git a/packages/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v9.test.ts.snap b/packages/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v9.test.ts.snap index 1a74d0e13afa..fa2a75464d2c 100644 --- a/packages/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v9.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v9.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`flat-config-types-@types__eslint-v9 eslint should work successfully 1`] = ` +exports[`flat-config-types-@types__eslint-v9 > eslint > should work successfully 1`] = ` [ { "errorCount": 3, @@ -48,8 +48,8 @@ exports[`flat-config-types-@types__eslint-v9 eslint should work successfully 1`] import { FlatCompat } from '@eslint/eslintrc' import eslint from '@eslint/js' import stylisticPlugin from '@stylistic/eslint-plugin' +import vitestPlugin from '@vitest/eslint-plugin' import deprecationPlugin from 'eslint-plugin-deprecation' -import jestPlugin from 'eslint-plugin-jest' import tseslint from 'typescript-eslint' import __dirname from './dirname.cjs' @@ -71,7 +71,7 @@ export default tseslint.config( plugins: { ['@typescript-eslint']: tseslint.plugin, ['deprecation']: deprecationPlugin, - ['jest']: jestPlugin, + ['vitest']: vitestPlugin, }, }, eslint.configs.recommended, @@ -87,24 +87,24 @@ function _otherCases() { ['@stylistic']: stylisticPlugin, ['@typescript-eslint']: tseslint.plugin, ['deprecation']: deprecationPlugin, - ['jest']: jestPlugin, + ['vitest']: vitestPlugin, }, }) tseslint.config( eslint.configs.recommended, ...tseslint.configs.recommended, stylisticPlugin.configs['recommended-flat'], - jestPlugin.configs['flat/recommended'], + vitestPlugin.configs.recommended, ) tseslint.config( // @ts-expect-error compat.config(deprecationPlugin.configs.recommended), - ...compat.config(jestPlugin.configs.recommended), + vitestPlugin.configs.recommended, ) tseslint.config( // @ts-expect-error deprecationPlugin.configs.recommended, - jestPlugin.configs.recommended, + vitestPlugin.configs.recommended, ) } ", diff --git a/packages/integration-tests/tests/__snapshots__/markdown.test.ts.snap b/packages/integration-tests/tests/__snapshots__/markdown.test.ts.snap index b987cad32f7f..9f5bda85287a 100644 --- a/packages/integration-tests/tests/__snapshots__/markdown.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/markdown.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`markdown eslint should work successfully 1`] = ` +exports[`markdown > eslint > should work successfully 1`] = ` [ { "errorCount": 10, diff --git a/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap b/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap index 059dfb803b0e..a8bb9c1e3138 100644 --- a/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`recommended-does-not-require-program eslint should work successfully 1`] = ` +exports[`recommended-does-not-require-program > eslint > should work successfully 1`] = ` [ { "errorCount": 1, diff --git a/packages/integration-tests/tests/__snapshots__/vue-jsx.test.ts.snap b/packages/integration-tests/tests/__snapshots__/vue-jsx.test.ts.snap index 94cb255c6050..bed8923abdb3 100644 --- a/packages/integration-tests/tests/__snapshots__/vue-jsx.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/vue-jsx.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`vue-jsx eslint should work successfully 1`] = ` +exports[`vue-jsx > eslint > should work successfully 1`] = ` [ { "errorCount": 1, diff --git a/packages/integration-tests/tests/__snapshots__/vue-sfc.test.ts.snap b/packages/integration-tests/tests/__snapshots__/vue-sfc.test.ts.snap index d649b5ab80e3..2eeb2fa46f59 100644 --- a/packages/integration-tests/tests/__snapshots__/vue-sfc.test.ts.snap +++ b/packages/integration-tests/tests/__snapshots__/vue-sfc.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`vue-sfc eslint should work successfully 1`] = ` +exports[`vue-sfc > eslint > should work successfully 1`] = ` [ { "errorCount": 1, diff --git a/packages/integration-tests/tools/integration-test-base.ts b/packages/integration-tests/tools/integration-test-base.ts index 3b6d49936407..8951c11c54e4 100644 --- a/packages/integration-tests/tools/integration-test-base.ts +++ b/packages/integration-tests/tools/integration-test-base.ts @@ -1,10 +1,10 @@ import * as fs from 'node:fs/promises'; import * as path from 'node:path'; -import { execFile, FIXTURES_DESTINATION_DIR } from './pack-packages'; +import { execFile, FIXTURES_DESTINATION_DIR } from './pack-packages.js'; -// make sure that jest doesn't timeout the test -jest.setTimeout(60_000); +// make sure that vitest doesn't timeout the test +vi.setConfig({ testTimeout: 60_000 }); function integrationTest( testName: string, diff --git a/packages/integration-tests/tools/pack-packages.ts b/packages/integration-tests/tools/pack-packages.ts index cf775c564929..a5b83cee1f59 100644 --- a/packages/integration-tests/tools/pack-packages.ts +++ b/packages/integration-tests/tools/pack-packages.ts @@ -7,6 +7,8 @@ * against the exact same version of the package. */ +import type { TestProject } from 'vitest/node'; + import * as child_process from 'node:child_process'; import * as fs from 'node:fs/promises'; import * as os from 'node:os'; @@ -44,10 +46,10 @@ const FIXTURES_DIR = path.join(__dirname, '..', FIXTURES_DIR_BASENAME); const TAR_FOLDER = path.join(INTEGRATION_TEST_DIR, 'tarballs'); -export const setup = async (): Promise => { - const testFileBaseNames = await fs.readdir(FIXTURES_DIR, { - encoding: 'utf-8', - }); +export const setup = async (project: TestProject): Promise => { + const testFileBaseNames = ( + await project.globTestFiles(project.vitest.state.getPaths()) + ).testFiles.map(testFilePath => path.basename(testFilePath, '.test.ts')); const PACKAGES = await fs.readdir(PACKAGES_DIR, { encoding: 'utf-8', @@ -213,15 +215,10 @@ export const setup = async (): Promise => { await fs.rm(temp, { recursive: true }); console.log('Finished packing local packages.'); - - return tseslintPackages; }; -const teardown = async (): Promise => { +export const teardown = async (): Promise => { if (process.env.KEEP_INTEGRATION_TEST_DIR !== 'true') { await fs.rm(INTEGRATION_TEST_DIR, { recursive: true }); } }; - -// eslint-disable-next-line import/no-default-export -export default teardown; diff --git a/packages/integration-tests/tsconfig.spec.json b/packages/integration-tests/tsconfig.spec.json index 9bd369767292..d7f954ed0f80 100644 --- a/packages/integration-tests/tsconfig.spec.json +++ b/packages/integration-tests/tsconfig.spec.json @@ -4,10 +4,11 @@ "outDir": "../../dist/out-tsc/packages/integration-tests", "module": "NodeNext", "resolveJsonModule": true, - "types": ["jest", "node"] + "types": ["node", "vitest/globals", "vitest/importMeta"] }, "include": [ - "jest.config.js", + "vitest.config.mts", + "package.json", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts", @@ -15,5 +16,9 @@ "tools", "typings" ], - "references": [] + "references": [ + { + "path": "../../tsconfig.spec.json" + } + ] } diff --git a/packages/integration-tests/typings/global.d.ts b/packages/integration-tests/typings/global.d.ts deleted file mode 100644 index 1a4c2599eaea..000000000000 --- a/packages/integration-tests/typings/global.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -// eslint-disable-next-line no-var -declare var tseslintPackages: Record; diff --git a/packages/integration-tests/vitest.config.mts b/packages/integration-tests/vitest.config.mts new file mode 100644 index 000000000000..5bf58b7687e7 --- /dev/null +++ b/packages/integration-tests/vitest.config.mts @@ -0,0 +1,22 @@ +import * as path from 'node:path'; +import { defineProject, mergeConfig } from 'vitest/config'; + +import { vitestBaseConfig } from '../../vitest.config.base.mjs'; +import packageJson from './package.json' with { type: 'json' }; + +const vitestConfig = mergeConfig( + vitestBaseConfig, + + defineProject({ + root: import.meta.dirname, + + test: { + dir: path.join(import.meta.dirname, 'tests'), + globalSetup: ['./tools/pack-packages.ts'], + name: packageJson.name.replace('@typescript-eslint/', ''), + root: import.meta.dirname, + }, + }), +); + +export default vitestConfig; diff --git a/yarn.lock b/yarn.lock index bf09c06b77b2..f2e57d71b531 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6064,9 +6064,8 @@ __metadata: version: 0.0.0-use.local resolution: "@typescript-eslint/integration-tests@workspace:packages/integration-tests" dependencies: - "@jest/types": 29.6.3 - jest: 29.7.0 - tsx: "*" + "@vitest/coverage-v8": ^3.1.1 + vitest: ^3.1.1 languageName: unknown linkType: soft pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy