zoukankan      html  css  js  c++  java
  • Angular测试遇到的小坑

    Angular测试遇到的小坑

    Error: Expected to be running in 'ProxyZone', but it was not found

      检查doneFn的写法是否正确,位置是否正确,是否定义为undefined

    Unhandled Promise rejection: 'expect' was used when there was no current spec - Google Search

      检查donfFn或者asyn是否使用正确,如果是测试异步方法,expect方法是否包含在asyn或者有donfFn的函数里面

    fail() 调用了,但是却pass了

      检查console中是否有异常

    dondFn的用法

      done(): 执行这个表示成功

      done.fail(err): 执行这个表示失败,参数可以是异常err或者文本

     beforeAll((done:DoneFn)=>{
          TestBed.configureTestingModule({
            imports: [HttpClientModule],
            providers: [ProjectResourceService]
          });
        })
      beforeAll((done:DoneFn)=>{
          
          TestBed.configureTestingModule({
            imports: [HttpClientModule]
          });
          http = TestBed.get(HttpClient);
          
          auth(http).then(()=>{
              done();
          });
        });
    

      



      beforeAll中配置TestBed.configureTestingModule报错:Error: Cannot configure the test module when the test module has already been instantiated. Make sure you are not using `inject` before

      目前还没搞清楚,我在的问题是将HttpClientModule在beforeAll中导入就会报这个错。我的解决办法是不用HttpClient,从网上找了个xhr的简单封装。

  • 相关阅读:
    HTML5学习记录
    CSS学习记录
    HTML扩展(thead,tbody,tfoot标签的使用)
    测删除功能
    jmeter-连接数据库
    jmeter-正则表达式提取器
    jmeter常用函数
    java基础(二)
    git基本使用
    波特的钻石模型
  • 原文地址:https://www.cnblogs.com/yoyogis/p/9215052.html
Copyright © 2011-2022 走看看