【问题标题】:Typescript with Jest and Jasmine (tests pass, tslint fails)带有 Jest 和 Jasmine 的打字稿(测试通过,tslint 失败)
【发布时间】:2017-10-08 11:47:00
【问题描述】:

通过在我的测试文件顶部包含这一行,我通过了 jasmine(库测试)和 jest(快照测试)的测试:

/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />

// -> in my jest test files
/// <reference path="../../node_modules/@types/jest/index.d.ts" />

但是,当我运行 tslint 时,会出现重复错误,例如

ERROR in [at-loader] ./node_modules/@types/jest/index.d.ts:12:13
    TS2300: Duplicate identifier 'fdescribe'.

问题是我实际上无法排除 jasmine 和 jest 的 d.ts 文件,因为我需要它们进行测试,但我想将它们从我的 tslint 中排除...有没有办法配置它?我看到了一些问题,但没有发布真正的解决方案。

【问题讨论】:

    标签: typescript jestjs


    【解决方案1】:

    通过告诉我的 tsconfig 排除我的测试文件(以 spec.tsx 结尾)来管理它的工作

    "exclude": [
        "node_modules",
        "**/*.spec.tsx",
        // ... etc
    

    【讨论】:

      猜你喜欢
      • 2017-05-14
      • 2018-09-06
      • 2019-09-06
      • 1970-01-01
      • 2019-09-07
      • 2021-06-11
      • 1970-01-01
      • 1970-01-01
      • 2015-09-29
      相关资源
      最近更新 更多