Skip to content

Latest commit

 

History

History
64 lines (55 loc) · 1.66 KB

File metadata and controls

64 lines (55 loc) · 1.66 KB

banner


Vitest 的 uni-app e2e 测试环境

Important

该项目依赖 @dcloudio/uni-automator

h5 平台下,需要安装 playwright ; 但目前无法获取启动状态导致超时

environmentOptions 参数同 uni-app 官方文档 , 但官网长久未更新,导致参数与实际不符

安装

pnpm i -D vitest-environment-uniapp

使用

pnpm test

package.json

{
  "scripts": {
    "test": "vitest"
  }
}

vitest.config.ts

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    environment: 'uniapp',
    environmentOptions: {
      uniapp: {
        compile: true,
        platform: 'mp-weixin',
        projectPath: './src',
        port: 5121,
      }
    },
  },
})

tsconfig.json

{
  "compilerOptions": {
    "types": [
      "vitest-environment-uniapp/types"
    ]
  }
}