Skip to content

Commit

Permalink
Merge pull request #322 from mizdra/use-vite
Browse files Browse the repository at this point in the history
Refactoring tests
  • Loading branch information
mizdra authored Nov 12, 2023
2 parents c0f3db1 + 7474abe commit d6a2c89
Show file tree
Hide file tree
Showing 39 changed files with 812 additions and 2,048 deletions.
9 changes: 5 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
"source=eslint-interactive-dist,target=${containerWorkspaceFolder}/dist,type=volume"
],

// Set *default* container specific settings.json values on container create.
"settings": {},

"extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "Orta.vscode-jest"],
"customizations": {
"vscode": {
"extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "zixuanchen.vitest-explorer"]
}
},

// Run `pnpm install` the moment after the container has finished starting, but before the extension starts loading.
"onCreateCommand": "npm install -g pnpm && pnpm install",
Expand Down
3 changes: 0 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ module.exports = {
// for test
{
files: ['src/**/*.test.{ts,tsx,cts,mts}', 'src/test-util/**/*.{ts,tsx,cts,mts}'],
env: {
jest: true,
},
rules: {
'no-restricted-imports': 'off',
},
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Change ESLint version
run: pnpm add -D eslint@${{ matrix.eslint }}
run: pnpm add -w -D eslint@${{ matrix.eslint }}
- run: pnpm run test

e2e:
Expand All @@ -62,5 +62,5 @@ jobs:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Change ESLint version
run: pnpm add -D eslint@${{ matrix.eslint }}
run: pnpm add -w -D eslint@${{ matrix.eslint }}
- run: pnpm run e2e
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "orta.vscode-jest"]
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "zixuanchen.vitest-explorer"],
"unwantedRecommendations": ["orta.vscode-jest"]
}
10 changes: 0 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "pnpm",
"args": ["run", "test", "--runInBand", "--watchAll=false"]
},
{
"name": "dev",
"type": "node",
Expand Down
9 changes: 0 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"jest.jestCommandLine": "pnpm run test",
// It is expensive to run the test each time the file to be tested (e.g. `loader.ts`) is saved.
// So, run Jest only when the test file (e.g. `loader.test.ts`) is saved.
"jest.autoRun": {
"watch": false,
"onSave": "test-file"
},
// Do not open vscode-jest's terminal on launch.
"jest.showTerminalOnLaunch": false,
// Use nightly version tsserver
"typescript.tsdk": "node_modules/typescript/lib"
}
8 changes: 0 additions & 8 deletions babel.config.cjs

This file was deleted.

4 changes: 0 additions & 4 deletions e2e-test/babel.config.cjs

This file was deleted.

3 changes: 2 additions & 1 deletion e2e-test/global-installation/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeAll, expect, test } from 'vitest';
import { execSync, spawn } from 'child_process';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
Expand Down Expand Up @@ -26,7 +27,7 @@ test('verify installation', async () => {
});

// FIXME
test.failing('can print error with eslint-formatter-codeframe', async () => {
test.fails('can print error with eslint-formatter-codeframe', async () => {
const child = spawn(
'eslint-interactive',
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Programmable API 1`] = `
"- 8 files (0 file passed, 8 files failed) checked.
Expand Down
5 changes: 1 addition & 4 deletions e2e-test/import-as-esm-from-esm/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { afterEach, beforeEach, expect, test } from 'vitest';
import { execSync } from 'child_process';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import stripAnsi from 'strip-ansi';
// eslint-disable-next-line no-restricted-imports
import { cleanupFixturesCopy, getSnapshotOfChangedFiles, setupFixturesCopy } from '../../src/test-util/fixtures.js';

// eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = dirname(fileURLToPath(import.meta.url));

execSync('pnpm install --no-lockfile', { stdio: 'inherit', cwd: __dirname });
const { Core, takeRuleStatistics } = await import('eslint-interactive');

beforeEach(async () => {
Expand Down
13 changes: 0 additions & 13 deletions e2e-test/jest.config.mjs

This file was deleted.

22 changes: 0 additions & 22 deletions jest.config.base.mjs

This file was deleted.

12 changes: 0 additions & 12 deletions jest.config.mjs

This file was deleted.

18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@
"lint:tsc": "tsc -p tsconfig.json --noEmit",
"lint:eslint": "eslint .",
"lint:prettier": "prettier --check .",
"test": "cross-env FORCE_HYPERLINK=1 NODE_OPTIONS=\"--experimental-vm-modules --experimental-import-meta-resolve $NODE_OPTIONS\" jest --colors",
"test": "vitest",
"e2e": "run-s e2e:prepare e2e:run",
"e2e:prepare": "pnpm run build",
"e2e:run": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-import-meta-resolve $NODE_OPTIONS\" jest -c e2e-test/jest.config.mjs --runInBand"
"e2e:run": "vitest -c vite.config.e2e.ts"
},
"prettier": "@mizdra/prettier-config-mizdra",
"packageManager": "pnpm@8.9.0",
"devDependencies": {
"@babel/core": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@jest/globals": "^29.7.0",
"@jest/types": "^29.6.3",
"@mizdra/eslint-config-mizdra": "2.1.0-alpha.0",
"@mizdra/prettier-config-mizdra": "^1.0.0",
"@tsconfig/node18": "^18.2.2",
Expand All @@ -44,20 +40,16 @@
"@types/estraverse": "^5.1.6",
"@types/estree": "^1.0.5",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.7",
"@types/node": "^20.8.10",
"@types/yargs": "^17.0.29",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"eslint": "^8.53.0",
"fs-extra": "^11.1.1",
"jest": "^29.7.0",
"jest-mock-process": "^2.0.0",
"npm-run-all": "^4.1.5",
"prettier": "3.0.3",
"resolve-from": "^5.0.0",
"stream-match": "^4.1.0",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"vitest": "^0.34.6",
"vitest-github-actions-reporter": "^0.10.0"
},
"dependencies": {
"boxen": "^7.1.1",
Expand Down
Loading

0 comments on commit d6a2c89

Please sign in to comment.