Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 获取错误:意外值';未定义';由模块';动态测试模块';使用笑话+;观众角9_Angular_Jestjs_Angular9_Angular Unit Test_Angular Spectator - Fatal编程技术网

Angular 获取错误:意外值';未定义';由模块';动态测试模块';使用笑话+;观众角9

Angular 获取错误:意外值';未定义';由模块';动态测试模块';使用笑话+;观众角9,angular,jestjs,angular9,angular-unit-test,angular-spectator,Angular,Jestjs,Angular9,Angular Unit Test,Angular Spectator,我正在使用angular 9,并在深入研究后,替换了angular to Observator and jest的默认单元测试,这很有趣,而且我没有几个测试可以正常工作,但当我尝试测试某个父组件时,突然出现了这个问题,导致了我无法解决的丑陋错误(请参见问题标题),我会很高兴得到一些帮助,代码如下 其他类似的测试也在运行,但是这个测试在标题上得到了不友好的消息,即使我删除了模板的所有标记,只写了愚蠢的div,并且取消了测试上的模拟,我仍然得到了这个不友好的消息。。。尝试在没有帮助的情况下重新启动服

我正在使用angular 9,并在深入研究后,替换了angular to Observator and jest的默认单元测试,这很有趣,而且我没有几个测试可以正常工作,但当我尝试测试某个父组件时,突然出现了这个问题,导致了我无法解决的丑陋错误(请参见问题标题),我会很高兴得到一些帮助,代码如下

其他类似的测试也在运行,但是这个测试在标题上得到了不友好的消息,即使我删除了模板的所有标记,只写了愚蠢的div,并且取消了测试上的模拟,我仍然得到了这个不友好的消息。。。尝试在没有帮助的情况下重新启动服务器

规格ts


    import { Spectator, createComponentFactory } from '@ngneat/spectator/jest';
    import { PlannerScreenComponent } from './planner-screen.component';
    import { SlotsListComponent } from '../planner/components/slots-list/slots-list.component';
    import { MockComponent } from 'ng-mocks';

    describe('PlannerScreenComponent suit', () => {
      let spectator: Spectator<PlannerScreenComponent>;
      const createComponent: () => Spectator<PlannerScreenComponent> = createComponentFactory({
        component: PlannerScreenComponent,
        declarations: [MockComponent(SlotsListComponent)]
      });

      beforeEach(() => (spectator = createComponent()));

      it('should create plannerScreenComponent ', () => {
        const plannerScreenComponent = spectator.component;
        expect(plannerScreenComponent).toBeTruthy();
      });
    });

component.html

    section [class.splitted-screen]="isSplittedScreen" class="planner-screen-wrapper">
          <aside class="left-ruller-container"></aside>
          <div class="top-middle-title">
            <div>title</div>
          </div>
          <div class="main-panel-container">
            <slots-list></slots-list>
          </div>
          <aside class="right-ruller-container"></aside>
        </section>
section[class.splittedscreen]=“isSplittedScreen”class=“planner screen wrapper”>
标题

在你的测试中,我听不懂这句话

declarations: [MockComponent(SlotsListComponent)]

您没有在PlannerScreen组件中使用SlotListComponent,所以没有必要在测试中模拟此组件。我认为,你可以自由地删除这一行。在此之后,测试正常。

我无法理解您测试中的这一行

declarations: [MockComponent(SlotsListComponent)]

您没有在PlannerScreen组件中使用SlotListComponent,所以没有必要在测试中模拟此组件。我认为,你可以自由地删除这一行。在此之后,测试工作正常。

不,它没有帮助。我在这里用它没有用。我在这里用它