Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ jobs:
command: pnpm eslint

- run:
name: Jest
command: pnpm jest --ci
name: Vitest
command: pnpm vitest run --coverage

- run:
name: Brakeman
Expand Down
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

40 changes: 0 additions & 40 deletions config/jest.json

This file was deleted.

26 changes: 13 additions & 13 deletions eslint.config.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import globals from "globals";
import importPlugin from "eslint-plugin-import";
import jest from "eslint-plugin-jest";
import vitest from "eslint-plugin-vitest";
import js from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
Expand All @@ -13,13 +13,12 @@ export default defineConfig([
js.configs.all,
tseslint.configs.all,
importPlugin.flatConfigs.recommended,
jest.configs["flat/all"],
vitest.configs.all,
stylistic.configs.all,
{
ignores: [
".eslint_todo.ts",
"app/assets/builds/**",
"babel.config.js",
"coverage/**",
"public/**",
"vendor/**",
Expand All @@ -38,10 +37,8 @@ export default defineConfig([
},
plugins: {
importPlugin,
jest,
js,
"sort-keys-fix": sortKeysFix,
stylistic,
vitest,
},
rules: {
"@stylistic/array-element-newline": ["error", "consistent"],
Expand All @@ -64,9 +61,6 @@ export default defineConfig([
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"arrow-body-style": ["error", "always"],
"func-style": ["error", "declaration"],
"jest/consistent-test-it": ["error", {fn: "it", withinDescribe: "it"}],
"jest/prefer-expect-assertions": "off",
"jest/require-top-level-describe": "off",
"max-len": ["error", 84, {ignoreUrls: true}],
"no-duplicate-imports": ["error", {allowSeparateTypeImports: true}],
"no-magic-numbers": "off",
Expand All @@ -77,6 +71,12 @@ export default defineConfig([
"sort-keys": ["error", "asc", {caseSensitive: false, natural: true}],
"sort-keys-fix/sort-keys-fix":
["error", "asc", {caseSensitive: false, natural: true}],
"vitest/consistent-test-it":
["error", {fn: "it", withinDescribe: "it"}],
"vitest/prefer-expect-assertions": "off",
"vitest/prefer-to-be-falsy": "off",
"vitest/prefer-to-be-truthy": "off",
"vitest/require-top-level-describe": "off",
},
settings: {
"import/resolver": {
Expand All @@ -89,20 +89,20 @@ export default defineConfig([
{
files: ["spec/javascript/test_helper.ts"],
rules: {
"jest/no-hooks": "off",
"jest/no-standalone-expect": "off",
"vitest/no-hooks": "off",
"vitest/no-standalone-expect": "off",
},
},
{
files: ["spec/javascript/support/**/*"],
rules: {
"jest/no-hooks": "off",
"vitest/no-hooks": "off",
},
},
{
files: ["app/javascript/**/*.ts"],
rules: {
"jest/require-hook": "off",
"vitest/require-hook": "off",
},
},
...eslintTodo,
Expand Down
23 changes: 7 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,40 @@
"@rails/activestorage": "^8.1.100"
},
"devDependencies": {
"@babel/core": "^7.28.5",
"@babel/preset-env": "^7.28.5",
"@eslint/eslintrc": "^3.3.3",
"@eslint/js": "^9.39.2",
"@jest/globals": "^30.2.0",
"@stylistic/eslint-plugin": "^5.6.1",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"@stylistic/eslint-plugin": "^5.7.0",
"@types/hotwired__turbo": "^8.0.5",
"@types/jest": "^30.0.0",
"@types/node": "^25.0.3",
"@types/rails__actioncable": "^8.0.3",
"@typescript-eslint/eslint-plugin": "^8.50.0",
"@typescript-eslint/parser": "^8.50.0",
"@vitest/coverage-v8": "^4.0.18",
"esbuild": "^0.27.1",
"eslint": "^9.39.2",
"eslint-find-rules": "^5.0.0",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.5.0",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-vitest": "^0.5.4",
"globals": "^17.3.0",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0",
"jest-junit": "^16.0.0",
"jest-util": "^30.0.5",
"jiti": "^2.6.1",
"jsdom": "^28.0.0",
"stylelint": "^17.0.0",
"stylelint-config-property-sort-order-smacss": "^11.0.0",
"stylelint-config-standard": "^40.0.0",
"stylelint-selector-bem-pattern": "^4.0.1",
"ts-jest": "^29.4.6",
"typescript": "^5.9.3",
"typescript-eslint": "^8.50.1"
"typescript-eslint": "^8.54.0",
"vitest": "^4.0.18"
},
"scripts": {
"build": "esbuild app/javascript/*.* --bundle --sourcemap --format=iife --outdir=app/assets/builds --public-path=/assets",
"eslint": "eslint ./ --cache --max-warnings=0",
"eslint_find_unused_rules": "eslint-find-rules --unused --flatConfig --no-core eslint.config.mts",
"jest": "./node_modules/jest/bin/jest.js --coverage --config config/jest.json",
"pretest": "pnpm tscheck && pnpm eslint",
"stylelint": "./node_modules/stylelint/bin/stylelint.mjs 'app/assets/stylesheets/**/*'",
"test": "pnpm jest",
"test": "pnpm vitest run --coverage",
"tscheck": "pnpm tsc --noEmit"
}
}
2 changes: 1 addition & 1 deletion spec/javascript/application_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, it} from "@jest/globals";
import {expect, it} from "vitest";
import "javascript/application";

it("disables Turbo", () => {
Expand Down
2 changes: 1 addition & 1 deletion spec/javascript/channels/consumer_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, it} from "@jest/globals";
import {expect, it} from "vitest";
import consumer from "channels/consumer";

it("is defined", () => {
Expand Down
2 changes: 1 addition & 1 deletion spec/javascript/controllers/dialog_controller_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, it} from "@jest/globals";
import {expect, it} from "vitest";
import {bootStimulus} from "spec/javascript/support/stimulus";
import DialogController from "controllers/dialog_controller";

Expand Down
6 changes: 3 additions & 3 deletions spec/javascript/controllers/hotkeys_controller_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {describe, expect, it, jest} from "@jest/globals";
import {describe, expect, it, vi} from "vitest";
import {bootStimulus, getController} from "spec/javascript/support/stimulus";
import HotkeysController from "controllers/hotkeys_controller";
import {assert} from "javascript/helpers";
Expand Down Expand Up @@ -56,7 +56,7 @@ describe("clickTargetDisconnected", () => {
describe("handleKeydown", () => {
it("clicks the target for the pressed key", async () => {
await setupController();
const clickSpy = jest.spyOn(button(), "click");
const clickSpy = vi.spyOn(button(), "click");

controller().handleKeydown(new KeyboardEvent("keydown", {key: "a"}));

Expand All @@ -65,7 +65,7 @@ describe("handleKeydown", () => {

it("does nothing if there is no target for the pressed key", async () => {
await setupController();
const clickSpy = jest.spyOn(button(), "click");
const clickSpy = vi.spyOn(button(), "click");

controller().handleKeydown(new KeyboardEvent("keydown", {key: "b"}));

Expand Down
2 changes: 1 addition & 1 deletion spec/javascript/helpers/assert_spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {describe, expect, it} from "@jest/globals";
import {describe, expect, it} from "vitest";
import {assert} from "javascript/helpers";

describe("assert", () => {
Expand Down
2 changes: 1 addition & 1 deletion spec/javascript/support/stimulus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {afterEach} from "@jest/globals";
import {afterEach} from "vitest";
import type {Context, Controller} from "@hotwired/stimulus";
import {Application} from "@hotwired/stimulus";

Expand Down
2 changes: 1 addition & 1 deletion spec/javascript/test_helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {beforeEach, expect} from "@jest/globals";
import {beforeEach, expect} from "vitest";

beforeEach(() => {
expect.hasAssertions();
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true
"noUncheckedIndexedAccess": true,
"skipLibCheck": true
},
"exclude": ["app/assets/builds", "coverage", "node_modules", "public", "vendor"]
}
47 changes: 47 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {defineConfig} from "vitest/config";
import path from "node:path";

const root = import.meta.dirname;

function appPath(subpath: string): string {
return `${path.resolve(root, "app/javascript", subpath)}/`;
}

export default defineConfig({
resolve: {
alias: [
{find: /^channels\//u, replacement: appPath("channels")},
{find: /^controllers\//u, replacement: appPath("controllers")},
{find: /^javascript\//u, replacement: appPath("")},
{find: /^spec\//u, replacement: `${path.resolve(root, "spec")}/`},
],
},
test: {
coverage: {
exclude: ["app/javascript/@types/**"],
include: ["app/javascript/**/*.ts"],
provider: "v8",
reportsDirectory: "coverage/vitest",
thresholds: {
branches: 100,
functions: 100,
lines: 0,
statements: 0,
},
},
environment: "jsdom",
environmentOptions: {
jsdom: {
url: "http://test.host",
},
},
include: ["spec/javascript/**/*_spec.ts"],
outputFile: {
junit: "/tmp/test-results/junit.xml",
},
reporters: ["default", "junit"],
restoreMocks: true,
root: ".",
setupFiles: ["spec/javascript/test_helper.ts"],
},
});
Loading