From cde013d3cfee8fc0212905e29f0cd26e3dabb66c Mon Sep 17 00:00:00 2001 From: wangxingkang Date: Thu, 9 May 2024 23:19:57 +0800 Subject: [PATCH] chore: add test:e2e scripts --- .dockerignore | 2 ++ .gitignore | 2 -- .npmrc | 2 -- .vscode/extensions.json | 13 +++++++++++ .vscode/settings.json | 49 +++++++++++++++++++++++++++++++++++++++++ cypress.config.ts | 14 ++++++++++++ cypress/tsconfig.json | 12 ++++++++++ eslint.config.js | 12 +++++----- package.json | 2 ++ pnpm-lock.yaml | 12 ++++++++++ 10 files changed, 111 insertions(+), 9 deletions(-) create mode 100644 .dockerignore create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 cypress.config.ts create mode 100644 cypress/tsconfig.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f06235c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +node_modules +dist diff --git a/.gitignore b/.gitignore index 2fd7615..3076285 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,6 @@ dist-ssr stats.html # Editor directories and files -.vscode/* -!.vscode/extensions.json .idea .DS_Store *.suo diff --git a/.npmrc b/.npmrc index 18e7963..cf04042 100644 --- a/.npmrc +++ b/.npmrc @@ -1,4 +1,2 @@ shamefully-hoist=true strict-peer-dependencies=false -side-effects-cache=false -shell-emulator=true diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..d066795 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,13 @@ +{ + "recommendations": [ + "antfu.iconify", + "antfu.unocss", + "antfu.vite", + "antfu.goto-alias", + "csstools.postcss", + "dbaeumer.vscode-eslint", + "vue.volar", + "lokalise.i18n-ally", + "streetsidesoftware.code-spell-checker" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5ae5db3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,49 @@ +{ + // Enable the ESlint flat config support + "eslint.experimental.useFlatConfig": true, + + // Disable the default formatter, use eslint instead + "prettier.enable": false, + "editor.formatOnSave": false, + + // "stylelint.enable": true, + // "stylelint.validate": ["css", "less"], + + // Auto fix + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + // "source.fixAll.stylelint": "explicit", + "source.organizeImports": "never" + }, + + // Silent the stylistic rules in you IDE, but still auto fix them + "eslint.rules.customizations": [ + { "rule": "style/*", "severity": "off" }, + { "rule": "format/*", "severity": "off" }, + { "rule": "*-indent", "severity": "off" }, + { "rule": "*-spacing", "severity": "off" }, + { "rule": "*-spaces", "severity": "off" }, + { "rule": "*-order", "severity": "off" }, + { "rule": "*-dangle", "severity": "off" }, + { "rule": "*-newline", "severity": "off" }, + { "rule": "*quotes", "severity": "off" }, + { "rule": "*semi", "severity": "off" } + ], + + // Enable eslint for all supported languages + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "html", + "markdown", + "json", + "jsonc", + "yaml", + "toml", + "gql", + "graphql" + ] +} diff --git a/cypress.config.ts b/cypress.config.ts new file mode 100644 index 0000000..e61db9a --- /dev/null +++ b/cypress.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from 'cypress' +import vitePreprocessor from 'cypress-vite' + +export default defineConfig({ + e2e: { + baseUrl: 'http://localhost:3333', + chromeWebSecurity: false, + specPattern: 'cypress/e2e/**/*.spec.*', + supportFile: false, + setupNodeEvents(on) { + on('file:preprocessor', vitePreprocessor()) + }, + }, +}) diff --git a/cypress/tsconfig.json b/cypress/tsconfig.json new file mode 100644 index 0000000..c8eb88f --- /dev/null +++ b/cypress/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "types": [ + "cypress" + ] + }, + "include": [ + "**/*.ts" + ], + "exclude": [] +} diff --git a/eslint.config.js b/eslint.config.js index 9fa644f..6fb29db 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,10 +1,12 @@ -import antfu from '@antfu/eslint-config' +import antfu from '@antfu/eslint-config'; export default antfu( { react: true, + unocss: true, + formatters: true, stylistic: { - semi: true - } - } -) + semi: true, + }, + }, +); diff --git a/package.json b/package.json index 9bc42e7..a3cd63a 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "build": "tsc && vite build", "deploy": "gh-pages -d dist -b gh-pages -f", "test": "vitest", + "test:e2e": "cypress open", "test:cov": "vitest run --coverage", "typecheck": "tsc --noEmit", "lint": "eslint --cache .", @@ -65,6 +66,7 @@ "cypress": "^13.8.1", "cypress-vite": "^1.5.0", "eslint": "^8.57.0", + "eslint-plugin-cypress": "^3.2.0", "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-refresh": "^0.4.6", "gh-pages": "^6.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b2f301..354b098 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -115,6 +115,9 @@ devDependencies: eslint: specifier: ^8.57.0 version: 8.57.0 + eslint-plugin-cypress: + specifier: ^3.2.0 + version: 3.2.0(eslint@8.57.0) eslint-plugin-react-hooks: specifier: ^4.6.2 version: 4.6.2(eslint@8.57.0) @@ -5445,6 +5448,15 @@ packages: eslint: 8.57.0 dev: true + /eslint-plugin-cypress@3.2.0(eslint@8.57.0): + resolution: {integrity: sha512-HaxMz6BoU4ay+K4WrG9ZJC1NdX06FqSlAwtRDStjM0ORFT7zCNPNuRJ+kUPc17Rt2AMUBSqeD9L0zTR3uZhPpw==} + peerDependencies: + eslint: '>=7' + dependencies: + eslint: 8.57.0 + globals: 13.24.0 + dev: true + /eslint-plugin-es-x@7.6.0(eslint@8.57.0): resolution: {integrity: sha512-I0AmeNgevgaTR7y2lrVCJmGYF0rjoznpDvqV/kIkZSZbZ8Rw3eu4cGlvBBULScfkSOCzqKbff5LR4CNrV7mZHA==} engines: {node: ^14.18.0 || >=16.0.0}