alibaba / x-render

🚴‍♀️ 阿里 - 很易用的中后台「表单 / 表格 / 图表」解决方案
https://xrender.fun
6.98k stars 988 forks source link

Vitest测试基于FormRender的组件失败 #1378

Open DevanXU opened 1 year ago

DevanXU commented 1 year ago

1.依赖仓库的版本(Dependencies versions):

2.问题描述(Bug description): vitest测试基于FormRender的组件失败

3.出现问题的 schema demo(Reproduction schema demo)

const schema = {
  // schema包含在以下repo源码中
}

4.最小复现 demo(Reproduction demo)https://github.com/DevanXU/form-render-issue

运行 $ yarn test 即可复现

form-render demo https://codesandbox.io/s/unruffled-flower-jl78h table-render demo https://codesandbox.io/s/sweet-euler-bdoty fr-generator demo https://codesandbox.io/s/s13sh

lhbxs commented 1 year ago

没有太关注单测这边,单测用列,也没有及时更新,现在卡点问题是什么呢?

DevanXU commented 1 year ago

无法跑单测啊,连带与FormRender无关的组件都可能失败。出现下面这个错误,在我提供的Demo可以复现这个问题的。

FAIL src/ConfigBox.test.tsx [ src/ConfigBox.test.tsx ] SyntaxError: Cannot use import statement outside a module ❯ Object.compileFunction node:vm:360:18 ❯ Object. node_modules/form-render/lib/form-core/index.js:8:1

Module /Users/devan/src/tmp/formrender/node_modules/antd/es/button/style/index.js:1 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "antd" asking them to ship the file in .mjs extension or add "type": "module" in their package.json.

As a temporary workaround you can try to inline the package by updating your config:

// vitest.config.js export default { test: { server: { deps: { inline: [ "antd" ] } } } }