Jest ionic 6 Angular 14 @awsome cordova lib 错误任何人请帮助设置 jest

问题描述 投票:0回答:1

我在 @awrsome-cordova 库上遇到 ionic 6 Angular 14 Jest 设置错误

这是我的错误,任何人都可以帮助我进行正确的玩笑设置

npm test
ts-jest[ts-jest-transformer] (WARN) Define `ts-jest` config under `globals` is deprecated. Please do
transform: {
    <transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],
},
 FAIL  src/app/pages/side-menu-exp/side-menu-exp.page.spec.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Details:
      \node_modules\@awesome-cordova-plugins\adjust\index.js:16
    import { AwesomeCordovaNativePlugin, cordova } from '@awesome-cordova-plugins/core';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

    > 13 | import { AdjustConfig, Adjust, AdjustEnvironment, AdjustLogLevel, AdjustEvent } from '@awesome-cordova-plugins/adjust'
         | ^
 

angular cordova ionic-framework jestjs ionic6
1个回答
0
投票

这个答案将为您指明正确的方向。

确保您已安装所有必需的软件包。您需要

jest
ts-jest
@types/jest
@angular-builders/jest
。您可以像这样使用 NPM 安装:

npm install --save-dev jest ts-jest @types/jest @angular-builders/jest

按照上面链接中的答案进行操作,您就可以开始了。

© www.soinside.com 2019 - 2024. All rights reserved.