Просмотр исходного кода

migrate to vitest in @growi/core

Yuki Takei 2 лет назад
Родитель
Сommit
d03b7ae6e2

+ 1 - 0
package.json

@@ -79,6 +79,7 @@
     "eslint-plugin-react": "^7.30.1",
     "eslint-plugin-react-hooks": "^4.6.0",
     "eslint-plugin-rulesdir": "^0.2.2",
+    "eslint-plugin-vitest": "^0.2.3",
     "glob": "^8.1.0",
     "jest": "^28.1.3",
     "jest-date-mock": "^1.0.8",

+ 5 - 0
packages/core/.eslintrc.js

@@ -0,0 +1,5 @@
+module.exports = {
+  extends: [
+    'plugin:vitest/recommended',
+  ],
+};

+ 0 - 63
packages/core/jest.config.js

@@ -1,63 +0,0 @@
-// For a detailed explanation regarding each configuration property, visit:
-// https://jestjs.io/docs/en/configuration.html
-
-const MODULE_NAME_MAPPING = {
-  '^~/(.+)$': '<rootDir>/src/$1',
-};
-
-module.exports = {
-
-  transform: {
-    '^.+\\.(js|jsx|ts|tsx)$': '@swc/jest',
-  },
-  transformIgnorePatterns: [],
-
-  moduleNameMapper: MODULE_NAME_MAPPING,
-
-  // Automatically clear mock calls and instances between every test
-  clearMocks: true,
-
-  // Indicates whether the coverage information should be collected while executing the test
-  collectCoverage: true,
-
-  // An array of glob patterns indicating a set of files for which coverage information should be collected
-  // collectCoverageFrom: undefined,
-
-  // The directory where Jest should output its coverage files
-  coverageDirectory: 'coverage',
-
-  // An array of regexp pattern strings used to skip coverage collection
-  coveragePathIgnorePatterns: [
-    '/node_modules/',
-  ],
-
-  // An object that configures minimum threshold enforcement for coverage results
-  // TODO: activate -- 2020.03.24 Yuki Takei
-  // coverageThreshold: {
-  //   global: {
-  //     branches: 70,
-  //     functions: 70,
-  //     lines: 70,
-  //     statements: 70,
-  //   },
-  // },
-
-  // An array of file extensions your modules use
-  moduleFileExtensions: [
-    'js',
-    'json',
-    'jsx',
-    'ts',
-    'tsx',
-    'node',
-  ],
-
-  // The test environment that will be used for testing
-  testEnvironment: 'node',
-
-  // The glob patterns Jest uses to detect test files
-  testMatch: [
-    '**/test/**/__tests__/**/*.[jt]s?(x)',
-    '**/test/**/?(*.)+(spec|test).[jt]s?(x)',
-  ],
-};

+ 1 - 1
packages/core/package.json

@@ -20,7 +20,7 @@
     "lint:js": "yarn eslint **/*.{js,ts}",
     "lint:typecheck": "tsc",
     "lint": "npm-run-all -p lint:*",
-    "test": "jest --verbose"
+    "test": "vitest"
   },
   "// comments for dependencies": {
     "escape-string-regexp": "5.0.0 or above exports only ESM"

+ 7 - 0
packages/core/vitest.config.unit.ts

@@ -0,0 +1,7 @@
+import { defineProject } from 'vitest/config';
+
+export default defineProject({
+  test: {
+    environment: 'node',
+  },
+});

+ 8 - 1
yarn.lock

@@ -4227,7 +4227,7 @@
     semver "^7.3.7"
     tsutils "^3.21.0"
 
-"@typescript-eslint/utils@5.59.7":
+"@typescript-eslint/utils@5.59.7", "@typescript-eslint/utils@^5.59.2":
   version "5.59.7"
   resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.7.tgz#7adf068b136deae54abd9a66ba5a8780d2d0f898"
   integrity sha512-yCX9WpdQKaLufz5luG4aJbOpdXf/fjwGMcLFXZVPUz3QqLirG5QcwwnIHNf8cjLjxK4qtzTO8udUtMQSAToQnQ==
@@ -7798,6 +7798,13 @@ eslint-plugin-rulesdir@^0.2.2:
   resolved "https://registry.yarnpkg.com/eslint-plugin-rulesdir/-/eslint-plugin-rulesdir-0.2.2.tgz#84756ec39cd8503b1fe8af6a02a5da361e2bd076"
   integrity sha512-qhBtmrWgehAIQeMDJ+Q+PnOz1DWUZMPeVrI0wE9NZtnpIMFUfh3aPKFYt2saeMSemZRrvUtjWfYwepsC8X+mjQ==
 
+eslint-plugin-vitest@^0.2.3:
+  version "0.2.3"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-vitest/-/eslint-plugin-vitest-0.2.3.tgz#3524e72630231c68dc85651adf26422f8d116ceb"
+  integrity sha512-eqyiIY0Hhyp/2+AgNDDFrVhVT0hSXMbAyjFLB87E5CCHxelH9eNrJZe9qVElPPVpuJ201nQ/wmUupaO5EguxKQ==
+  dependencies:
+    "@typescript-eslint/utils" "^5.59.2"
+
 eslint-restricted-globals@^0.1.1:
   version "0.1.1"
   resolved "https://registry.yarnpkg.com/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz#35f0d5cbc64c2e3ed62e93b4b1a7af05ba7ed4d7"