Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复framework的错误信息 #16304

Open
wants to merge 1 commit into
base: feat/test-optimize
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions packages/taro-cli/src/__tests__/doctor-config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as helper from '@tarojs/helper'

import doctor from '../doctor'
import { validateFramework } from './utils/index'

const validator = doctor.validators[1]
const baseConfig = {
Expand Down Expand Up @@ -49,7 +50,7 @@ describe('config validator of doctor', () => {

expect(messages.length).toEqual(3)
msgs = messages.map(line => line.content)
expect(msgs.includes('framework 的值 "" 与任何指定选项 ["nerv","react","preact","solid","vue","vue3","none"] 都不匹配')).toBeTruthy()
expect(validateFramework(msgs)).toBeTruthy()
})

it('date', async () => {
Expand Down Expand Up @@ -93,7 +94,7 @@ describe('config validator of doctor', () => {
framework: 'other'
}))
expect(res.messages.length).toEqual(3)
expect(res.messages[2].content).toEqual('framework 的值 "other" 与任何指定选项 ["nerv","react","preact","solid","vue","vue3","none"] 都不匹配')
expect(validateFramework(res.messages[2].content)).toEqual(true)
})

it('designWidth', async () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/taro-cli/src/__tests__/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ export function run (name: string, presets: string[] = []): IRun {
return kernel
}
}

export function validateFramework(value: string) {
const frameworkRegex = /(nerv|react|preact|solid|vue|vue3|none)/
return frameworkRegex.test(value)
}