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

[Bug Report]: pnpm run test 报错 #1945

Open
Yuan-ZW opened this issue Nov 4, 2024 · 5 comments
Open

[Bug Report]: pnpm run test 报错 #1945

Yuan-ZW opened this issue Nov 4, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Yuan-ZW
Copy link
Contributor

Yuan-ZW commented Nov 4, 2024

发生了什么?

node: v20.10.0
pnpm: 9.12.1
仓库版本: e9f097c

完整日志:

Windows PowerShell
版权所有(CMicrosoft Corporation。保留所有权利。

安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows

PS D:\projects\js> git clone -b yzw/fix/cross-point-with-polygon https://github.com/Yuan-ZW/LogicFlow.git
Cloning into 'LogicFlow'...
remote: Enumerating objects: 24136, done.
remote: Counting objects: 100% (72/72), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 24136 (delta 27), reused 61 (delta 27), pack-reused 24064 (from 1)
Receiving objects: 100% (24136/24136), 81.72 MiB | 3.89 MiB/s, done.
Resolving deltas: 100% (15002/15002), done.
Updating files: 100% (1018/1018), done.
PS D:\projects\js> cd .\LogicFlow\
PS D:\projects\js\LogicFlow> pnpm i
Scope: all 13 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +3378
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Downloading antd@5.19.4: 9.68 MB/9.68 MB, done
Downloading typescript@5.4.5: 5.83 MB/5.83 MB, done
Downloading @swc/core-win32-x64-msvc@1.4.2: 16.52 MB/16.52 MB, done
Downloading turbo-windows-64@2.0.9: 10.95 MB/10.95 MB, done
Downloading element-plus@2.7.8: 8.62 MB/8.62 MB, done
Downloading echarts@5.5.1: 10.36 MB/10.36 MB, done
Downloading @tabler/icons@1.119.0: 19.58 MB/19.58 MB, done
Downloading next@14.2.3: 20.66 MB/20.66 MB, done
Downloading @next/swc-win32-x64-msvc@14.2.3: 41.47 MB/41.47 MB, done
Downloading monaco-editor@0.25.2: 14.99 MB/14.99 MB, done
Downloading antd@4.24.16: 8.75 MB/8.75 MB, done
Downloading @formatjs/intl-displaynames@6.6.8: 6.00 MB/6.00 MB, done
Progress: resolved 3378, reused 0, downloaded 3222, added 3378, done
node_modules/.pnpm/core-js@3.34.0/node_modules/core-js: Running postinstall script, done in 987ms
node_modules/.pnpm/core-js-pure@3.37.1/node_modules/core-js-pure: Running postinstall script, done in 987ms
node_modules/.pnpm/@swc+core@1.4.2_@swc+helpers@0.5.5/node_modules/@swc/core: Running postinstall script, done in 1.6s
node_modules/.pnpm/esbuild@0.21.4/node_modules/esbuild: Running postinstall script...
node_modules/.pnpm/esbuild@0.21.4/node_modules/esbuild: Running postinstall script, done in 4.6s
node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild: Running postinstall script, done in 4.3s
node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild: Running postinstall script...
node_modules/.pnpm/core-js@3.37.1/node_modules/core-js: Running postinstall script, done in 3.1s@3.4.34_typescript@5.4.5_/node_modules/vue-demi: Running postinstall script...
node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild: Running postinstall script, done in 4.5s@3.4.34_typescript@5.4.5_/node_modules/vue-demi: Running postinstalnode_modules/.pnpm/@vercel+speed-insights@1.0.12_next@14.2.3_@babel+core@7.25.2_babel-plugin-macros@3.1.0_react-_qytz2clasdjbv5zdvaenq4yuva/node_modules/@vercel/speed-insights: Running postinstall script, done in 2.4s

dependencies:
+ lodash-es 4.17.21

devDependencies:
+ @babel/core 7.25.2
+ @babel/plugin-proposal-decorators 7.24.7
+ @babel/plugin-transform-class-properties 7.24.7
+ @babel/plugin-transform-react-jsx 7.25.2
+ @babel/preset-env 7.25.2
+ @babel/preset-react 7.24.7
+ @babel/preset-typescript 7.24.7
+ @changesets/cli 2.27.7
+ @commitlint/cli 17.8.1
+ @commitlint/config-conventional 17.8.1
+ @jest/globals 29.7.0
+ @rollup/plugin-alias 5.1.0
+ @rollup/plugin-babel 6.0.4
+ @rollup/plugin-commonjs 23.0.7
+ @rollup/plugin-node-resolve 15.2.3
+ @rollup/plugin-replace 5.0.7
+ @rollup/plugin-terser 0.4.4
+ @rollup/plugin-typescript 10.0.1
+ @types/jest 29.5.12
+ @types/lodash-es 4.17.12
+ @types/node 20.14.13
+ @typescript-eslint/eslint-plugin 6.21.0
+ @typescript-eslint/parser 6.21.0
+ boxen 7.1.1
+ colors 1.4.0
+ eslint 8.57.0
+ eslint-config-prettier 9.1.0
+ eslint-plugin-import 2.29.1
+ eslint-plugin-prettier 5.2.1
+ fs-extra 11.2.0
+ husky 8.0.3
+ is-ci 3.0.1
+ jest 29.7.0
+ less 4.2.0
+ lint-staged 14.0.1
+ lodash 4.17.21
+ npm-run-all 4.1.5
+ postcss 8.4.40
+ postcss-import 16.1.0
+ postcss-less 6.0.0
+ prettier 3.3.3
+ pretty-quick 3.3.1
+ rimraf 5.0.9
+ rollup 4.21.0
+ rollup-plugin-filesize 10.0.0
+ rollup-plugin-polyfill-node 0.12.0
+ rollup-plugin-postcss 4.0.2
+ rollup-plugin-visualizer 5.12.0
+ run-shared-scripts 1.1.5
+ stylelint 15.11.0
+ stylelint-config-prettier 9.0.5
+ stylelint-config-rational-order 0.1.2
+ stylelint-config-standard 34.0.0
+ stylelint-order 6.0.4
+ ts-jest 29.2.3
+ tslib 2.6.3
+ turbo 2.0.9
+ typescript 5.4.5

. prepare$ is-ci || run-p setup:husky build
[199 lines collapsed]
│ @logicflow/extension:build: |   Destination: dist/index.min.js   |
│ @logicflow/extension:build: |   Bundle   Size: 443.32 KB         |
│ @logicflow/extension:build: |   Minified Size: 441.54 KB         |
│ @logicflow/extension:build: |   GZipped  Size: 127.32 KB         |
│ @logicflow/extension:build: |                                    |
│ @logicflow/extension:build: +------------------------------------+
│ @logicflow/extension:build: created dist/index.min.js in 28.2s
│  Tasks:    6 successful, 6 total
│ Cached:    0 cached, 6 total
│   Time:    1m58.356s
└─ Done in 2m 3.5s
examples/feature-examples postinstall$ umi setupinfo  - [你知道吗?] ANALYZE=1 umi build 可以分析产物的源码构成。
│ info  - generate filesinfo  - Preparing...
└─ Done in 4.4s
Done in 19m 37s
PS D:\projects\js\LogicFlow> pnpm run test

> logicflow@ test D:\projects\js\LogicFlow
> jest

Test Suites: 0 of 33 total
Tests:       0 total
Snapshots:   0 total
Time:        1.498 s
Ran all test suites.
SyntaxError: D:\projects\js\LogicFlow\node_modules\.pnpm\jest-runner@29.7.0\node_modules\jest-runner\build\index.js: Class private methods are not enabled. Please add `@babel/plugin-transform-private-methods` to your configuration.
  71 |       : this.#createParallelTestRun(tests, watcher);
  72 |   }
> 73 |   async #createInBandTestRun(tests, watcher) {
     |   ^
  74 |     process.env.JEST_WORKER_ID = '1';
  75 |     const mutex = (0, _pLimit().default)(1);
  76 |     return tests.reduce(
    at File.buildCodeFrameError (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+core@7.25.2\node_modules\@babel\core\lib\transformation\file\file.js:195:12)
    at NodePath.buildCodeFrameError (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\path\index.js:116:21)
    at shouldTransform (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+helper-create-class-features-plugin@7.25.0_@babel+core@7.25.2\node_modules\@babel\helper-create-class-features-plugin\lib\features.js:130:29)
    at PluginPass.Class (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+helper-create-class-features-plugin@7.25.0_@babel+core@7.25.2\node_modules\@babel\helper-create-class-features-plugin\lib\index.js:112:44)
    at newFn (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\visitors.js:162:14)
    at NodePath._call (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\path\context.js:49:20)
    at NodePath.call (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\path\context.js:39:18)
    at NodePath.visit (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\path\context.js:85:31)
    at TraversalContext.visitQueue (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\context.js:89:16)
    at TraversalContext.visitMultiple (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\context.js:61:17)
    at TraversalContext.visit (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\context.js:110:19)
    at traverseNode (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at NodePath.visit (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\path\context.js:91:52)
    at TraversalContext.visitQueue (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\context.js:89:16)
    at TraversalContext.visitSingle (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\context.js:65:19)
    at TraversalContext.visit (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\context.js:112:19)
    at traverseNode (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at traverse (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+traverse@7.25.2\node_modules\@babel\traverse\lib\index.js:53:34)
    at transformFile (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+core@7.25.2\node_modules\@babel\core\lib\transformation\index.js:82:31)
    at transformFile.next (<anonymous>)
    at run (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+core@7.25.2\node_modules\@babel\core\lib\transformation\index.js:24:12)
    at run.next (<anonymous>)
    at transform (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+core@7.25.2\node_modules\@babel\core\lib\transform.js:22:33)
    at transform.next (<anonymous>)
    at evaluateSync (D:\projects\js\LogicFlow\node_modules\.pnpm\gensync@1.0.0-beta.2\node_modules\gensync\index.js:251:28)
    at sync (D:\projects\js\LogicFlow\node_modules\.pnpm\gensync@1.0.0-beta.2\node_modules\gensync\index.js:89:14)
    at stopHiding - secret - don't use this - v1 (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+core@7.25.2\node_modules\@babel\core\lib\errors\rewrite-stack-trace.js:47:12)
    at transformSync (D:\projects\js\LogicFlow\node_modules\.pnpm\@babel+core@7.25.2\node_modules\@babel\core\lib\transform.js:42:76)
    at Object.process (D:\projects\js\LogicFlow\node_modules\.pnpm\babel-jest@29.7.0_@babel+core@7.25.2\node_modules\babel-jest\build\index.js:273:57)
    at ScriptTransformer.transformSource (D:\projects\js\LogicFlow\node_modules\.pnpm\@jest+transform@29.7.0\node_modules\@jest\transform\build\ScriptTransformer.js:545:31)
    at revertHook.exts (D:\projects\js\LogicFlow\node_modules\.pnpm\@jest+transform@29.7.0\node_modules\@jest\transform\build\ScriptTransformer.js:776:18)
    at Module._compile (D:\projects\js\LogicFlow\node_modules\.pnpm\pirates@4.0.6\node_modules\pirates\lib\index.js:113:29)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.newLoader (D:\projects\js\LogicFlow\node_modules\.pnpm\pirates@4.0.6\node_modules\pirates\lib\index.js:121:7)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at requireOrImportModule (D:\projects\js\LogicFlow\node_modules\.pnpm\jest-util@29.7.0\node_modules\jest-util\build\requireOrImportModule.js:44:28)
    at ScriptTransformer.requireAndTranspileModule (D:\projects\js\LogicFlow\node_modules\.pnpm\@jest+transform@29.7.0\node_modules\@jest\transform\build\ScriptTransformer.js:798:66)
    at D:\projects\js\LogicFlow\node_modules\.pnpm\@jest+core@29.7.0_babel-plugin-macros@3.1.0_ts-node@10.9.2_@swc+core@1.4.2_@types+node@20.14.13_typescript@5.4.5_\node_modules\@jest\core\build\TestScheduler.js:224:46
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async TestScheduler.scheduleTests (D:\projects\js\LogicFlow\node_modules\.pnpm\@jest+core@29.7.0_babel-plugin-macros@3.1.0_ts-node@10.9.2_@swc+core@1.4.2_@types+node@20.14.13_typescript@5.4.5_\node_modules\@jest\core\build\TestScheduler.js:217:7)
    at async runJest (D:\projects\js\LogicFlow\node_modules\.pnpm\@jest+core@29.7.0_babel-plugin-macros@3.1.0_ts-node@10.9.2_@swc+core@1.4.2_@types+node@20.14.13_typescript@5.4.5_\node_modules\@jest\core\build\runJest.js:367:19)
    at async _run10000 (D:\projects\js\LogicFlow\node_modules\.pnpm\@jest+core@29.7.0_babel-plugin-macros@3.1.0_ts-node@10.9.2_@swc+core@1.4.2_@types+node@20.14.13_typescript@5.4.5_\node_modules\@jest\core\build\cli\index.js:343:7)
    at async runCLI (D:\projects\js\LogicFlow\node_modules\.pnpm\@jest+core@29.7.0_babel-plugin-macros@3.1.0_ts-node@10.9.2_@swc+core@1.4.2_@types+node@20.14.13_typescript@5.4.5_\node_modules\@jest\core\build\cli\index.js:198:3)
    at async Object.run (D:\projects\js\LogicFlow\node_modules\.pnpm\jest-cli@29.7.0_@types+node@20.14.13_babel-plugin-macros@3.1.0_ts-node@10.9.2_@swc+core@1.4.2_ulof4mg72c4flfd6zowe63wde4\node_modules\jest-cli\build\run.js:130:37)
 ELIFECYCLE  Test failed. See above for more details.
PS D:\projects\js\LogicFlow>

logicflow/core版本

2.0.6

logicflow/extension版本

2.0.10

logicflow/engine版本

No response

浏览器&环境

No response

@Yuan-ZW Yuan-ZW added the bug Something isn't working label Nov 4, 2024
@DymoneLewis
Copy link
Collaborator

看起来是少了个依赖,导致报错了,您可以直接本地安装上看看
不过现在内部的包还没有构建完整的测试用例,你run test的诉求是什么呢🤔

@Yuan-ZW
Copy link
Contributor Author

Yuan-ZW commented Nov 5, 2024

就是我发现个bug,原本想按你们的PR规范里的步骤提个pr

具体bug就是polyline和菱形(多边形)的交点问题:
动画

我翻了下源码,发现你们其实有相应的实现
不过由于这段代码逻辑不严谨导致功能没生效:

/* 判断一个点是否在线段中
入参点:point, 线段起终点,start,end,
返回值: 在线段中true,否则false
*/
export const isInSegment = (point: Point, start: Point, end: Point) => {
const { x, y } = point
const { x: startX, y: startY } = start
const { x: endX, y: endY } = end
const k = (endY - startY) / (endX - startX)
const b = startY - k * startX
return (
x >= startX &&
x <= endX &&
y >= startY &&
y <= endY &&
Math.abs(y - k * x + b) < Number.EPSILON
)
}

想改一下这个函数,还有它对应的测试用例

@DymoneLewis
Copy link
Collaborator

了解😄,升2.0之后 test 指令的逻辑还没来得及加上,这个pr我们今天看下

@Yuan-ZW
Copy link
Contributor Author

Yuan-ZW commented Nov 8, 2024

解决了依赖问题后还有新的报错:

PS D:\projects\js\LogicFlow> pnpm test -- packages\core\__tests__\algorithm\egde.test.ts

> logicflow@ test D:\projects\js\LogicFlow
> jest "packages\\core\\__tests__\\algorithm\\egde.test.ts"

 FAIL  packages/core/__tests__/algorithm/egde.test.ts
  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'Point')

       7 | import { GraphModel, BezierEdgeModel } from '../../model'
       8 |
    >  9 | import Point = LogicFlow.Point
         |                          ^
      10 |
      11 | type IProps = {
      12 |   graphModel: GraphModel

      at Object.Point (packages/core/src/view/overlay/BezierAdjustOverlay.tsx:9:26)
      at Object.require (packages/core/src/view/overlay/index.ts:2:1)
      at Object.require (packages/core/src/options.ts:6:1)
      at Object.require (packages/core/src/util/animation.ts:2:1)
      at Object.require (packages/core/src/util/index.ts:1:1)
      at Object.require (packages/core/src/index.ts:5:1)
      at Object.require (packages/core/src/LogicFlow.tsx:3:1)
      at Object.require (packages/core/src/algorithm/edge.ts:1:1)
      at Object.require (packages/core/__tests__/algorithm/egde.test.ts:1:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        5.274 s
Ran all test suites matching /packages\\core\\__tests__\\algorithm\\egde.test.ts/i.
 ELIFECYCLE  Test failed. See above for more details.
PS D:\projects\js\LogicFlow> 

有点怀疑是不是循环引用的原因🤔

@boyongjiong
Copy link
Collaborator

test 目前是有问题的,需要治理一下哈哈,我们今年没抽出时间搞这个,明年应该会专门搞个专项来做测试用例完善

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants