gpt4 book ai didi

javascript - SystemJS+Typescript环境下Jasmine异步启动

转载 作者:行者123 更新时间:2023-12-03 05:01:50 25 4
gpt4 key购买 nike

我正在 SystemJS+Typescript 环境中运行 Jasmine 测试(基本上 a plunk 这应该是 Angular 2 测试平台)。

Jasmine 有意用作全局库,而不是通过 TypeScript import

这会导致

No specs found

控制台中没有错误,规范只是不运行:

main.ts

describe('test', () => {
it('test', () => {
console.log('test');
expect(1).toBe(1);
});
});

我确信这是由于 main.ts 与 SystemJS 异步加载的事实,因此应该另外触发 Jasmine 启动过程以使其符合规范。

该手册描述了什么是 default boot configuration in Jasmine ,但它没有很好地解释如何手动执行启动。

在这种情况下,使用 SystemJS 和全局 Jasmine 运行测试的方法是什么?

最佳答案

原因是您的规范是在 jasmine 尝试搜索和执行它们之后加载的。

要解决此问题,您可以在 system.js 加载规范后再次调用 window.onload:

<script>
System.import('app').then(window.onload).catch(console.error.bind(console));
</script>

关于javascript - SystemJS+Typescript环境下Jasmine异步启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42192500/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com