网站搜索

typescript - allure-cypress 插件版本 3.0.7 以上在解析 allure-cypress\dist\cjs\index.js 时抛出意外的令牌


我升级到了3.0.7,并测试了allure-cypress插件的较新版本。当我运行测试脚本时,我收到以下错误:

Oops...we found an error preparing this test file:    > cypress\support\e2e.ts  The error was:  SyntaxError: Unexpected token (1:16307) while parsing C:\Users\USER\allure-cypress\dist\cjs\index.js while parsing file: C:\Users\USER\node_modules\allure-cypress\dist\cjs\index.js     at DestroyableTransform.end [as _flush]
(C:\Users\USER\node_modules\insert-module-globals\index.js:114:21)
    at DestroyableTransform.prefinish (C:\Users\USER\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:138:10)
    at DestroyableTransform.emit (node:events:513:28)
    at DestroyableTransform.emit (node:domain:489:12)
    at prefinish (C:\Users\USER\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:619:14)
    at finishMaybe (C:\Users\USER\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:627:5)
    at endWritable (C:\Users\USER\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:638:3)
    at DestroyableTransform.Writable.end (C:\Users\USER\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:594:22)
    at DestroyableTransform.onend (C:\Users\USER\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:627:28)
    at DestroyableTransform.emit (node:events:525:35)
    at DestroyableTransform.emit (node:domain:489:12)
    at endReadableNT (C:\Users\USER\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:1010:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)"  

3.0.5及以下版本运行良好。我使用的是Cypress和Cucumber框架,较新版本中对某些问题进行了修复,我需要这些修复以便报告在测试主体下包含正确的测试步骤。在我的e2e.ts文件中,我导入了该插件:

import "allure-cypress"

我尝试将路径添加到 allure-cypress 插件,并且还在 tsconfig.json 文件中的 'include' 中允许 .js 文件:

"include": [
"/*.ts",
"/*.js",
"./node_modules/cypress",
"./node_modules/allure-cypress/dist/cjs",
"./node_modules/allure-cypress"]

我还升级/更改了 package.json 文件中以下插件的版本,以检查是否是兼容性问题:

"cucumber": "latest" 
"@types/node": "latest" 
"allure-cypress": "^3.0.9" 
"typescript": "^5.4.5" 
"cypress": "^13.17.0"
"@badeball/cypress-cucumber-preprocessor": "^20.0.6"