NativeScript / NativeScript/nativescript-cli

tns test fails with error "ReferenceError: Can't find variable: Zone"

未关闭
#3,303 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

to-be-checked unit testing
主要语言
JavaScript
星标
1.1k
派生
204
平均合并
1 天 9 小时
30 天内合并 PR
8

描述

Tell us about the problem

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

Which platform(s) does your issue occur on?

iOS, Android

Please provide the following version numbers that your issue occurs with:
  • CLI: (run tns --version to fetch it)
    3.4.0

  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)
    3.3.0

  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the
    package.json file of your project)
    3.0.0

Please tell us how to recreate the issue in as much detail as possible.
  • Build a service that requires injection of TranslateService (from ng-translate)
  • Inject that service in beforeEach() of a test suite.
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

error.service.test.ts

'use strict';

import {ErrorService} from '../services/error.service';
import {inject} from "@angular/core/testing";

declare let assert: Chai.AssertStatic;

describe("ErrorService tests", () => {

    let service = null;

    beforeEach((done) => {
        inject([ErrorService], (injectService: ErrorService) => {
            service = injectService;
            done();
        });
    });

    it("Service exists", (done) => {
        assert.exists(service);
        done();
    });

});

error.service.ts

import { Injectable } from "@angular/core";
import { TranslateService } from "ng2-translate";

@Injectable()
export class ErrorService {

    constructor(private i18n: TranslateService) {
    }
}

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用为 CLI、模块和运行时列出的版本,重现报告的 tns 测试失败。阅读 error.service.test.ts 和 error.service.ts,重点关注 beforeEach() 中的 Angular 测试注入。完成的标准是服务测试在 iOS 和 Android 上都能运行,且不会出现关于 Zone 的 ReferenceError。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, javascript
领域
cli, mobile, testing
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。