AngularMock在测试组件时给我一个模块错误

mpbci0fu  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(231)

在尝试使用angularjs测试组件时,我收到以下错误。这个组件是我用这种语言创建的库的一部分,它使用jest而不是jasmine。

TypeError: angular_1.default.mock.module is not a function

   6 | describe('Badge', () => {
   7 |   beforeEach(() => {
>  8 |     angular.mock.module(['myApp.components.quoteCard']);
     |                  ^
   9 |   });
  10 |   it('renders badge', () => {
  11 |     render(`

这是符合规范的测试代码:

import angular from 'angular';
import 'angular-mocks';
import { render, screen } from 'angularjs-testing-library';
import './quote-card';

describe('Badge', () => {
  beforeEach(() => {
    angular.mock.module(['myApp.components.quoteCard']);
  });
  it('renders badge', () => {
    render(`
      <quote-card-component
        content="content"
        author="author"
      ></quote-card-component>
      `);

    expect(screen.getByText(`content`)).toBeInTheDocument();
  });
});

如果有人知道如何解决这个问题,那就太好了。谢谢大家!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题