【问题标题】:Nativescript testing - tests/example.ts is missing from the TypeScript compilationNativescript 测试 - TypeScript 编译中缺少 tests/example.ts
【发布时间】:2020-01-08 23:24:39
【问题描述】:

我有一个 Angular 风格的 Nativescript 项目。

按照https://docs.nativescript.org/tooling/testing/testing 的步骤后,我遇到了以下错误:

./src/tests/example.ts 中的错误模块构建失败(来自 ../node_modules/@ngtools/webpack/src/index.js):错误: TypeScript 中缺少 /home/..../src/tests/example.ts 汇编。请通过“文件”确保它在您的 tsconfig 中 或“包含”属性。

我做的步骤:

  1. tns test init - 输入茉莉花
  2. npm i @types/jasmine --save-dev
  3. 启动我的安卓模拟器
  4. tns run android

您可以看到生成的示例测试文件不起作用,但是我没有在网站上阅读有关修改 tsconfig.json 的任何内容。

【问题讨论】:

    标签: nativescript angular2-nativescript


    【解决方案1】:

    一种可能的解决方案是……完全按照错误消息的说明进行操作。

    插入后:

    "include": ["src/tests/**/*.ts"]
    

    tsconfig.json(或tsconfig.tns.json),测试运行没有问题。

    虽然我认为这意味着,这个文件被包含在每个构建中(不仅仅是测试运行),所以还不是最好的解决方案。仅在 tsconfig.spec.json 中包含这一行也无济于事,看来我必须为生产准备一个不同的构建,其中不包含这个。

    【讨论】:

      猜你喜欢
      • 2019-01-05
      • 1970-01-01
      • 2018-10-01
      • 2020-11-26
      • 2018-08-12
      • 2018-11-23
      • 1970-01-01
      • 2021-02-12
      • 2021-02-23
      相关资源
      最近更新 更多