在我和这位艺术家测试之后
import { HttpClientModule } from '@angular/common/http';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterModule } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { ArtistDetailComponent } from './artist-detail.component';
describe('ArtistDetailComponent', () => {
let component: ArtistDetailComponent;
let fixture: ComponentFixture<ArtistDetailComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule,
RouterModule,
HttpClientModule
],
declarations: [ ArtistDetailComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ArtistDetailComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});我得到了这个输出
27 04 2022 18:23:06.651:INFO启动浏览器ChromeHeadless 27 04 2022 18:23:09.795:INFO Chrome Headless 100.0.4896.127 (Linux x86_64):使用id 92608559 ChromeHeadless 100.4896.127 (Linux x86_64)连接到套接字iATQ5FHffdjRWSTWAAAB上:“不建议使用:没有子的描述( describe ()或it())”,并将在将来的Jasmine版本中删除。请移除描述或添加子元素。错误: at Env.jasmineEnv。webpack_require (http://localhost:9876//webpack:/webpack/bootstrap:19:1)的as describe at Object.4911 (http://localhost:9876//webpack:/src/app/modules/artist/artist-detail/artist-detail.component.spec.ts:8:1):此消息只显示一次。将verboseDeprecations配置属性设置为true以查看每个事件。‘Chrome 100.0.4896.127 (Linux x86_64)错误:“弃用:无子描述( describe ()或it())已被废弃,并将在未来版本的茉莉花中删除。请删除或向其添加子元素。错误:在Env.jasmineEnv,as describe at Object.4911 (http://localhost:9876//webpack:/src/app/modules/artist/artist-detail/artist-detail.component.spec.ts:8:1),在http://localhost:9876//webpack:/src/app/modules/artist/artist-detail/artist-detail.component.spec.ts:8:1 (http://localhost:9876//webpack:/webpack/bootstrap:19:1):此消息将只显示一次。将verboseDeprecations配置属性设置为真,以查看每个事件。”Chrome 100.0.4896.127 (Linux x86_64)错误:“弃用:无子描述( describe ()或it())已被废弃,并将在未来版本的茉莉花中删除。请删除或向其添加子元素。错误:在Env.jasmineEnv,as describe at Object.4911 (http://localhost:9876//webpack:/src/app/modules/artist/artist-detail/artist-detail.component.spec.ts:8:1),在http://localhost:9876//webpack:/src/app/modules/artist/artist-detail/artist-detail.component.spec.ts:8:1 (http://localhost:9876//webpack:/webpack/bootstrap:19:1):此消息将只显示一次。将verboseDeprecations配置属性设置为真,以查看每个事件。”ExhibitionDetailComponent✔应该创建
如何修复错误:“弃用”
非常感谢
发布于 2022-05-18 03:56:07
上述不推荐的警告不会告诉您哪个测试有问题。这就像一个简单的警告,其中一个测试有这个问题。
要找出哪些测试需要修复,请在verboseDeprecations karma.conf.js配置文件中添加::true (见下文)
client: {
jasmine: {
....
verboseDeprecations: true,
...
},
...
},然后运行所有或必需的单元测试,查看每个具有描述而没有子问题的测试的名称,并修复这些测试(添加子测试或删除描述)。
发布于 2022-08-17 11:05:19
这个答案并不直接回答上面的问题,但它可能会帮助其他遇到错误的人,因为我在寻找解决方案时一直在这里结束。
错误:
ERROR: 'DEPRECATION: describe with no children (describe() or it())
如果在代码击中内部describe或it函数之前发生错误,则可能发生这种情况。因此,测试代码永远不会到达内部函数。
在我的例子中,我是从Jasminv1.3.1升级到Jasmine v4的,我有下面的代码。请注意,对于被监视的对象,我对andReturn有不正确的Jasmine调用。因此,测试在到达内部describe函数之前就失败了。
define(function(require) {
'use strict';
return describe('Sample test', function () {
var saveMock = jasmine.createSpy('save').andReturn($.Deferred().resolve());
describe('test', function() {
it('should be true', function() {
expect(true).toEqual(true);
});
});
});
});修复API调用,然后修复实际问题并停止抛出错误describe with no children,因为它可以到达内部describe。
var saveMock = jasmine.createSpy('save').and.returnValue($.Deferred().resolve());发布于 2022-10-03 12:05:46
也有同样的错误。通过指定函数ìt来求解。既然您有2x beforeEach函数,我建议您编写如下
it('should create', () => {
const fixture = TestBed.createComponent(ArtistDetailComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});https://stackoverflow.com/questions/72046913
复制相似问题